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

PHPCSStandards / PHP_CodeSniffer / 19056334694
79%
master: 79%

Build:
Build:
LAST BUILD BRANCH: 4.x
DEFAULT BRANCH: master
Ran 04 Nov 2025 03:01AM UTC
Jobs 8
Files 310
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

04 Nov 2025 02:59AM UTC coverage: 78.603% (+0.004%) from 78.599%
19056334694

push

github

web-flow
PHP 8.5 | Tokenizer/PHP: properly fix "Using null as an array offset" deprecation (#1230)

If a slash/hash comment is on its own line, the new line token is merged into the comment token for PHP 8.0+, and the new line is skipped by setting it to `null`.

The PHP Tokenizer did not take the possibility of a token being set to `null` into account when retokening a `?` to either `T_NULLABLE` or `T_INLINE_THEN`, leading to the PHP 8.5 deprecation notice.
In that case, the sniff first looks forward to see if we can draw a conclusion based on the non-empty tokens following the `?` and if not, walks backward to look at the tokens before the `?`.
The problem occurs when a `null` token exists in the sequence before the `?`.

This `null` token will only have been injected with a specific code sequence: when there is a slash/hash comment followed by a new line in the token sequence before the `?` and there is no indentation/new line whitespace on the next line.

Also see the detailed analysis by andrewnicols in PHPCSStandards/PHP_CodeSniffer 1216#issuecomment-3274198443

There are only two situations in which this causes the tokenizer to hit the PHP 8.5 "Using null as an array offset" deprecation notice:
1. If the `?` token is the last token in the file (live coding - the issue was discovered via a test related to live coding).
2. If there are tokens after the `?`, but not tokens which allows us to draw a conclusion (yet) and there is a slash/hash comment between the `?` and the previous non-empty token.

This commit:
1. Adds dedicated tests for both situations.
2. Adds a new fix for situation [1] as if there are no tokens after a `?`, we cannot determine definitively whether the `?` is a nullable operator or an inline then. For BC, this should be tokenized as `T_INLINE_THEN`.
3. Makes a small tweak to the previously added fix which addressed situation [2].
    Alternatively, we could consider switching to using the "$finalTokens" token stack to do the token walk... (continued)

14 of 15 new or added lines in 1 file covered. (93.33%)

25344 of 32243 relevant lines covered (78.6%)

74.87 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
87.66
0.02% src/Tokenizers/PHP.php
Jobs
ID Job ID Ran Files Coverage
1 os-ubuntu-latest-php-5.4-custom-ini-false - 19056334694.1 04 Nov 2025 03:31AM UTC 310
72.68
GitHub Action Run
2 cbf-os-ubuntu-latest-ubuntu-latest-php-5.4-custom-ini-false - 19056334694.2 04 Nov 2025 03:31AM UTC 310
1.43
GitHub Action Run
3 os-ubuntu-latest-php-7.2-custom-ini-true - 19056334694.3 04 Nov 2025 03:06AM UTC 310
71.57
GitHub Action Run
4 os-windows-latest-php-5.5-custom-ini-false - 19056334694.4 04 Nov 2025 03:03AM UTC 310
2.18
GitHub Action Run
5 cbf-os-ubuntu-latest-ubuntu-latest-php-8.4-custom-ini-false - 19056334694.5 04 Nov 2025 03:04AM UTC 310
1.84
GitHub Action Run
6 os-ubuntu-latest-php-8.4-custom-ini-false - 19056334694.6 04 Nov 2025 03:04AM UTC 310
73.94
GitHub Action Run
7 os-windows-latest-php-8.4-custom-ini-false - 19056334694.7 04 Nov 2025 03:01AM UTC 310
2.5
GitHub Action Run
8 cbf-os-ubuntu-latest-ubuntu-latest-php-7.2-custom-ini-true - 19056334694.8 04 Nov 2025 03:06AM UTC 310
0.89
GitHub Action Run
Source Files on build 19056334694
  • Tree
  • List 310
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #19056334694
  • e163dbfc on github
  • Prev Build on 3.x (#19022120041)
  • Next Build on 3.x (#19075725465)
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