Skip to content

Commit ea26fc2

Browse files
committed
PHPStan: Improve code coverage
1 parent 6cb3702 commit ea26fc2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/Toolkit/PHPStan/Core/Rules/TypesAssignedByHasMutatorRule.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,28 @@ public function processNode(Node $node, Scope $scope): array
2929
/** @var MethodCall $node */
3030
$methodName = $node->name;
3131
if (!$methodName instanceof Identifier) {
32+
// @codeCoverageIgnoreStart
3233
return [];
34+
// @codeCoverageIgnoreEnd
3335
}
3436
$calledOnType = $scope->getType($node->var);
3537
$methodReflection = $scope->getMethodReflection($calledOnType, $methodName->toString());
3638
if (!$methodReflection) {
39+
// @codeCoverageIgnoreStart
3740
return [];
41+
// @codeCoverageIgnoreEnd
3842
}
3943
$prototypeReflection = $methodReflection->getPrototype();
4044
if (!$prototypeReflection instanceof PhpMethodReflection) {
45+
// @codeCoverageIgnoreStart
4146
return [];
47+
// @codeCoverageIgnoreEnd
4248
}
4349
$traitReflection = $prototypeReflection->getDeclaringTrait();
4450
if (!$traitReflection || $traitReflection->getName() !== HasMutator::class) {
51+
// @codeCoverageIgnoreStart
4552
return [];
53+
// @codeCoverageIgnoreEnd
4654
}
4755
$classReflection = $prototypeReflection->getDeclaringClass();
4856
$aliases = array_change_key_case($classReflection->getNativeReflection()->getTraitAliases());
@@ -51,18 +59,24 @@ public function processNode(Node $node, Scope $scope): array
5159
$name = explode('::', $aliases[$name])[1];
5260
}
5361
if ($name !== 'with' && $name !== 'without') {
62+
// @codeCoverageIgnoreStart
5463
return [];
64+
// @codeCoverageIgnoreEnd
5565
}
5666
$args = $node->getArgs();
5767
if (!$args) {
68+
// @codeCoverageIgnoreStart
5869
return [];
70+
// @codeCoverageIgnoreEnd
5971
}
6072
$propertyName = $scope->getType($args[0]->value);
6173
if (
6274
!$propertyName->isConstantScalarValue()->yes()
6375
|| !$propertyName->isString()->yes()
6476
) {
77+
// @codeCoverageIgnoreStart
6578
return [];
79+
// @codeCoverageIgnoreEnd
6680
}
6781
/** @var string */
6882
$propertyName = $propertyName->getConstantScalarValues()[0];

src/Toolkit/PHPStan/Utility/Type/ArrFlattenReturnTypeExtension.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ public function getTypeFromStaticMethodCall(
5252
return null;
5353
}
5454
$values = $type->getConstantScalarValues();
55-
if (count($values) !== 1) {
56-
return null;
57-
}
5855
/** @var int */
5956
$limit = $values[0];
6057
}

0 commit comments

Comments
 (0)