Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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: 09 November 2026