array Is Not An Array¶
<?php
function foo(\array $a) {}
foo([]);
// Fatal error: Uncaught TypeError: foo():
// Argument #1 ($a) must be of type array, array given
?>
PHP native types, such as the scalar int cannot be specified with a leading \. Such code get hit with a Type declaration ‘\int’ must be unqualified.
This is the case for all of the PHP native types, except for array, and iterable.
That error message is really hilarious.
See Also¶
PHP Features¶
Last updated: 14 July 2026