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

PHPCSStandards / PHP_CodeSniffer / 14730902924
79%

Build:
DEFAULT BRANCH: master
Ran 29 Apr 2025 12:13PM UTC
Jobs 8
Files 310
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

29 Apr 2025 12:11PM UTC coverage: 78.321% (+0.08%) from 78.245%
14730902924

push

github

web-flow
Fixer::fixFile(): bug fix for incorrect return value (#1048)

Over the years, I'd noticed on numerous occasions that `phpcbf` could update the file under scan, even when the end-result of the run was a "FAILED TO FIX".
In my opinion, if the fixer didn't manage to fix the file completely, the file should not be updated as the end-result may be worse than before.

The trouble was that this didn't _always_ happen, but only some of the time, so this needed some debugging to figure out under what exact conditions the file write would happen (and when it wouldn't happen).

To demonstrate the issue, run the following commands with the branch for this PR checked out and the change in the `Fixer` file reverted:
```bash
phpcbf --suffix=.fixed ./tests/Core/Fixer/Fixtures/test.inc --standard=./tests/Core/Fixer/FixFileReturnValueNotEnoughLoopsTest.xml
```
Now check the `./tests/Core/Fixer/Fixtures/` directory and take note that there is no `test.inc.fixed` file present.
Next, run:
```bash
phpcbf --suffix=.fixed ./tests/Core/Fixer/Fixtures/test.inc --standard=./tests/Core/Fixer/FixFileReturnValueConflictTest.xml
```
Now check the `./tests/Core/Fixer/Fixtures/` directory again and see that the `test.inc.fixed` file has been created.

If you run these commands with `-vv` you can see what is happening in the fixer, including seeing a _"=> Fixed file written to test.inc.fixed"_ debug notice at the end of the debug output for the second command, but not seeing it for the first command.

_(you can now delete the `test.inc.fixed` file)_

Turns out that if the last loop of the Fixer didn't make any fixes, the `Fixer::fixFile()` method always returned `true` (= everything fixed), even when there were no fixes made _due to the fixer having discarded the fixes as it detected a fixer conflict..._.
This, in turn, would then cause the `CBF` report, which triggers the fixer and checks the return value of the `fixFile()` method, to do a file write with the "fixed" content of the f... (continued)

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

25065 of 32003 relevant lines covered (78.32%)

67.37 hits per line

Jobs
ID Job ID Ran Files Coverage
1 os-ubuntu-latest-php-5.4-custom-ini-false - 14730902924.1 29 Apr 2025 12:40PM UTC 310
72.39
GitHub Action Run
2 os-ubuntu-latest-php-7.2-custom-ini-true - 14730902924.2 29 Apr 2025 12:18PM UTC 310
71.23
GitHub Action Run
3 cbf-os-ubuntu-latest-ubuntu-latest-php-5.4-custom-ini-false - 14730902924.3 29 Apr 2025 12:40PM UTC 310
1.37
GitHub Action Run
4 os-windows-latest-php-5.5-custom-ini-false - 14730902924.4 29 Apr 2025 12:14PM UTC 310
2.2
GitHub Action Run
5 cbf-os-ubuntu-latest-ubuntu-latest-php-7.2-custom-ini-true - 14730902924.5 29 Apr 2025 12:18PM UTC 310
0.83
GitHub Action Run
6 cbf-os-ubuntu-latest-ubuntu-latest-php-8.4-custom-ini-false - 14730902924.6 29 Apr 2025 12:16PM UTC 310
1.77
GitHub Action Run
7 os-ubuntu-latest-php-8.4-custom-ini-false - 14730902924.7 29 Apr 2025 12:16PM UTC 310
73.71
GitHub Action Run
8 os-windows-latest-php-8.4-custom-ini-false - 14730902924.8 29 Apr 2025 12:13PM UTC 310
2.51
GitHub Action Run
Source Files on build 14730902924
  • Tree
  • List 310
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #14730902924
  • e4c1f2f2 on github
  • Prev Build on master (#14698176721)
  • Next Build on master (#14736080624)
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