Skip to content

Commit 3b74a35

Browse files
committed
fixup! Replace error-prone instanceof in Rules classes
1 parent e632c31 commit 3b74a35

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Diff for: src/Rules/MissingTypehintCheck.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getNonGenericObjectTypesWithGenericClass(Type $type): array
108108
if ($type instanceof TemplateType) {
109109
return $type;
110110
}
111-
if (count($type->getObjectClassNames()) > 0) {
111+
if ($type->isObject()->yes()) {
112112
if (count($type->getObjectClassReflections()) === 0) {
113113
return $type;
114114
}
@@ -128,7 +128,7 @@ public function getNonGenericObjectTypesWithGenericClass(Type $type): array
128128
}
129129

130130
$resolvedType = TemplateTypeHelper::resolveToBounds($type);
131-
if (count($resolvedType->getObjectClassNames()) === 0) {
131+
if (!$resolvedType->isObject()->yes()) {
132132
throw new ShouldNotHappenException();
133133
}
134134

Diff for: src/Rules/UnusedFunctionParametersCheck.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ private function getUsedVariables(Scope $scope, $node): array
9292
) {
9393
foreach ($node->getArgs() as $arg) {
9494
$argType = $scope->getType($arg->value);
95-
if (count($argType->getConstantStrings()) === 1) {
96-
$constantStringType = $argType->getConstantStrings()[0];
95+
foreach ($argType->getConstantStrings() as $constantStringType) {
9796
$variableNames[] = $constantStringType->getValue();
9897
}
9998
}

0 commit comments

Comments
 (0)