Array Has No Absolute Name¶
Classes may be used as type, with an optional leading \. This is not the case for scalar types, such as int or string, but it was the case for array. In PHP 8.5, it is now homogenized.
PHP code¶
<?php
function foo(\array $x = []) {}
?>
Before¶
PHP Fatal error: Cannot use array as default value for parameter $x of type array
Fatal error: Cannot use array as default value for parameter $x of type array
After¶
PHP Fatal error: Cannot use array as a type name as it is reserved
Fatal error: Cannot use array as a type name as it is reserved
PHP version change¶
This behavior changed in 8.5