Cannot use "%s" as %s as it is reserved

Description

array and callable cannot be used with the leading backslash. This bug was fixed in PHP 8.5.

Example

<?php

// Since PHP 8.5
function foo() : \array {}

?>

Solutions

  • Use the type without the leading \.

  • Upgrade to PHP 8.5 (when available).