Skip to content

\array should not be usable #16665

Closed
Closed
@exakat

Description

@exakat

Description

The following code allows the configuration of \array as a custom (anonymous) class.

<?php

$a = new class() {};

class_alias($a::class, \array::class);

function foo(\array $x) {
    print_r($x);
}

foo($a);

?>

Resulted in this output (see https://3v4l.org/Wsb8F)

class@anonymous Object
(
)

But I expected this output instead:

Cannot use 'array' as class name as it is reserved 
Type declaration 'array' must be unqualified

As a side note, callable has the same behavior as 'array' and should be aligned.

PHP Version

8.3.13 (also 8.4 and older PHP versions)

Operating System

Tested on OSX, debian and ubuntu.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions