PHP 8.4 | :sparkles: New `PHPCompatibility.Classes.NewAbstractProperties` sniff by jrfnl · Pull Request #1901 · PHPCompatibility/PHPCompatibility

@jrfnl jrfnl mentioned this pull request

Sep 5, 2025

58 tasks

@jrfnl

As of PHP 8.4, (hooked) properties can be declared as `abstract`.

Notes:
* The "abstract" modifier is not supported in constructor property promotion as that wouldn't make sense.
* The "abstract" modifier is also not supported for interface properties as those are implicitly abstract (but that's not the concern of this sniff).

This commit adds a new sniff to detect abstract properties as supported in PHP 8.4.

For this sniff to function correctly, the PHPCSUtils minimum version needs to be v 1.1.2, which includes support for abstract properties via the `Variables::getMemberProperties()` method.

Includes tests.
Includes documentation.

Refs:
* https://wiki.php.net/rfc/property-hooks#abstract_properties
* php/php-src 13455
* php/php-src@780a828

wimg

wimg approved these changes Sep 8, 2025

@wimg wimg deleted the php-8.4/new-newabstractpropertiessniff branch

September 8, 2025 14:45

@jrfnl jrfnl mentioned this pull request

Nov 19, 2025