1 | <?php |
||
20 | final class FieldFactory implements FieldFactoryInterface |
||
21 | { |
||
22 | private $defaultType = Field::class; |
||
23 | private $fields = [ |
||
24 | Integer::class => [ |
||
25 | 'names' => ['id'], |
||
26 | 'regex' => ['/_id$/'], |
||
27 | 'types' => ['bigint', 'int', 'mediumint', 'smallint', 'tinyint', 'year'], |
||
28 | ], |
||
29 | Boolean::class => [ |
||
30 | 'names' => ['active'], |
||
31 | 'regex' => ['/^(is|has)[A-Z]/'], |
||
32 | 'types' => ['boolean'], |
||
33 | ], |
||
34 | Datetime::class => [ |
||
35 | 'names' => ['pubdate'], |
||
36 | 'regex' => ['/[a-z]At$/'], |
||
37 | 'types' => ['datetime'], |
||
38 | ], |
||
39 | Date::class => [ |
||
40 | 'names' => [], |
||
41 | 'regex' => [], |
||
42 | 'types' => ['date'], |
||
43 | ], |
||
44 | Decimal::class => [ |
||
45 | 'names' => [], |
||
46 | 'regex' => [], |
||
47 | 'types' => ['decimal', 'float', 'real'], |
||
48 | ], |
||
49 | Set::class => [ |
||
50 | 'names' => [], |
||
51 | 'regex' => [], |
||
52 | 'types' => ['set'], |
||
53 | ], |
||
54 | Point::class => [ |
||
55 | 'names' => [], |
||
56 | 'regex' => [], |
||
57 | 'types' => ['point'], |
||
58 | ], |
||
59 | Json::class => [ |
||
60 | 'names' => [], |
||
61 | 'regex' => [], |
||
62 | 'types' => ['json'], |
||
63 | ], |
||
64 | ]; |
||
65 | |||
66 | public function defineField(string $className, array $definition): self |
||
77 | |||
78 | public function getFieldDefinition(string $className): ?array |
||
82 | |||
83 | /** |
||
84 | * @see FieldFactoryInterface |
||
85 | * |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function get(Table $table, array $info): FieldInterface |
||
98 | |||
99 | /** |
||
100 | * Get the field class name. |
||
101 | */ |
||
102 | private function getClassName(string $name, string $type): ?string |
||
122 | } |
||
123 |
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.