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

PHPCSStandards / PHPCSUtils / 49
91%
develop: 100%

Build:
Build:
LAST BUILD BRANCH: dependabot/github_actions/action-runners-c4b2a15d30
DEFAULT BRANCH: develop
Ran 27 Dec 2019 02:18AM UTC
Jobs 4
Files 9
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

pending completion
49

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

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

369 of 405 relevant lines covered (91.11%)

10.02 hits per line

Jobs
ID Job ID Ran Files Coverage
29 49.29 (LINT=1 PHPCS_VERSION="dev-master" COVERALLS_VERSION="^2.0") 27 Dec 2019 02:18AM UTC 0
82.22
Travis Job 49.29
30 49.30 (PHPCS_VERSION="2.9.2" COVERALLS_VERSION="^2.0") 27 Dec 2019 02:18AM UTC 0
77.04
Travis Job 49.30
31 49.31 (LINT=1 PHPCS_VERSION="dev-master" COVERALLS_VERSION="^1.0") 27 Dec 2019 02:19AM UTC 0
78.34
Travis Job 49.31
32 49.32 (PHPCS_VERSION="2.6.0" COVERALLS_VERSION="^1.0") 27 Dec 2019 02:19AM UTC 0
67.52
Travis Job 49.32
Source Files on build 49
Detailed source file information is not available for this build.
  • Back to Repo
  • Build #49
  • Pull Request #11
  • PR Base - develop (#44)
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