You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHPCS displays a fatal error when the user inadvertently tries to change a sniff property that can't be changed from outside the class. Consider the ruleset.xml file below:
I suppose a friendlier error message would be nice, but changing non-public properties was never supported and has never been a feature of PHPCS, so I'm not too concerned about people getting a fatal about that. I've also never seen anyone report seeing that fatal or even asking for support because of it.
The code you are referring to above was introduced to handle the PHP 8.2 dynamic properties deprecations and dynamic properties are public by nature, so that's a completely different matter.
All in all, while giving people friendly error messages is a good thing, I don't think we need to accommodate every single thing people may possibly try to do, even though it's never been supported.
Is your feature request related to a problem?
PHPCS displays a fatal error when the user inadvertently tries to change a sniff property that can't be changed from outside the class. Consider the
ruleset.xml
file below:It results in the following PHP fatal error:
Describe the solution you'd like
I want to suggest that instead of a fatal error, PHPCS display a user-friendly error message alerting that the property cannot be changed.
It needs to be determined in which cases PHPCS cannot change the sniff property. Here is a non-exhaustive list:
__set()
magic method does not exist in the sniff class.Additional context
Here is the code that checks if the property exists and displays an error if it doesn't:
PHP_CodeSniffer/src/Ruleset.php
Lines 1571 to 1586 in 95e3a35
The text was updated successfully, but these errors were encountered: