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

ReflectionParameterTest::testGetTypeHint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace ApiGen\Parser\Tests\Reflection;
4
5
use ApiGen\Contracts\Configuration\ConfigurationInterface;
6
use ApiGen\Contracts\Parser\ParserStorageInterface;
7
use ApiGen\Contracts\Parser\Reflection\ClassReflectionInterface;
8
use ApiGen\Contracts\Parser\Reflection\MethodReflectionInterface;
9
use ApiGen\Contracts\Parser\Reflection\ParameterReflectionInterface;
10
use ApiGen\Contracts\Parser\Reflection\TokenReflection\ReflectionFactoryInterface;
11
use ApiGen\Parser\Broker\Backend;
12
use ApiGen\Parser\Reflection\TokenReflection\ReflectionFactory;
13
use PHPUnit\Framework\TestCase;
14
use ReflectionProperty;
15
use TokenReflection\Broker;
16
17
class ReflectionParameterTest extends TestCase
18
{
19
    /**
20
     * @var ClassReflectionInterface
21
     */
22
    private $reflectionClass;
23
24
    /**
25
     * @var ParameterReflectionInterface
26
     */
27
    private $reflectionParameter;
28
29
    protected function setUp(): void
30
    {
31
        $backend = new Backend($this->getReflectionFactory());
32
        $broker = new Broker($backend);
33
        $broker->processDirectory(__DIR__ . '/ReflectionMethodSource');
34
35
        $this->reflectionClass = $backend->getClasses()['Project\ReflectionMethod'];
36
        $reflectionMethod = $this->reflectionClass->getMethod('methodWithArgs');
37
        $this->reflectionParameter = $reflectionMethod->getParameter(0);
38
    }
39
40
    public function testInstance(): void
41
    {
42
        $this->assertInstanceOf('ApiGen\Parser\Reflection\ReflectionParameter', $this->reflectionParameter);
43
    }
44
45
    public function testGetTypeHint(): void
46
    {
47
        $this->assertSame('int|string', $this->reflectionParameter->getTypeHint());
48
    }
49
50
    public function testGetDescription(): void
51
    {
52
        $this->assertSame(' the URL of the API endpoint', $this->reflectionParameter->getDescription());
53
    }
54
55
    public function testIsDefaultValueAvailable(): void
56
    {
57
        $this->assertTrue($this->reflectionParameter->isDefaultValueAvailable());
58
    }
59
60
    public function testGetPosition(): void
61
    {
62
        $this->assertSame(0, $this->reflectionParameter->getPosition());
63
    }
64
65
    public function testIsArray(): void
66
    {
67
        $this->assertFalse($this->reflectionParameter->isArray());
68
    }
69
70
    public function testIsCallable(): void
71
    {
72
        $this->assertFalse($this->reflectionParameter->isCallable());
73
    }
74
75
    public function testGetClass(): void
76
    {
77
        $this->assertNull($this->reflectionParameter->getClass());
78
    }
79
80
    public function testGetClassName(): void
81
    {
82
        $this->assertNull($this->reflectionParameter->getClassName());
83
    }
84
85
    public function testAllowsNull(): void
86
    {
87
        $this->assertTrue($this->reflectionParameter->allowsNull());
88
    }
89
90
    public function testIsOptional(): void
91
    {
92
        $this->assertTrue($this->reflectionParameter->isOptional());
93
    }
94
95
    public function testIsPassedByReference(): void
96
    {
97
        $this->assertFalse($this->reflectionParameter->isPassedByReference());
98
    }
99
100
    public function testCanBePassedByValue(): void
101
    {
102
        $this->assertTrue($this->reflectionParameter->canBePassedByValue());
103
    }
104
105
    public function testGetDeclaringFunction(): void
106
    {
107
        $this->assertInstanceOf(MethodReflectionInterface::class, $this->reflectionParameter->getDeclaringFunction());
108
    }
109
110
    public function testGetDeclaringFunctionName(): void
111
    {
112
        $this->assertSame('methodWithArgs', $this->reflectionParameter->getDeclaringFunctionName());
113
    }
114
115
    public function testGetDeclaringClass(): void
116
    {
117
        $this->assertInstanceOf(
118
            'ApiGen\Parser\Reflection\ReflectionClass',
119
            $this->reflectionParameter->getDeclaringClass()
120
        );
121
    }
122
123
    public function testGetDeclaringClassName(): void
124
    {
125
        $this->assertSame('Project\ReflectionMethod', $this->reflectionParameter->getDeclaringClassName());
126
    }
127
128
    public function testIsUnlimited(): void
129
    {
130
        $this->assertFalse($this->reflectionParameter->isUnlimited());
131
    }
132
133 View Code Duplication
    private function getReflectionFactory(): ReflectionFactoryInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
134
    {
135
        $parserStorageMock = $this->createMock(ParserStorageInterface::class);
136
        $parserStorageMock->method('getElementsByType')->willReturnCallback(function ($arg) {
137
            if ($arg) {
138
                return ['Project\ReflectionMethod' => $this->reflectionClass];
139
            }
140
        });
141
        $configurationMock = $this->createMock(ConfigurationInterface::class);
142
        $configurationMock->method('getVisibilityLevel')
143
            ->willReturn(ReflectionProperty::IS_PUBLIC);
144
145
        return new ReflectionFactory($configurationMock, $parserStorageMock);
146
    }
147
}
148