diff --git a/src/Rules/Debug/DumpNativeTypeRule.php b/src/Rules/Debug/DumpNativeTypeRule.php index cfb084c4e3..b71c550578 100644 --- a/src/Rules/Debug/DumpNativeTypeRule.php +++ b/src/Rules/Debug/DumpNativeTypeRule.php @@ -35,16 +35,16 @@ public function processNode(Node $node, Scope $scope): array return []; } - $functionName = $this->reflectionProvider->resolveFunctionName($node->name, $scope); - if ($functionName === null) { + if (count($node->getArgs()) === 0) { return []; } - if (strtolower($functionName) !== 'phpstan\dumpnativetype') { + $functionName = $this->reflectionProvider->resolveFunctionName($node->name, $scope); + if ($functionName === null) { return []; } - if (count($node->getArgs()) === 0) { + if (strtolower($functionName) !== 'phpstan\dumpnativetype') { return []; } diff --git a/src/Rules/Debug/DumpPhpDocTypeRule.php b/src/Rules/Debug/DumpPhpDocTypeRule.php index 1180469b0d..e91817d887 100644 --- a/src/Rules/Debug/DumpPhpDocTypeRule.php +++ b/src/Rules/Debug/DumpPhpDocTypeRule.php @@ -35,16 +35,16 @@ public function processNode(Node $node, Scope $scope): array return []; } - $functionName = $this->reflectionProvider->resolveFunctionName($node->name, $scope); - if ($functionName === null) { + if (count($node->getArgs()) === 0) { return []; } - if (strtolower($functionName) !== 'phpstan\dumpphpdoctype') { + $functionName = $this->reflectionProvider->resolveFunctionName($node->name, $scope); + if ($functionName === null) { return []; } - if (count($node->getArgs()) === 0) { + if (strtolower($functionName) !== 'phpstan\dumpphpdoctype') { return []; } diff --git a/src/Rules/Debug/DumpTypeRule.php b/src/Rules/Debug/DumpTypeRule.php index 5a628a95f5..edbf5cb1ce 100644 --- a/src/Rules/Debug/DumpTypeRule.php +++ b/src/Rules/Debug/DumpTypeRule.php @@ -35,16 +35,16 @@ public function processNode(Node $node, Scope $scope): array return []; } - $functionName = $this->reflectionProvider->resolveFunctionName($node->name, $scope); - if ($functionName === null) { + if (count($node->getArgs()) === 0) { return []; } - if (strtolower($functionName) !== 'phpstan\dumptype') { + $functionName = $this->reflectionProvider->resolveFunctionName($node->name, $scope); + if ($functionName === null) { return []; } - if (count($node->getArgs()) === 0) { + if (strtolower($functionName) !== 'phpstan\dumptype') { return []; } diff --git a/src/Rules/Debug/FileAssertRule.php b/src/Rules/Debug/FileAssertRule.php index bf5af7456d..b422395527 100644 --- a/src/Rules/Debug/FileAssertRule.php +++ b/src/Rules/Debug/FileAssertRule.php @@ -42,6 +42,10 @@ public function processNode(Node $node, Scope $scope): array return []; } + if (count($node->getArgs()) !== 2) { + return []; + } + if (!$this->reflectionProvider->hasFunction($node->name, $scope)) { return []; } @@ -67,15 +71,11 @@ public function processNode(Node $node, Scope $scope): array } /** - * @param Node\Arg[] $args + * @param array{Node\Arg, Node\Arg} $args * @return list */ private function processAssertType(array $args, Scope $scope): array { - if (count($args) !== 2) { - return []; - } - $expectedTypeStrings = $scope->getType($args[0]->value)->getConstantStrings(); if (count($expectedTypeStrings) !== 1) { return [ @@ -100,15 +100,11 @@ private function processAssertType(array $args, Scope $scope): array } /** - * @param Node\Arg[] $args + * @param array{Node\Arg, Node\Arg} $args * @return list */ private function processAssertNativeType(array $args, Scope $scope): array { - if (count($args) !== 2) { - return []; - } - $expectedTypeStrings = $scope->getNativeType($args[0]->value)->getConstantStrings(); if (count($expectedTypeStrings) !== 1) { return [ @@ -133,15 +129,11 @@ private function processAssertNativeType(array $args, Scope $scope): array } /** - * @param Node\Arg[] $args + * @param array{Node\Arg, Node\Arg} $args * @return list */ private function processAssertSuperType(array $args, Scope $scope): array { - if (count($args) !== 2) { - return []; - } - $expectedTypeStrings = $scope->getType($args[0]->value)->getConstantStrings(); if (count($expectedTypeStrings) !== 1) { return [ @@ -167,15 +159,11 @@ private function processAssertSuperType(array $args, Scope $scope): array } /** - * @param Node\Arg[] $args + * @param array{Node\Arg, Node\Arg} $args * @return list */ private function processAssertVariableCertainty(array $args, Scope $scope): array { - if (count($args) !== 2) { - return []; - } - $certainty = $args[0]->value; if (!$certainty instanceof StaticCall) { return [