Re: Request for opinions: bug vs feature - change intokenization of yield from
| From: | Bob Weinand | Date: | Thu, 18 Jul 2024 23:09:49 +0000 |
| Subject: | Re: Request for opinions: bug vs feature - change intokenization of yield from | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-124503@lists.php.net to get a copy of this message | ||
Hey Christoph,
Am 19.07.2024 um 00:51 schrieb Christoph M. Becker <cmbecker69@gmx.de>:
Hi Bob!
On 18.07.2024 at 15:41, Bob Weinand wrote:
Moreover, it can - at least - be worked around in tooling by special casing the T_YIELD_FROM token
and extracting the comment from the raw parsed string:
var_dump(token_get_all('<?php yield /* comment */ from $foo;'));
will contain:
[1]=> array(3) { [0]=> int(270) [1]=> string(24) "yield /* comment */ from"
[2]=> int(1) }
It's not optimal, but probably the least bad solution to leave it unchanged in PHP 8.3, have
tooling special case it and properly fix it in PHP 8.4.
And what about "code" like <https://3v4l.org/4CLhM>? Is Codesniffer
supposed to scan the result of <https://3v4l.org/dKDcs>
for possible CS
violations?
Cheers,
Christoph
I suppose you mean https://3v4l.org/IMi8Y, (you missed the
<?php tag).
If you want to scan that, it's quite easy to strip the leading yield and trailing from, and
tokenize that again to extract all comments.
Sure, it's a hack, but it'll work: https://3v4l.org/8eAiV.
Bob