If a PHP function has a parameter type hint (or "type declaration") that says "array", and you call this function with another value, e.g. an integer, there should be a
Fatal error: Uncaught TypeError: Argument 1 passed to foo() must be of the type array, integer given".
Code:
function foo(array $x) {}
foo(5); // -> Fatal error.
The 3v4l confirms this: https://3v4l.org/7BTtr.
Errors are shown in all relevant PHP versions.
However, I have a local PHP project where the type hint is silently ignored, no error is shown, and subsequent code executes normally.
Some debugging:
- If I insert the offending code at the beginning of the script (start of index.php), the error is triggered.
- If I insert the offending code some place later in the script, the error no longer appears.
I imagine there is an ini_set() or something which changes the behavior of PHP towards these errors.
But I don't know which PHP setting, if any, would be responsible for ignoring type errors.