1 | <?php |
||
26 | class ORM extends Component implements ORMInterface, SingletonInterface |
||
27 | { |
||
28 | use LoggerTrait; |
||
29 | |||
30 | /** |
||
31 | * Memory section to store ORM schema. |
||
32 | */ |
||
33 | const MEMORY = 'orm.schema'; |
||
34 | |||
35 | /** |
||
36 | * Already created instantiators. |
||
37 | * |
||
38 | * @invisible |
||
39 | * @var InstantiatorInterface[] |
||
40 | */ |
||
41 | private $instantiators = []; |
||
42 | |||
43 | /** |
||
44 | * ORM schema. |
||
45 | * |
||
46 | * @invisible |
||
47 | * @var array |
||
48 | */ |
||
49 | private $schema = []; |
||
50 | |||
51 | /** |
||
52 | * @var DatabaseManager |
||
53 | */ |
||
54 | protected $manager; |
||
55 | |||
56 | /** |
||
57 | * @var SchemaLocator |
||
58 | */ |
||
59 | protected $locator; |
||
60 | |||
61 | /** |
||
62 | * @invisible |
||
63 | * @var MemoryInterface |
||
64 | */ |
||
65 | protected $memory; |
||
66 | |||
67 | /** |
||
68 | * Container defines working scope for all Documents and DocumentEntities. |
||
69 | * |
||
70 | * @var ContainerInterface |
||
71 | */ |
||
72 | protected $container; |
||
73 | |||
74 | /** |
||
75 | * @param DatabaseManager $manager |
||
76 | * @param LocatorInterface $locator |
||
77 | * @param MemoryInterface $memory |
||
78 | * @param ContainerInterface $container |
||
79 | */ |
||
80 | public function __construct( |
||
95 | |||
96 | /** |
||
97 | * Create instance of ORM SchemaBuilder. |
||
98 | * |
||
99 | * @param bool $locate Set to true to automatically locate available records and record sources |
||
100 | * sources in a project files (based on tokenizer scope). |
||
101 | * |
||
102 | * @return SchemaBuilder |
||
103 | * |
||
104 | * @throws SchemaException |
||
105 | */ |
||
106 | public function schemaBuilder(bool $locate = true): SchemaBuilder |
||
125 | |||
126 | /** |
||
127 | * Specify behaviour schema for ORM to be used. Attention, you have to call renderSchema() |
||
128 | * prior to passing builder into this method. |
||
129 | * |
||
130 | * @param SchemaBuilder $builder |
||
131 | * @param bool $remember Set to true to remember packed schema in memory. |
||
132 | */ |
||
133 | public function buildSchema(SchemaBuilder $builder, bool $remember = false) |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function define(string $class, int $property) |
||
162 | |||
163 | //other methods |
||
164 | |||
165 | /** |
||
166 | * {@inheritdoc} |
||
167 | */ |
||
168 | public function make( |
||
177 | |||
178 | //todo: __clone |
||
179 | |||
180 | /** |
||
181 | * Get object responsible for class instantiation. |
||
182 | * |
||
183 | * @param string $class |
||
184 | * |
||
185 | * @return InstantiatorInterface |
||
186 | */ |
||
187 | protected function instantiator(string $class): InstantiatorInterface |
||
206 | |||
207 | /** |
||
208 | * Load packed schema from memory. |
||
209 | * |
||
210 | * @return array |
||
211 | */ |
||
212 | protected function loadSchema(): array |
||
216 | |||
217 | /** |
||
218 | * Get ODM specific factory. |
||
219 | * |
||
220 | * @return FactoryInterface |
||
221 | */ |
||
222 | protected function getFactory(): FactoryInterface |
||
230 | } |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.