Closed jrfnl closed 7 months ago
Closing as replaced by https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/99
FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release.
As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).
Description
Follow up on #3629, which was merged for PHPCS 3.8.0.
PR #3629 added logic to throw a "Ruleset invalid. Property \"$propertyName\" does not exist on sniff ..." error.
This error is intended for the command-line when reading the
phpcs.xml.dist
ruleset file.However, this error could also be encountered if an inline
// phpcs:set ...
annotation would try to set a non-existent property.While the use of
// phpcs:set
is typically reserved for sniff test case files, there is nothing stopping end-users from using the annotation.The net-effect would be:
Ruleset::setSniffProperty()
throws aRuntimeException
.File::addMessage()
where it is not thrown as the line on which the error is being thrown is an annotation line.RuntimeException
was encountered.Internal
error is shown for the file.To me, this is counter-intuitive and counter-productive as it may give people a false sense of security (CI is green, while in reality files are not being scanned).
To fix this, I propose the following:
// phpcs:set
related inline annotations encountered while scanning.Includes a test via the
Generic.PHP.BacktickOperator
sniff.Suggested changelog entry
I'd suggest updating the existing changelog entry for the change from PR #3629 and adding:
Types of changes