Conditions | 2 |
Paths | 2 |
Total Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
35 | private function getTypeCode(string $class, string $type, string $name): string |
||
36 | { |
||
37 | $baseClass = $type === 'int' ? AbstractIntegerEnumType::class : AbstractEnumType::class; |
||
38 | $fqcn = self::getTypeClassname($class); |
||
39 | $classname = basename(str_replace('\\', '/', $fqcn)); |
||
40 | $ns = substr($fqcn, 0, -\strlen($classname) - 1); |
||
41 | |||
42 | return <<<PHP |
||
43 | |||
44 | namespace $ns; |
||
45 | |||
46 | if (!\class_exists('\\$fqcn')) { |
||
47 | class $classname extends \\{$baseClass} |
||
48 | { |
||
49 | const NAME = '$name'; |
||
50 | |||
51 | protected function getEnumClass(): string |
||
52 | { |
||
53 | return \\{$class}::class; |
||
54 | } |
||
55 | |||
56 | public function getName(): string |
||
57 | { |
||
58 | return static::NAME; |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 | |||
63 | PHP; |
||
64 | } |
||
65 | |||
71 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.