Cannot use “%s” as a type name as it is reserved

Description

array is a native PHP type, and it cannot be used with the leading \. This is also the case for the other native types, such as int or string, although they provide a different error message.

Example

<?php

function foo(\array $array) {}

?>

Literal Examples

  • Cannot use “array” as a type name as it is reserved

Solutions

  • Remove the leading \, before the array.

  • Change the type from array to an actual class.