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

PHPCSStandards / PHP_CodeSniffer / 13902348003
79%

Build:
DEFAULT BRANCH: master
Ran 17 Mar 2025 02:47PM UTC
Jobs 8
Files 310
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 Mar 2025 02:44PM UTC coverage: 78.707% (+0.008%) from 78.699%
13902348003

push

github

jrfnl
Ruleset: handle invalid sniffs more graciously

As things were, a ruleset loading an invalid sniff - a sniff which doesn't implement the `Sniff` interface and is missing either the `register()` or `process()` method, or both -, would result in fatal errors which are unfriendly to the end-user.

Now, while this will hopefully be a very rare occurrence and should no longer be possible as of PHPCS 4.0, which intends to remove support for sniffs not implementing the `Sniff` interface, I still believe it prudent to show more user-friendly and more informative error messages to the end-user until that time.

This commit implements this and executes step 2 to address issue 694..

Includes tests.

Output of commands involving various invalid sniffs **before** this PR:

```
$ phpcs -ps . --standard=./tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterTest.xml

Fatal error: Uncaught Error: Call to undefined method TestStandard\Sniffs\InvalidSniffError\NoImplementsNoRegisterSniff::register() in path/to/PHP_CodeSniffer/src/Ruleset.php:1505
Stack trace:
  thrown in path/to/PHP_CodeSniffer/src/Ruleset.php on line 1505
```

```
$ phpcs -ps . --standard=./tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoProcessTest.xml

PHP_CodeSniffer version 3.11.1 (stable) by Squiz and PHPCSStandards

Fatal error: Uncaught Error: Call to undefined method TestStandard\Sniffs\InvalidSniffError\NoImplementsNoProcessSniff::process() in path/to/PHP_CodeSniffer/src/Files/File.php:519
Stack trace:
  thrown in path/to/PHP_CodeSniffer/src/Files/File.php on line 519
```

```
$ phpcs -ps . --standard=./tests/Core/Ruleset/RegisterSniffsRejectsInvalidSniffNoImplementsNoRegisterOrProcessTest.xml

PHP_CodeSniffer version 3.11.1 (stable) by Squiz and PHPCSStandards

Fatal error: Uncaught Error: Call to undefined method TestStandard\Sniffs\InvalidSniffError\NoImplementsNoRegisterOrProcessSniff::register() in path/to/PHP_CodeSniffer/src/Ruleset.php:1505
Stack... (continued)

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

24844 of 31565 relevant lines covered (78.71%)

66.34 hits per line

Jobs
ID Job ID Ran Files Coverage
1 os-ubuntu-latest-php-5.4-custom-ini-false - 13902348003.1 17 Mar 2025 03:14PM UTC 310
72.69
GitHub Action Run
2 os-windows-latest-php-5.5-custom-ini-false - 13902348003.2 17 Mar 2025 02:47PM UTC 310
2.19
GitHub Action Run
3 cbf-os-ubuntu-latest-ubuntu-latest-php-7.2-custom-ini-true - 13902348003.3 17 Mar 2025 02:51PM UTC 310
0.73
GitHub Action Run
4 cbf-os-ubuntu-latest-ubuntu-latest-php-5.4-custom-ini-false - 13902348003.4 17 Mar 2025 03:14PM UTC 310
1.28
GitHub Action Run
5 cbf-os-ubuntu-latest-ubuntu-latest-php-8.4-custom-ini-false - 13902348003.5 17 Mar 2025 02:49PM UTC 310
1.7
GitHub Action Run
6 os-ubuntu-latest-php-7.2-custom-ini-true - 13902348003.6 17 Mar 2025 02:51PM UTC 310
71.64
GitHub Action Run
7 os-windows-latest-php-8.4-custom-ini-false - 13902348003.7 17 Mar 2025 02:47PM UTC 310
2.49
GitHub Action Run
8 os-ubuntu-latest-php-8.4-custom-ini-false - 13902348003.8 17 Mar 2025 02:49PM UTC 310
74.18
GitHub Action Run
Source Files on build 13902348003
  • 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 #13902348003
  • 97e340e3 on github
  • Prev Build on master (#13902226210)
  • Next Build on master (#13906362805)
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