Skip to content

Commit a330bf2

Browse files
committed
PHP 8.1: fix deprecation notice
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.
1 parent 1106d65 commit a330bf2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Ruleset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ private function expandRulesetReference($ref, $rulesetDir, $depth=0)
726726
} else {
727727
// See if this is a whole standard being referenced.
728728
$path = Util\Standards::getInstalledStandardPath($ref);
729-
if (Util\Common::isPharFile($path) === true && strpos($path, 'ruleset.xml') === false) {
729+
if ($path !== null && Util\Common::isPharFile($path) === true && strpos($path, 'ruleset.xml') === false) {
730730
// If the ruleset exists inside the phar file, use it.
731731
if (file_exists($path.DIRECTORY_SEPARATOR.'ruleset.xml') === true) {
732732
$path .= DIRECTORY_SEPARATOR.'ruleset.xml';

0 commit comments

Comments
 (0)