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

PHPCSStandards / PHP_CodeSniffer / 30756320523
79%
master: 79%

Build:
Build:
LAST BUILD BRANCH: 4.x
DEFAULT BRANCH: master
Ran 02 Aug 2026 04:19PM UTC
Jobs 8
Files 265
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

02 Aug 2026 04:18PM UTC coverage: 78.983% (+0.005%) from 78.978%
30756320523

push

github

web-flow
Tokenizer/PHP: fix tokenizer error for a line comment before a ternary colon (#1448)

As things were, when a `//` or `#` line comment sits directly before the `:` of a ternary, with the comment on its own line and the `:` on the following line without indentation, tokenizing the file aborts on PHP 8+ with `An error occurred during processing; checking has been aborted. The error message was: `Trying to access array offset on null` pointing into `src/Tokenizers/PHP.php`. The tokenization itself would be correct though.

Additionally, when a closure/fn declaration with a return type would be in the "then" part and there would be an inline comment between the keyword and the open parenthesis of the function, both the return type colon, as well as the ternary else colon would be tokenized incorrectly. And PHP would also thrown a warning for `Trying to access array offset on null`.

This is related to the PHP 8.0 tokenization change for trailing new lines at the end of inline comments, which the PHPCS tokenizer "undoes". As part of that the original new line token entry is blanked out to `null`.
And while the main tokenizer loop skips those `null` entries, various subsections in the tokenizer do their own backward walking in the token stream and can still run into these `null` entries.

This commit fixes this for the code related to the inline else tokenization and adds tests to safeguard each of the situations outlined above.

Notes:
* Within this same section of the `PHP` class, there is [one additional backward walking `for` loop](https://github.com/andrewnicols/PHP_CodeSniffer/blob/e023fad5f/src/Tokenizers/PHP.php#L2627-L2636). As that loop only checks for explicit token values and doesn't try to check if the token is an array or attempt array access of the token, the extra condition should not be necessary.
* As for the tests - While mosts of the new tests do not fail without the change, they do throw warnings, which wou... (continued)

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

19891 of 25184 relevant lines covered (78.98%)

99.16 hits per line

Jobs
ID Job ID Ran Files Coverage
1 os-windows-latest-php-7.2-custom-ini-false - 30756320523.1 02 Aug 2026 04:19PM UTC 265
2.13
GitHub Action Run
2 os-windows-latest-php-8.5-custom-ini-false - 30756320523.2 02 Aug 2026 04:19PM UTC 265
2.68
GitHub Action Run
3 cbf-os-ubuntu-latest-php-7.2-custom-ini-false - 30756320523.3 02 Aug 2026 04:25PM UTC 265
1.3
GitHub Action Run
4 os-ubuntu-latest-php-7.2-custom-ini-false - 30756320523.4 02 Aug 2026 04:25PM UTC 265
75.86
GitHub Action Run
5 cbf-os-ubuntu-latest-php-8.5-custom-ini-true - 30756320523.5 02 Aug 2026 04:23PM UTC 265
2.33
GitHub Action Run
6 cbf-os-ubuntu-latest-php-8.5-custom-ini-false - 30756320523.6 02 Aug 2026 04:21PM UTC 265
2.33
GitHub Action Run
7 os-ubuntu-latest-php-8.5-custom-ini-false - 30756320523.7 02 Aug 2026 04:21PM UTC 265
76.67
GitHub Action Run
8 os-ubuntu-latest-php-8.5-custom-ini-true - 30756320523.8 02 Aug 2026 04:23PM UTC 265
76.57
GitHub Action Run
Source Files on build 30756320523
  • Tree
  • List 265
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #30756320523
  • c5bd7271 on github
  • Prev Build on 4.x (#30731945513)
  • Next Build on 4.x (#30766473066)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc