|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Part of SplTypes package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Adrien Loyant <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Ducks\Component\SplTypes; |
|
15
|
|
|
|
|
16
|
|
|
use Ducks\Component\SplTypes\Reflection\SplReflectionEnumUnitCase; |
|
17
|
|
|
|
|
18
|
|
|
trait SplUnitEnumTrait |
|
19
|
|
|
{ |
|
20
|
|
|
use SplEnumSingletonTrait; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* case-sensitive name of the case itself. |
|
24
|
|
|
* |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
protected string $name; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Generates a list of cases on an enum |
|
31
|
|
|
* |
|
32
|
|
|
* @return array<int, UnitEnum|BackedEnum> |
|
33
|
|
|
* An array of all defined cases of this enumeration, in order of declaration. |
|
34
|
|
|
*/ |
|
35
|
|
|
public static function cases(): array |
|
36
|
|
|
{ |
|
37
|
|
|
static $cases = null; |
|
38
|
|
|
|
|
39
|
|
|
if (null === $cases) { |
|
40
|
|
|
$enum = new \ReflectionEnum(static::class); |
|
|
|
|
|
|
41
|
|
|
foreach ($enum->getCases() as $case) { |
|
42
|
|
|
/** @var Reflection\SplReflectionEnumUnitCase $case */ |
|
43
|
|
|
$cases[] = $case->getValue(); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return $cases ?? []; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Return a new instance of enum |
|
52
|
|
|
* |
|
53
|
|
|
* @param string $name |
|
54
|
|
|
* @param array $arguments |
|
55
|
|
|
* |
|
56
|
|
|
* @return static self keywords not an equivalent |
|
57
|
|
|
* |
|
58
|
|
|
* @psalm-suppress UnsafeInstantiation |
|
59
|
|
|
* @phpstan-ignore-next-line |
|
60
|
|
|
*/ |
|
61
|
|
|
#[\ReturnTypeWillChange] |
|
62
|
|
|
public static function __callStatic(string $name, array $arguments) |
|
63
|
|
|
{ |
|
64
|
|
|
try { |
|
65
|
|
|
$unit = new SplReflectionEnumUnitCase(static::class, $name); |
|
66
|
|
|
$object = $unit->getValue(); |
|
67
|
|
|
} catch (\ReflectionException $th) { |
|
68
|
|
|
throw new \Error('Undefined constant ' . static::class . '::' . $name); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** @var static $object */ |
|
72
|
|
|
return $object; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
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