Completed
Push — master ( ae11cf...8eec5e )
by Dave
16s queued 12s
created

setTypeSpecifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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;
0 ignored issues
show
Bug introduced by
The type PHPStan\Analyser\Scope was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use PHPStan\Analyser\SpecifiedTypes;
0 ignored issues
show
Bug introduced by
The type PHPStan\Analyser\SpecifiedTypes was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use PHPStan\Analyser\TypeSpecifier;
0 ignored issues
show
Bug introduced by
The type PHPStan\Analyser\TypeSpecifier was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use PHPStan\Analyser\TypeSpecifierAwareExtension;
0 ignored issues
show
Bug introduced by
The type PHPStan\Analyser\TypeSpecifierAwareExtension was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use PHPStan\Analyser\TypeSpecifierContext;
0 ignored issues
show
Bug introduced by
The type PHPStan\Analyser\TypeSpecifierContext was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use PHPStan\Reflection\MethodReflection;
0 ignored issues
show
Bug introduced by
The type PHPStan\Reflection\MethodReflection was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use PHPStan\Type\ArrayType;
0 ignored issues
show
Bug introduced by
The type PHPStan\Type\ArrayType was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use PHPStan\Type\MixedType;
0 ignored issues
show
Bug introduced by
The type PHPStan\Type\MixedType was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use PHPStan\Type\StaticMethodTypeSpecifyingExtension;
0 ignored issues
show
Bug introduced by
The type PHPStan\Type\StaticMethodTypeSpecifyingExtension was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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,
0 ignored issues
show
Bug introduced by
The property value does not seem to exist on PhpParser\Node\VariadicPlaceholder.
Loading history...
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