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

PHPCSStandards / PHP_CodeSniffer / 8867362179
78%
master: 79%

Build:
Build:
LAST BUILD BRANCH: 4.x
DEFAULT BRANCH: master
Ran 28 Apr 2024 11:55AM UTC
Jobs 3
Files 260
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 Apr 2024 11:52AM UTC coverage: 73.16% (+0.09%) from 73.069%
8867362179

push

github

jrfnl
PHP 8.2 | Tokenizer/PHP: add support for DNF types

This commit adds tokenizer support for DNF types as per the proposal outlined in 387.

This means that:
* Two new tokens are introduced `T_TYPE_OPEN_PARENTHESIS` and `T_TYPE_CLOSE_PARENTHESIS` for the parentheses used in DNF types.
    This allows for sniffs to specifically target those tokens and prevents sniffs which are looking for the "normal" open/close parenthesis tokens from acting on DNF parentheses.
* These new tokens, like other parentheses, will get the `parenthesis_opener` and `parenthesis_closer` token array indexes and the tokens between them will have the `nested_parenthesis` index.

Based on the currently added tests, the commit safeguards that:
* The `|` in types is still tokenized as `T_TYPE_UNION`, even in DNF types.
* The `&` in types is still tokenized as `T_TYPE_INTERSECTION`, even in DNF types.
* The `static` keyword for properties is still tokenized as `T_STATIC`, even when right before a DNF type (which could be confused for a function call).
* The arrow function retokenization to `T_FN` with a `T_FN_ARROW` scope opener is handled correctly, even when DNF types are involved and including when the arrow function is declared to return by reference.
* The keyword tokens, like `self`, `parent`, `static`, `true` or `false`, when used in DNF types are still tokenized to their own token and not tokenized as `T_STRING`.
* The `array` keyword when used in DNF types is still tokenized as `T_STRING` and not as `T_ARRAY`.
* A `?` intended as an (illegal) nullability operator in combination with a DNF type is still tokenized as `T_NULLABLE` and not as `T_INLINE_THEN`.
* A function declaration open parenthesis before a typed parameter isn't accidentally retokenized to `T_TYPE_OPEN_PARENTHESIS`.

Includes ample unit tests.

Even so, strenuous testing of this PR is recommended as there are so many moving parts involved, it is very easy for something to have been overlooked.

Related to 105

... (continued)

79 of 86 new or added lines in 1 file covered. (91.86%)

7 existing lines in 1 file now uncovered.

17764 of 24281 relevant lines covered (73.16%)

67.5 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
7
84.72
-0.23% src/Tokenizers/PHP.php

Uncovered Existing Lines

Lines Coverage ∆ File
7
84.72
-0.23% src/Tokenizers/PHP.php
Jobs
ID Job ID Ran Files Coverage
1 php-8.1-custom-ini-true - 8867362179.1 28 Apr 2024 11:55AM UTC 260
71.64
GitHub Action Run
2 php-7.2-custom-ini-false - 8867362179.2 28 Apr 2024 11:57AM UTC 260
69.11
GitHub Action Run
3 php-8.3-custom-ini-false - 8867362179.3 28 Apr 2024 11:55AM UTC 260
71.6
GitHub Action Run
Source Files on build 8867362179
  • Tree
  • List 260
  • Changed 3
  • Source Changed 2
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #8867362179
  • 939fd02a on github
  • Prev Build on 4.0 (#8867171703)
  • Next Build on 4.0 (#8867554128)
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