GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 4.2-to-master ( ed215f )
by E
06:47
created

AbstractReflection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace ApiGen\Parser\Reflection;
4
5
use ApiGen\Contracts\Configuration\ConfigurationInterface;
6
use ApiGen\Contracts\Parser\Elements\ElementsInterface;
7
use ApiGen\Contracts\Parser\ParserStorageInterface;
8
use ApiGen\Contracts\Parser\Reflection\ClassReflectionInterface;
9
use ApiGen\Contracts\Parser\Reflection\TokenReflection\ReflectionFactoryInterface;
10
use ApiGen\Parser\Reflection\TokenReflection\ReflectionInterface;
11
use Nette\Object;
12
use TokenReflection\IReflection;
13
use TokenReflection\IReflectionClass;
14
use TokenReflection\IReflectionFunction;
15
use TokenReflection\IReflectionMethod;
16
use TokenReflection\IReflectionParameter;
17
use TokenReflection\IReflectionProperty;
18
19
abstract class AbstractReflection extends Object implements ReflectionInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $reflectionType;
25
26
    /**
27
     * @var IReflectionClass|IReflectionFunction|IReflectionMethod|IReflectionParameter|IReflectionProperty
28
     */
29
    protected $reflection;
30
31
    /**
32
     * @var ConfigurationInterface
33
     */
34
    protected $configuration;
35
36
    /**
37
     * @var ParserStorageInterface
38
     */
39
    protected $parserStorage;
40
41
    /**
42
     * @var ReflectionFactoryInterface
43
     */
44
    protected $reflectionFactory;
45
46
    public function __construct(IReflection $reflection)
47
    {
48
        $this->reflectionType = get_class($this);
49
        $this->reflection = $reflection;
0 ignored issues
show
Documentation Bug introduced by
It seems like $reflection of type object<TokenReflection\IReflection> is incompatible with the declared type object<TokenReflection\I...on\IReflectionProperty> of property $reflection.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
50
    }
51
52
    public function getName(): string
53
    {
54
        return $this->reflection->getName();
55
    }
56
57
    public function getPrettyName(): string
58
    {
59
        return $this->reflection->getPrettyName();
60
    }
61
62
    public function isInternal(): bool
63
    {
64
        return $this->reflection->isInternal();
65
    }
66
67
    public function isTokenized(): bool
68
    {
69
        return $this->reflection->isTokenized();
70
    }
71
72
    public function getFileName(): string
73
    {
74
        return $this->reflection->getFileName();
75
    }
76
77
    public function getStartLine(): int
78
    {
79
        $startLine = $this->reflection->getStartLine();
80
        $doc = $this->getDocComment();
0 ignored issues
show
Documentation Bug introduced by
The method getDocComment does not exist on object<ApiGen\Parser\Ref...ion\AbstractReflection>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
81
82
        if ($doc) {
83
            $startLine -= substr_count($doc, "\n") + 1;
84
        }
85
86
        return $startLine;
87
    }
88
89
    public function getEndLine(): int
90
    {
91
        return $this->reflection->getEndLine();
92
    }
93
94
    public function setConfiguration(ConfigurationInterface $configuration): void
95
    {
96
        $this->configuration = $configuration;
97
    }
98
99
    public function setParserStorage(ParserStorageInterface $parserStorage): void
100
    {
101
        $this->parserStorage = $parserStorage;
102
    }
103
104
    public function setReflectionFactory(ReflectionFactoryInterface $reflectionFactory): void
105
    {
106
        $this->reflectionFactory = $reflectionFactory;
107
    }
108
109
    /**
110
     * @return ClassReflectionInterface[]
111
     */
112
    public function getParsedClasses(): array
113
    {
114
        return $this->parserStorage->getElementsByType(ElementsInterface::CLASSES);
115
    }
116
}
117