Skip to content

Commit 9dbc6a6

Browse files
authored
[CLEANUP] Avoid negated non-Boolean in RuleSet (#1246)
Use `=== null` instead to be more precise.
1 parent a9874a9 commit 9dbc6a6

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

config/phpstan-baseline.neon

-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ parameters:
5454
count: 1
5555
path: ../src/RuleSet/DeclarationBlock.php
5656

57-
-
58-
message: '#^Only booleans are allowed in a negated boolean, string\|null given\.$#'
59-
identifier: booleanNot.exprNotBoolean
60-
count: 2
61-
path: ../src/RuleSet/RuleSet.php
62-
6357
-
6458
message: '#^Parameters should have "string" types as the only types passed to this method$#'
6559
identifier: typePerfect.narrowPublicClassMethodParamType

src/RuleSet/RuleSet.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function getRules($searchPattern = null): array
149149
// Either no search rule is given or the search rule matches the found rule exactly
150150
// or the search rule ends in “-” and the found rule starts with the search rule.
151151
if (
152-
!$searchPattern || $propertyName === $searchPattern
152+
$searchPattern === null || $propertyName === $searchPattern
153153
|| (
154154
\strrpos($searchPattern, '-') === \strlen($searchPattern) - \strlen('-')
155155
&& (\strpos($propertyName, $searchPattern) === 0
@@ -240,7 +240,7 @@ public function removeRule($searchPattern): void
240240
// or the search rule ends in “-” and the found rule starts with the search rule or equals it
241241
// (without the trailing dash).
242242
if (
243-
!$searchPattern || $propertyName === $searchPattern
243+
$searchPattern === null || $propertyName === $searchPattern
244244
|| (\strrpos($searchPattern, '-') === \strlen($searchPattern) - \strlen('-')
245245
&& (\strpos($propertyName, $searchPattern) === 0
246246
|| $propertyName === \substr($searchPattern, 0, -1)))

0 commit comments

Comments
 (0)