Underscore Named Class

It is not possible to name a class _ underscore anymore.

This applies to classes, interfaces, traits and enumerations. It applies in every namespace.

It does not applies to functions, although that name is usually a native PHP function from the gettext extension. It also does not apply to constants, methods, class constants and variables.

It is still possible to name a class with a longer name, starting with an underscore.

The _ is being reserved for the future pattern matching feature of PHP.

PHP code

<?php

class _ {}

print get_class(new _);

?>

Before

_

After

PHP Deprecated:  Using "_" as a class name is deprecated since 8.4

Deprecated: Using "_" as a class name is deprecated since 8.4
_

PHP version change

This behavior changed in 8.4

Error Messages

Analyzer