1.2.904. PHP 7.0 Scalar Typehints

New scalar typehints were introduced : bool, int, float, string.

They cannot be used before PHP 7.0, and will be confused with classes or interfaces.

<?php

function foo(string $name) {
    print "Hello $name";
}

foo("Damien");
// display 'Hello Damien'

foo(33);
// displays an error

?>

See also Scalar type declarations and PHP 7 SCALAR TYPE DECLARATIONS.

1.2.904.1. Specs

Short name

Php/PHP70scalartypehints

Rulesets

All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56

Exakat since

1.3.5

PHP Version

With PHP 7.0 and more recent

Severity

Critical

Time To Fix

Quick (30 mins)

Precision

Very high

Features

class

Available in

Entreprise Edition, Exakat Cloud