1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Tools\Phpstan; |
6
|
|
|
|
7
|
|
|
use DaveLiddament\StaticAnalysisResultsBaseliner\Domain\Utils\ArrayUtils; |
8
|
|
|
use PhpParser\Node\Expr\StaticCall; |
9
|
|
|
use PHPStan\Analyser\Scope; |
|
|
|
|
10
|
|
|
use PHPStan\Analyser\SpecifiedTypes; |
|
|
|
|
11
|
|
|
use PHPStan\Analyser\TypeSpecifier; |
|
|
|
|
12
|
|
|
use PHPStan\Analyser\TypeSpecifierAwareExtension; |
|
|
|
|
13
|
|
|
use PHPStan\Analyser\TypeSpecifierContext; |
|
|
|
|
14
|
|
|
use PHPStan\Reflection\MethodReflection; |
|
|
|
|
15
|
|
|
use PHPStan\Type\ArrayType; |
|
|
|
|
16
|
|
|
use PHPStan\Type\MixedType; |
|
|
|
|
17
|
|
|
use PHPStan\Type\StaticMethodTypeSpecifyingExtension; |
|
|
|
|
18
|
|
|
|
19
|
|
|
class ArrayUtilsTypeSpecifyingExtension implements StaticMethodTypeSpecifyingExtension, TypeSpecifierAwareExtension |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var TypeSpecifier |
23
|
|
|
*/ |
24
|
|
|
private $typeSpecifier; |
25
|
|
|
|
26
|
|
|
public function getClass(): string |
27
|
|
|
{ |
28
|
|
|
return ArrayUtils::class; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function isStaticMethodSupported( |
32
|
|
|
MethodReflection $staticMethodReflection, |
33
|
|
|
StaticCall $node, |
34
|
|
|
TypeSpecifierContext $context |
35
|
|
|
): bool { |
36
|
|
|
return 'assertArray' === $staticMethodReflection->getName() |
37
|
|
|
&& isset($node->getArgs()[0]) |
38
|
|
|
&& $context->null(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function specifyTypes( |
42
|
|
|
MethodReflection $staticMethodReflection, |
43
|
|
|
StaticCall $node, |
44
|
|
|
Scope $scope, |
45
|
|
|
TypeSpecifierContext $context |
46
|
|
|
): SpecifiedTypes { |
47
|
|
|
return $this->typeSpecifier->create( |
48
|
|
|
$node->getArgs()[0]->value, |
|
|
|
|
49
|
|
|
new ArrayType(new MixedType(), new MixedType()), |
50
|
|
|
TypeSpecifierContext::createTruthy(), |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void |
55
|
|
|
{ |
56
|
|
|
$this->typeSpecifier = $typeSpecifier; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths