php-src/Zend/tests/readonly_function.phpt
Nikita Popov 76348f3378
Allow using readonly as function name
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.
2021-09-13 08:50:32 +02:00

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!