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

PHPCSStandards / PHPCSUtils / 49 / 31
91%
develop: 100%

Build:
Build:
LAST BUILD BRANCH: dependabot/github_actions/actions/upload-pages-artifact-5.0.0
DEFAULT BRANCH: develop
Ran 27 Dec 2019 02:19AM UTC
Files 3
Run time 0s
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

27 Dec 2019 02:02AM UTC coverage: 78.344% (+0.8%) from 77.57%
LINT=1 PHPCS_VERSION="dev-master" COVERALLS_VERSION="^1.0"

Pull #11

travis-ci-com

web-flow
:sparkles: New BackCompat\BCTokens class

PHPCS provides a number of static token arrays in the `PHP_CodeSniffer\Util\Tokens` class.
Some of these token arrays will not be available in older PHPCS versions.
Some will not contain the same set of tokens across PHPCS versions.

The `PHPCSUtils\BackCompat\BCTokens` class is a compatibility layer to allow for retrieving these token arrays with a consistent token content across PHPCS versions.
The one caveat is that the token constants do need to be available.

The class is named `BCTokens` instead of `Tokens` on purpose to more easily allow sniffs to use both the PHPCS native Tokens class as well as this class without always having to alias one of the two.

Recommended usage:
Only use the methods in this class when needed. I.e. when your sniff unit tests indicate a PHPCS cross-version compatibility issue related to inconsistent token arrays.

All PHPCS token arrays are supported, though only a limited number of them are different across PHPCS versions.

The names of the PHPCS native token arrays translate one-on-one to the methods in this class:
- `PHP_CodeSniffer\Util\Tokens::$emptyTokens` => `PHPCSUtils\BackCompat\BCTokens::emptyTokens()`
- `PHP_CodeSniffer\Util\Tokens::$operators`     => `PHPCSUtils\BackCompat\BCTokens::operators()`
    ... etc

The order of the tokens in the arrays may differ between the PHPCS native token arrays and the token arrays returned by this class.

Also note: While `T_LIST` and `T_ANON_CLASS` will be included in the return value for the `parenthesisOpeners()` method, the associated parentheses will not have the `'parenthesis_owner'` index set until PHPCS 3.5.0.

Methods:
* `assignmentTokens()`
* `comparisonTokens()`
* `arithmeticTokens()`
* `operators()`
* `parenthesisOpeners()`
* `phpcsCommentTokens()`
* `textStringTokens()`
* `functionNameTokens()`
* `ooScopeTokens()`
* `__callStatic()` - to retrieve the other token arrays which haven't had any relevant changes between PHPC... (continued)
Pull Request #11: New BackCompat\BCTokens class

123 of 157 relevant lines covered (78.34%)

2.54 hits per line

Source Files on job 49.31 (LINT=1 PHPCS_VERSION="dev-master" COVERALLS_VERSION="^1.0")
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 10
  • Travis Job 49.31
  • 783d40d9 on github
  • Prev Job for LINT=1 PHPCS_VERSION="dev-master" COVERALLS_VERSION="^1.0" on feature/backcompat-new-bctokens-class (#44.31)
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