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

PHPCSStandards / PHPCSUtils / 253 / 32
97%
develop: 100%

Build:
Build:
LAST BUILD BRANCH: dependabot/github_actions/actions/upload-pages-artifact-5.0.0
DEFAULT BRANCH: develop
Ran 30 Jan 2020 06:14PM UTC
Files 24
Run time 2s
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

30 Jan 2020 05:55PM UTC coverage: 94.95% (+0.3%) from 94.675%
PHPCS_VERSION="2.6.0" COVERALLS_VERSION="^1.0"

Pull #70

travis-ci-com

web-flow
:sparkles: New Utils\ControlStructures class

This adds three new utility methods:
* `hasBody()` - to check whether a control structure has a body and optionally whether that body is non-empty. Returns boolean.
    This is a helper function to distinguish between structures like `while (++$i < 10);` and `while (++$i < 10) { /* do something */ }`.
* `isElseIf()` - to check whether an `T_IF` or `T_ELSE` token is part of an `else if`. Returns boolean.
* `getDeclareScopeOpenClose()` - to retrieve the scope open/close pointers for `declare` statements. Returns an array with the stack pointers or false if a file based statement or if the scope open/close pointers could not be determined.
    Declare statements come in three flavours:
    - file based, without body: `declare(ticks=1);`;
    - scoped using curly braces;
    - scoped using the alternative control structure syntax.
    In that last case, PHPCS does not assign the scope open/close indexes in the `$tokens` array. A [PR is open to fix this](https://github.com/squizlabs/PHP_CodeSniffer/pull/2843), but for any sniff which needs to support versions of PHPCS prior to the version in which that PR will be merged, this helper method can retrieve the scope open/close indexes.

This commit also adds two convenience token arrays for working with control structures to the `PHPCSUtils\Tokens\Collections` class.
* `$alternativeControlStructureSyntaxTokens` - tokens which can use the alternative syntax for control structures.
* `$controlStructureTokens` - control structure tokens.

Includes extensive dedicated unit tests.
Pull Request #70: New Utils\ControlStructures class

2482 of 2614 relevant lines covered (94.95%)

16.4 hits per line

Source Files on job 253.32 (PHPCS_VERSION="2.6.0" COVERALLS_VERSION="^1.0")
  • Tree
  • List 0
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 89
  • Travis Job 253.32
  • c1ed22b4 on github
  • Prev Job for PHPCS_VERSION="2.6.0" COVERALLS_VERSION="^1.0" on feature/new-controlstructures-class (#250.32)
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