This RFC further proposes the addition of a new optional per-file directive, declare(strict_types=1);, which makes all function calls and return statements within a file have “strict” type-checking for scalar type declarations, including for extension and built-in PHP functions.
Balabala......
然后是...
Behaviour of strict type checks
A strictly type-checked call to an extension or built-in PHP function changes the behaviour of zend_parse_parameters. In particular, it will produce E_RECOVERABLE_ERROR rather than E_WARNING on failure, and it follows strict type checking rules for scalar typed parameters, rather than the traditional weak type checking rules.
The strict type checking rules are quite straightforward: when the type of the value matches that specified by the type declaration it is accepted, otherwise it is not.
These strict type checking rules are used for userland scalar type declarations, and for extension and built-in PHP functions.
The one exception is that widening primitive conversion is allowed for int to float. This means that parameters that declare float can also accept int.
@
szopen @
br00k JavaScript或成最大赢家