PHP 8.3 | :sparkles: New `PHPCompatibility.Generators.NewYieldFromComment` sniff by jrfnl · Pull Request #1792 · PHPCompatibility/PHPCompatibility

@jrfnl

> . In addition to whitespace characters, now comments are allowed between
>   `yield` and `from`. The whole "construct" (e.g. `yield /* comment */ from`)
>   is reported as a single `T_YIELD_FROM` token by the tokenizer.

This commit adds a new sniff which detects this in a PHPCS cross-version compatible manner.

Once support for PHPCS < 3.11.0 has been dropped, this sniff can be simplified, but IMO, this sniff alone is not enough reason to raise the minimum supported PHPCS version, especially as working around the different tokenizations isn't that complicated.

Includes tests.
Includes documentation.

Refs:
* php/php-src 14926
* https://github.com/php/php-src/blob/e4010fcf957c62ddb70f8d3296d52c5486a84d4d/UPGRADING#L48-L50
* php/php-src 10125
* php/php-src@f291d37

Related to 1589
Fixes 1720

@jrfnl jrfnl marked this pull request as ready for review

November 2, 2024 10:59

wimg

wimg approved these changes Nov 29, 2024

@wimg wimg deleted the feature/new-newyieldfromcomment-sniff branch

November 29, 2024 23:41

@jrfnl jrfnl mentioned this pull request

Jul 6, 2025

@jrfnl jrfnl mentioned this pull request

Sep 1, 2025