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

PHPCSStandards / PHP_CodeSniffer / 13729446547
79%

Build:
DEFAULT BRANCH: master
Ran 07 Mar 2025 09:17PM UTC
Jobs 8
Files 309
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

07 Mar 2025 09:15PM UTC coverage: 78.556%. Remained the same
13729446547

push

github

web-flow
Tests/Tokenizer: fix bug in the `default` keyword tests (#850)

This commit fixes a bug in `RecurseScopeMapDefaultKeywordConditionsTest
::testSwitchDefault()`. Among other things, this method checks whether
tokens within the scope of a `default` have `T_DEFAULT` set as the scope
condition.

But the code would never check if the scope condition is set for the
tokens within the scope of a `T_DEFAULT` token when `$conditionStop` is
not `null`. `$conditionStop` is used when `T_DEFAULT` uses curlies to
open and close the scope. In those cases, scope conditions are not set
all the way until the scope closer. Instead, they are set only until
just before a T_BREAK|T_RETURN|T_CONTINUE.

`simple_switch_default_with_curlies` test case is the only one that
currently sets `$conditionStop` to something other than `null`. But it
passes an offset value of the condition stop while the code was
expecting an absolute value of the index of the token where the scope
condition stops being set. Passing an offset meant that when `$end` was
set to be equal to `$conditionStop` it would always be less than `$i`
and the assertion inside the `for` loop would never run:

https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/be74da1a2/tests/Core/Tokenizers/Tokenizer/RecurseScopeMapDefaultKeywordConditionsTest.php#L160-L170

Now the code calculates the correct value for `$end` when
`$conditionStop` is not null. It was also necessary to update the value
for `$conditionStop` in `simple_switch_default_with_curlies` as it was
pointing to the wrong token.

This uncovered an inconsistency in the tokenizer that might need to be
addressed in a separate issue. When `T_DEFAULT` doesn't use curlies the
tokenizer sets `scope_condition` for all the tokens until the token just
before `T_BREAK|T_RETURN|T_CONTINUE`. But when there are curlies,
`scope_condition` is set including for `T_BREAK|T_RETURN|T_CONTINUE`. It
needs to be determined if this behavior is intentional or not.

24694 of 31435 relevant lines covered (78.56%)

66.41 hits per line

Jobs
ID Job ID Ran Files Coverage
1 os-windows-latest-php-8.4-custom-ini-false - 13729446547.1 07 Mar 2025 09:17PM UTC 309
2.43
GitHub Action Run
2 cbf-os-ubuntu-latest-ubuntu-latest-php-7.2-custom-ini-true - 13729446547.2 07 Mar 2025 09:22PM UTC 309
0.73
GitHub Action Run
3 cbf-os-ubuntu-latest-ubuntu-latest-php-5.4-custom-ini-false - 13729446547.3 07 Mar 2025 09:43PM UTC 309
1.28
GitHub Action Run
4 os-windows-latest-php-5.5-custom-ini-false - 13729446547.4 07 Mar 2025 09:18PM UTC 309
2.14
GitHub Action Run
5 os-ubuntu-latest-php-7.2-custom-ini-true - 13729446547.5 07 Mar 2025 09:22PM UTC 309
71.38
GitHub Action Run
6 os-ubuntu-latest-php-8.4-custom-ini-false - 13729446547.6 07 Mar 2025 09:20PM UTC 309
74.01
GitHub Action Run
7 cbf-os-ubuntu-latest-ubuntu-latest-php-8.4-custom-ini-false - 13729446547.7 07 Mar 2025 09:20PM UTC 309
1.7
GitHub Action Run
8 os-ubuntu-latest-php-5.4-custom-ini-false - 13729446547.8 07 Mar 2025 09:43PM UTC 309
72.48
GitHub Action Run
Source Files on build 13729446547
  • Tree
  • List 309
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #13729446547
  • dc3a6393 on github
  • Prev Build on master (#13726080863)
  • Next Build on master (#13730164121)
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

© 2025 Coveralls, Inc