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.

Issues (62)

tests/AbstractTestCase.php (11 issues)

1
<?php
2
declare(strict_types=1);
3
namespace Thunder\Platenum\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use Thunder\Platenum\Enum\AbstractAttributeEnum;
7
use Thunder\Platenum\Enum\AbstractCallbackEnum;
8
use Thunder\Platenum\Enum\AbstractConstantsEnum;
9
use Thunder\Platenum\Enum\AbstractDocblockEnum;
10
use Thunder\Platenum\Enum\AbstractStaticEnum;
11
use Thunder\Platenum\Enum\AttributeEnumTrait;
12
use Thunder\Platenum\Enum\CallbackEnumTrait;
13
use Thunder\Platenum\Enum\ConstantsEnumTrait;
14
use Thunder\Platenum\Enum\DocblockEnumTrait;
15
use Thunder\Platenum\Enum\EnumTrait;
16
use Thunder\Platenum\Enum\Member;
17
use Thunder\Platenum\Enum\StaticEnumTrait;
18
use Thunder\Platenum\Tests\Fake\FakeEnum;
19
20
/**
21
 * @author Tomasz Kowalczyk <[email protected]>
22
 */
23
abstract class AbstractTestCase extends TestCase
24
{
25
    /** @return FakeEnum */
26
    protected function makeRawEnum(array $members): string
27
    {
28
        $entries = [];
29
        foreach($members as $member => $value) {
30
            $entries[] = sprintf('%s => %s', '\''.$member.'\'', is_string($value) ? '\''.$value.'\'' : $value);
31
        }
32
33
        $class = $this->computeUniqueClassName('RawEnum');
34
        eval('final class '.$class.' implements \JsonSerializable {
35
            use '.EnumTrait::class.';
36
            private static function resolve(): array { return ['.implode(', ', $entries).']; }
37
        }');
38
39
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
40
    }
41
42
    /** @return FakeEnum */
43
    protected function makeDocblockTraitEnum(array $members): string
44
    {
45
        $entries = [];
46
        foreach($members as $member => $value) {
47
            $entries[] = sprintf(' * @method static self %s()', $member);
48
        }
49
50
        $class = $this->computeUniqueClassName('DocblockTrait');
51
        eval('/**'."\n".implode("\n", $entries)."\n".'*/ final class '.$class.' { use '.DocblockEnumTrait::class.'; }');
52
53
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
54
    }
55
56
    /** @return FakeEnum */
57
    protected function makeDocblockExtendsEnum(array $members): string
58
    {
59
        $entries = [];
60
        foreach($members as $member => $value) {
61
            $entries[] = sprintf(' * @method static self %s()', $member);
62
        }
63
64
        $class = $this->computeUniqueClassName('DocblockExtends');
65
        eval('/**'."\n".implode("\n", $entries)."\n".'*/ final class '.$class.' extends '.AbstractDocblockEnum::class.' {}');
66
67
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
68
    }
69
70
    /** @return FakeEnum */
71
    protected function makeConstantsTraitEnum(array $members): string
72
    {
73
        $entries = [];
74
        foreach($members as $member => $value) {
75
            $entries[] = sprintf('private const %s = %s;', $member, is_string($value) ? '\''.$value.'\'' : $value);
76
        }
77
78
        $class = $this->computeUniqueClassName('ConstantsTrait');
79
        eval('final class '.$class.' implements \JsonSerializable { '.implode("\n", $entries).' use '.ConstantsEnumTrait::class.'; }');
80
81
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
82
    }
83
84
    /** @return FakeEnum */
85
    protected function makeConstantsExtendsEnum(array $members): string
86
    {
87
        $entries = [];
88
        foreach($members as $member => $value) {
89
            $entries[] = sprintf('private const %s = %s;', $member, is_string($value) ? '\''.$value.'\'' : $value);
90
        }
91
92
        $class = $this->computeUniqueClassName('ConstantsExtends');
93
        eval('final class '.$class.' extends '.AbstractConstantsEnum::class.' { '.implode("\n", $entries).' }');
94
95
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
96
    }
97
98
    /** @return FakeEnum */
99
    protected function makeStaticTraitEnum(array $members): string
100
    {
101
        $entries = [];
102
        foreach($members as $member => $value) {
103
            $entries[] = sprintf('%s => %s', '\''.$member.'\'', is_string($value) ? '\''.$value.'\'' : $value);
104
        }
105
106
        $class = $this->computeUniqueClassName('StaticTrait');
107
        eval('final class '.$class.' implements \JsonSerializable { private static $mapping = ['.implode(', ', $entries).']; use '.StaticEnumTrait::class.'; }');
108
109
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
110
    }
111
112
    /** @return FakeEnum */
113
    protected function makeStaticExtendsEnum(array $members): string
114
    {
115
        $entries = [];
116
        foreach($members as $member => $value) {
117
            $entries[] = sprintf('%s => %s', '\''.$member.'\'', is_string($value) ? '\''.$value.'\'' : $value);
118
        }
119
120
        $class = $this->computeUniqueClassName('StaticExtends');
121
        eval('final class '.$class.' extends '.AbstractStaticEnum::class.' { protected static $mapping = ['.implode(', ', $entries).']; }');
122
123
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
124
    }
125
126
    /** @return FakeEnum */
127
    protected function makeCallbackTraitEnum(array $members): string
128
    {
129
        $class = $this->computeUniqueClassName('CallbackTrait');
130
        eval('final class '.$class.' implements \JsonSerializable { use '.CallbackEnumTrait::class.'; }');
131
132
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
133
    }
134
135
    /** @return FakeEnum */
136
    protected function makeCallbackExtendsEnum(array $members): string
137
    {
138
        $class = $this->computeUniqueClassName('CallbackExtends');
139
        eval('final class '.$class.' extends '.AbstractCallbackEnum::class.' { }');
140
141
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
142
    }
143
144
    /** @return FakeEnum */
145
    protected function makeAttributeTraitEnum(array $members): string
146
    {
147
        $attributes = [];
148
        foreach($members as $member => $value) {
149
            $attributes[] = '#['.Member::class.'(\''.$member.'\', '.$value.')]';
150
        }
151
152
        $class = $this->computeUniqueClassName('AttributeTrait');
153
        eval(implode("\n", $attributes)."\n".'final class '.$class.' implements \JsonSerializable { use '.AttributeEnumTrait::class.'; }');
154
155
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
156
    }
157
158
    /** @return FakeEnum */
159
    protected function makeAttributeExtendsEnum(array $members): string
160
    {
161
        $attributes = [];
162
        foreach($members as $member => $value) {
163
            $attributes[] = '#['.Member::class.'(\''.$member.'\', '.$value.')]';
164
        }
165
166
        $class = $this->computeUniqueClassName('AttributeExtends');
167
        eval(implode("\n", $attributes)."\n".'final class '.$class.' extends '.AbstractAttributeEnum::class.' {}');
168
169
        return $class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $class returns the type string which is incompatible with the documented return type Thunder\Platenum\Tests\Fake\FakeEnum.
Loading history...
170
    }
171
172
    protected function computeUniqueClassName(string $prefix): string
173
    {
174
        while(true === class_exists($class = $prefix.random_int(1, 1000000))) {
175
            continue;
176
        }
177
178
        return $class;
179
    }
180
}
181