Closed paulschreiber closed 6 years ago
Updated from what version ? This sniff has not been changed in v 3.1.0.
Upgraded from 2.7.1.
That code construct has always been banned by the Squiz.PHP.DisallowMultipleAssignments sniff.
I have checked this on version 3.1.0 (latest), master, 2.7.1, and even went back to version 1.5.5. All versions have the same check and show the same error.
So I don't think your new errors are coming from the upgrade itself. Are you using a custom coding standard? Did it change? Can you make it available for testing?
I'm using the WordPress-VIP
coding standard. Odd that I hadn't caught these before. I've fixed them in my code.
If this is intended to be disallowed, PHPCS should do a better job of distinguishing between these two types of errors:
Multiple assignments:
$a = $b = false;
Assign and compare
if ( ( $key = array_search( 'tag', $classes, true ) ) !== false ) {
PHPCS should do a better job of distinguishing between these two types of errors
The sniff reporting the error doesn't make a distinction because it doesn't need to. If you think the WordPress coding standard should make a distinction, you could ask over there.
I'll close this as the sniff is working as intended and the behaviour has not changed during the upgrade. It's likely that the coding standard itself changed.
It's likely my ruleset/exclusions changed.
I don't think WPCS should make a distinction here, as its rule isn't the one being violated. Since it's a Squiz.PHP rule, PHPCS would be a better place to make that distinction.
I updated PHPCS to 3.1.0 and I’m now getting a lot of
Assignments must be the first block of code on a line
errors.They’re on code like this:
Are you intending to prohibit these sorts of expressions? If so, it would be good to use a different type of error message. If not, can you fix this?