Skip to content

Commit

Permalink
PHP 8.1: fix deprecation notice
Browse files Browse the repository at this point in the history
The `Util\Standards::getInstalledStandardPath()` method returns either a string or `null`, however the `strpos()` method which is used in both the `Util\Common::isPharFile()` method, as well as in the follow-on condition, only accepts a `string` as `$haystack`.

As of PHP 8.1, this will generate a deprecation notice `strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated`.

Discovered while testing an external standard against PHPCS `master` on PHP 8.1.

Fixed now.
  • Loading branch information
jrfnl committed Feb 28, 2021
1 parent 1106d65 commit a330bf2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ private function expandRulesetReference($ref, $rulesetDir, $depth=0)
} else {
// See if this is a whole standard being referenced.
$path = Util\Standards::getInstalledStandardPath($ref);
if (Util\Common::isPharFile($path) === true && strpos($path, 'ruleset.xml') === false) {
if ($path !== null && Util\Common::isPharFile($path) === true && strpos($path, 'ruleset.xml') === false) {
// If the ruleset exists inside the phar file, use it.
if (file_exists($path.DIRECTORY_SEPARATOR.'ruleset.xml') === true) {
$path .= DIRECTORY_SEPARATOR.'ruleset.xml';
Expand Down

0 comments on commit a330bf2

Please sign in to comment.