[php-src] Issue #10309: token_get_all() invalid behavior with readonly and DNF tokens

From: Date: Fri, 13 Jan 2023 09:39:47 +0000
Subject: [php-src] Issue #10309: token_get_all() invalid behavior with readonly and DNF tokens
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243432@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10309 Author: mrsuh ### Description The following code: tokens.php ```php <?php $code = <<<'CODE' <?php class A {} class B {} class Container { public readonly (A&B)|null $property1; public readonly null|(A&B) $property2; } CODE; foreach (token_get_all($code) as $token) { if (is_array($token)) { echo "Line {$token[2]}: ", token_name($token[0]), " ('{$token[1]}')", PHP_EOL; } } ``` ```bash docker run -it --rm -v "$PWD":/app php:8.1-cli php /app/tokens.php | grep readonly ``` Resulted in this output: ``` Line 7: T_STRING ('readonly') Line 8: T_READONLY ('readonly') ``` But I expected this output instead: ``` Line 7: T_READONLY ('readonly') Line 8: T_READONLY ('readonly') ``` ### PHP Version PHP 8.1 ### Operating System _No response_

« previous php.bugs (#243432) next »