• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPCSStandards / PHP_CodeSniffer / 11545087532
78%
master: 79%

Build:
Build:
LAST BUILD BRANCH: fix/missing-static-token
DEFAULT BRANCH: master
Ran 28 Oct 2024 12:28AM UTC
Jobs 3
Files 261
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Oct 2024 12:23AM UTC coverage: 74.124% (+0.001%) from 74.123%
11545087532

push

github

jrfnl
Generic/RequireExplicitBooleanOperatorPrecedence: remove
unreachable condition

This commit reverts the changes to the
`Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence` sniff
introduced in
https://github.com/PHPCSStandards/PHPCSExtra/pull/271/commits/7b38efb98.
The sniff's tests remain relevant, so they were preserved.

The original commit was added to fix false positives that the sniff was
triggering when handling boolean operators inside a match (see
https://github.com/PHPCSStandards/PHPCSExtra/pull/271#pullrequestreview
-1634348864 and
https://github.com/PHPCSStandards/PHPCSExtra/pull/271#issuecomment-1729104556
). Example:

```php
match (true) {
    $a || ($b && $c) => true,
};
```

I believe the false positive was actually caused by a bug in
`File::findStartOfStatement()`. This bug was then fixed in
https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/502/commits/b82438f2e
which rendered the changes to the sniff itself unnecessary and the
removed condition unreachable.

Before this fix, when processing the code example above,
`File::findStartOfStatement()` returned the variable `$a` as the
start of the statement for the `&&` boolean operator. This meant that
`$previous` would be set to `||` and the removed condition would be
needed to ensure the sniff would bail instead of triggering an error.

After this fix, `File::findStartOfStatement()` returns `$b` as the start
of the statement and then `$previous` is set to `false` and the sniff
bails before reaching the removed condition.

Including `Tokens::$blockOpeners` in
`RequireExplicitBooleanOperatorPrecedenceSniff::$searchTargets` was
necessary only for the removed condition, so it was removed as well.

1 of 1 new or added line in 1 file covered. (100.0%)

18098 of 24416 relevant lines covered (74.12%)

72.79 hits per line

Jobs
ID Job ID Ran Files Coverage
1 php-7.2-custom-ini-false - 11545087532.1 28 Oct 2024 12:29AM UTC 0
70.08
GitHub Action Run
2 php-8.3-custom-ini-false - 11545087532.2 28 Oct 2024 12:28AM UTC 0
72.67
GitHub Action Run
3 php-8.1-custom-ini-true - 11545087532.3 28 Oct 2024 12:28AM UTC 0
72.7
GitHub Action Run
Source Files on build 11545087532
Detailed source file information is not available for this build.
  • Back to Repo
  • Github Actions Build #11545087532
  • 739aa751 on github
  • Prev Build on 4.0 (#11525347559)
  • Next Build on 4.0 (#11568633781)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc