mirror of
https://github.com/php/php-src.git
synced 2026-03-24 16:22:37 +01:00
Don't treat "readonly" as a keyword if followed by "(". This
allows using it as a global function name. In particular, this
function has been used by WordPress.
This does not allow other uses of "readonly", in particular it
cannot be used as a class name, unlike "enum". The reason is that
we'd still have to recognize it as a keyword when using in a type
position:
class Test {
public ReadOnly $foo;
}
This should now be interpreted as a readonly property, not as a
read-write property with type `ReadOnly`. As such, a class with
name `ReadOnly`, while unambiguous in most other circumstances,
would not be usable as property or parameter type. For that
reason, we do not support it at all.
17 lines
152 B
PHP
17 lines
152 B
PHP
--TEST--
|
|
Can use readonly as a function name
|
|
--FILE--
|
|
<?php
|
|
|
|
function readonly() {
|
|
echo "Hi!\n";
|
|
}
|
|
|
|
readonly();
|
|
readonly ();
|
|
|
|
?>
|
|
--EXPECT--
|
|
Hi!
|
|
Hi!
|