Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Rules/Api/NodeConnectingVisitorAttributesRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@
if ($node->name->toLowerString() !== 'getattribute') {
return [];
}
$calledOnType = $scope->getType($node->var);
if (!(new ObjectType(Node::class))->isSuperTypeOf($calledOnType)->yes()) {
return [];
}

$args = $node->getArgs();
if (!isset($args[0])) {
return [];
}

$calledOnType = $scope->getType($node->var);
if (!(new ObjectType(Node::class))->isSuperTypeOf($calledOnType)->yes()) {

Check warning on line 44 in src/Rules/Api/NodeConnectingVisitorAttributesRule.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ } $calledOnType = $scope->getType($node->var); - if (!(new ObjectType(Node::class))->isSuperTypeOf($calledOnType)->yes()) { + if ((new ObjectType(Node::class))->isSuperTypeOf($calledOnType)->no()) { return []; }

Check warning on line 44 in src/Rules/Api/NodeConnectingVisitorAttributesRule.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\IsSuperTypeOfCalleeAndArgumentMutator": @@ @@ } $calledOnType = $scope->getType($node->var); - if (!(new ObjectType(Node::class))->isSuperTypeOf($calledOnType)->yes()) { + if (!$calledOnType->isSuperTypeOf(new ObjectType(Node::class))->yes()) { return []; }

Check warning on line 44 in src/Rules/Api/NodeConnectingVisitorAttributesRule.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ } $calledOnType = $scope->getType($node->var); - if (!(new ObjectType(Node::class))->isSuperTypeOf($calledOnType)->yes()) { + if ((new ObjectType(Node::class))->isSuperTypeOf($calledOnType)->no()) { return []; }
return [];
}

$messages = [];
$argType = $scope->getType($args[0]->value);
foreach ($argType->getConstantStrings() as $constantString) {
Expand Down
8 changes: 4 additions & 4 deletions src/Rules/Api/OldPhpParser4ClassRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public function getNodeType(): string

public function processNode(Node $node, Scope $scope): array
{
if (!$scope->isInClass()) {
return [];
}

$nameMapping = array_change_key_case(self::NAME_MAPPING);
$lowerName = $node->toLowerString();
if (!array_key_exists($lowerName, $nameMapping)) {
Expand All @@ -50,10 +54,6 @@ public function processNode(Node $node, Scope $scope): array

$newName = $nameMapping[$lowerName];

if (!$scope->isInClass()) {
return [];
}

$classReflection = $scope->getClassReflection();
$hasPhpStanInterface = false;
foreach (array_keys($classReflection->getInterfaces()) as $interfaceName) {
Expand Down
8 changes: 4 additions & 4 deletions src/Rules/Api/RuntimeReflectionFunctionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

if (!$scope->isInClass()) {
return [];
}

if (!$this->reflectionProvider->hasFunction($node->name, $scope)) {
return [];
}
Expand All @@ -50,10 +54,6 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

if (!$scope->isInClass()) {
return [];
}

$classReflection = $scope->getClassReflection();
$hasPhpStanInterface = false;
foreach (array_keys($classReflection->getInterfaces()) as $interfaceName) {
Expand Down
8 changes: 4 additions & 4 deletions src/Rules/Api/RuntimeReflectionInstantiationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

if (!$scope->isInClass()) {
return [];
}

$className = $scope->resolveName($node->class);
if (!$this->reflectionProvider->hasClass($className)) {
return [];
Expand All @@ -69,10 +73,6 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

if (!$scope->isInClass()) {
return [];
}

$scopeClassReflection = $scope->getClassReflection();
$hasPhpStanInterface = false;
foreach (array_keys($scopeClassReflection->getInterfaces()) as $interfaceName) {
Expand Down
Loading