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

PHPCSStandards / PHP_CodeSniffer / 15719074832
79%
master: 79%

Build:
Build:
LAST BUILD BRANCH: feature/fixer-conflict/PSR12.Functions.ReturnTypeDeclaration
DEFAULT BRANCH: master
Ran 17 Jun 2025 10:11PM UTC
Jobs 8
Files 265
Run time 2min
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

17 Jun 2025 10:10PM UTC coverage: 78.771% (+0.04%) from 78.728%
15719074832

push

github

web-flow
Generic/InlineControlStructure: bail early for control structures without body (#880)

* Generic/InlineControlStructure: bail early for control structures without body

The sniff now consistently handles all supported control structures
without a body by bailing early. Extending the existing behavior for
`while` and `for` to also include `do while`, `else`, `elseif`, `if`,
and `foreach`.

Previously, the sniff would incorrectly flag these empty control
structures as inline control structures that needed curly braces. For
`else`, `elseif`, `if`, and `foreach`, the fixer would remove the
semicolon and add the curly braces. For `do while`, the fixer would add
the curly braces and keep the semicolon in between the braces. In all
the cases, the resulting code was syntactically correct.

Consider the following example:

```
do ; while ($foo < 5);
```

Previously, PHPCS would flag this as an inline control structure and
PHPCBF would fix it to:

```
do { ;
} while ($foo < 5);
```

Now an empty `do while` is ignored by the sniff (no warnings and no
fixes).

Here is a link showing that control structures without a body are
valid in PHP:

https://3v4l.org/slnYL

And here is a link showing that the way that they were being fixed by
PHPCBF was resulting in valid code (`while` and `for` are not included
below as they were already ignored before this commit):

https://3v4l.org/8k1N3

* Generic/InlineControlStructure: removed unnecessary code block

29d0be3e changed the sniff to bail early for all control structures
without body, so the code will never reach the fixer if `$closer + 1` is
`T_SEMICOLON` and thus the removed condition is not necessary anymore.

* Generic/InlineControlStructure: removed another unnecessary code block

The original version of this part of the code that is now being removed
was added in the early days by the commit that enabled this sniff to fix
errors:

https://github.com/squizlabs/PHP_CodeSniffer/commit/a54c619#diff-4b3945c2100b0a92a5650... (continued)

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

1 existing line in 1 file now uncovered.

19762 of 25088 relevant lines covered (78.77%)

88.94 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
1
96.03
8.0% src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php
Jobs
ID Job ID Ran Files Coverage
1 os-ubuntu-latest-php-8.4-custom-ini-false - 15719074832.1 17 Jun 2025 10:14PM UTC 265
76.58
GitHub Action Run
2 cbf-os-ubuntu-latest-ubuntu-latest-php-7.2-custom-ini-false - 15719074832.2 17 Jun 2025 10:16PM UTC 265
1.31
GitHub Action Run
3 cbf-os-ubuntu-latest-ubuntu-latest-php-8.4-custom-ini-true - 15719074832.3 17 Jun 2025 10:14PM UTC 265
2.34
GitHub Action Run
4 os-ubuntu-latest-php-7.2-custom-ini-false - 15719074832.4 17 Jun 2025 10:16PM UTC 265
75.69
GitHub Action Run
5 os-windows-latest-php-8.4-custom-ini-false - 15719074832.5 17 Jun 2025 10:11PM UTC 265
2.71
GitHub Action Run
6 os-ubuntu-latest-php-8.4-custom-ini-true - 15719074832.6 17 Jun 2025 10:14PM UTC 265
76.48
GitHub Action Run
7 os-windows-latest-php-7.2-custom-ini-false - 15719074832.7 17 Jun 2025 10:11PM UTC 265
2.15
GitHub Action Run
8 cbf-os-ubuntu-latest-ubuntu-latest-php-8.4-custom-ini-false - 15719074832.8 17 Jun 2025 10:14PM UTC 265
2.34
GitHub Action Run
Source Files on build 15719074832
  • Tree
  • List 265
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #15719074832
  • e1b95951 on github
  • Prev Build on 4.x (#15718119659)
  • Next Build on 4.x (#15719505208)
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