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

PHPCSStandards / PHP_CodeSniffer / 14424850286
78%
master: 79%

Build:
Build:
LAST BUILD BRANCH: 4.x
DEFAULT BRANCH: master
Ran 13 Apr 2025 01:31AM UTC
Jobs 8
Files 263
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

13 Apr 2025 01:29AM UTC coverage: 77.557% (-0.003%) from 77.56%
14424850286

push

github

jrfnl
Report/Code: fix fatal potential fatal error when combined with Diff report

Okay, so this is an awkward one.

If both the `Code` + the `Diff` report were requested + caching was turned on + the _order_ of the requested reports was `Code,Diff` (i.e. first the code report), the following fatal error which would occur:
```
Fatal error: Uncaught Error: Call to a member function getFixableCount() on null in path/to/PHP_CodeSniffer/src/Fixer.php:144
Stack trace:
#0 path/to/PHP_CodeSniffer/src/Reports/Diff.php(73): PHP_CodeSniffer\Fixer->fixFile()
#1 path/to/PHP_CodeSniffer/src/Reporter.php(285): PHP_CodeSniffer\Reports\Diff->generateFileReport(Array, Object(PHP_CodeSniffer\Files\LocalFile), true, 150)
#2 path/to/PHP_CodeSniffer/src/Runner.php(659): PHP_CodeSniffer\Reporter->cacheFileReport(Object(PHP_CodeSniffer\Files\LocalFile))
#3 path/to/PHP_CodeSniffer/src/Runner.php(400): PHP_CodeSniffer\Runner->processFile(Object(PHP_CodeSniffer\Files\LocalFile))
#4 path/to/PHP_CodeSniffer/src/Runner.php(119): PHP_CodeSniffer\Runner->run()
#5 path/to/PHP_CodeSniffer/bin/phpcs(30): PHP_CodeSniffer\Runner->runPHPCS()
#6 {main}
  thrown in path/to/PHP_CodeSniffer/src/Fixer.php on line 144
```

To reproduce the issue (on `master`):
1. Create a small test file like:
    ```php
    <?php

    echo 'hello'.callMe( $p );
    ```
2. Run the following command to initialize the cache:
    ```bash
    phpcs -ps ./test.php --standard=PSR2 --report=Code,Diff --cache
    ```
    All should be fine.
3. Now run the same command again and see the fatal error.

Some investigating later, it turns out that both the `Code` report, as well as the `Diff` report, re-parse the current file, with the `Diff` report initializing the fixer once the file has reparsed, but the `Code` report not doing so (as it doesn't need the fixer).
The problem with that is that the `Code` report basically leaves the `Fixer` in an invalid state, leading to the above error.

While it is up for debate whether repor... (continued)

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

1 existing line in 1 file now uncovered.

19345 of 24943 relevant lines covered (77.56%)

78.9 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
0.0
0.0% src/Reports/Code.php

Uncovered Existing Lines

Lines Coverage ∆ File
1
0.0
0.0% src/Reports/Code.php
Jobs
ID Job ID Ran Files Coverage
1 cbf-os-ubuntu-latest-ubuntu-latest-php-8.1-custom-ini-true - 14424850286.1 13 Apr 2025 01:35AM UTC 263
1.89
GitHub Action Run
2 cbf-os-ubuntu-latest-ubuntu-latest-php-8.4-custom-ini-false - 14424850286.2 13 Apr 2025 01:35AM UTC 263
1.88
GitHub Action Run
3 os-ubuntu-latest-php-8.4-custom-ini-false - 14424850286.3 13 Apr 2025 01:35AM UTC 263
76.04
GitHub Action Run
4 os-windows-latest-php-8.4-custom-ini-false - 14424850286.4 13 Apr 2025 01:31AM UTC 263
2.64
GitHub Action Run
5 cbf-os-ubuntu-latest-ubuntu-latest-php-7.2-custom-ini-false - 14424850286.5 13 Apr 2025 01:36AM UTC 263
0.81
GitHub Action Run
6 os-windows-latest-php-7.2-custom-ini-false - 14424850286.6 13 Apr 2025 01:31AM UTC 263
2.1
GitHub Action Run
7 os-ubuntu-latest-php-8.1-custom-ini-true - 14424850286.7 13 Apr 2025 01:35AM UTC 263
76.06
GitHub Action Run
8 os-ubuntu-latest-php-7.2-custom-ini-false - 14424850286.8 13 Apr 2025 01:36AM UTC 263
73.9
GitHub Action Run
Source Files on build 14424850286
  • Tree
  • List 263
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #14424850286
  • fc859064 on github
  • Prev Build on 4.0 (#14424835604)
  • Next Build on 4.0 (#14424855168)
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