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

PHPCSStandards / PHP_CodeSniffer / 13902348003 / 5
79%
master: 79%

Build:
DEFAULT BRANCH: master
Ran 17 Mar 2025 03:15PM UTC
Files 310
Run time 23s
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: 1.697%. Remained the same
13902348003.5

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)

469 of 27645 relevant lines covered (1.7%)

0.03 hits per line

Source Files on job cbf-os-ubuntu-latest-ubuntu-latest-php-8.4-custom-ini-false - 13902348003.5
  • Tree
  • List 310
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 13902348003
  • 97e340e3 on github
  • Prev Job for on master (#13902226210.3)
  • Next Job for on master (#13906362805.5)
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