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

PHPCSStandards / PHP_CodeSniffer / 14730902924 / 2
79%
master: 79%

Build:
DEFAULT BRANCH: master
Ran 29 Apr 2025 12:40PM UTC
Files 310
Run time 11s
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: 71.228% (+0.09%) from 71.142%
14730902924.2

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)

19909 of 27951 relevant lines covered (71.23%)

23.84 hits per line

Source Files on job os-ubuntu-latest-php-7.2-custom-ini-true - 14730902924.2
  • Tree
  • List 310
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 14730902924
  • e4c1f2f2 on github
  • Prev Job for on master (#14698176721.2)
  • Next Job for on master (#14736080624.6)
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