1 | <?php |
||
25 | class ORM extends Component implements ORMInterface, SingletonInterface |
||
26 | { |
||
27 | /** |
||
28 | * Memory section to store ORM schema. |
||
29 | */ |
||
30 | const MEMORY = 'orm.schema'; |
||
31 | |||
32 | /** |
||
33 | * Already created instantiators. |
||
34 | * |
||
35 | * @invisible |
||
36 | * @var InstantiatorInterface[] |
||
37 | */ |
||
38 | private $instantiators = []; |
||
39 | |||
40 | /** |
||
41 | * ORM schema. |
||
42 | * |
||
43 | * @invisible |
||
44 | * @var array |
||
45 | */ |
||
46 | private $schema = []; |
||
47 | |||
48 | /** |
||
49 | * @var DatabaseManager |
||
50 | */ |
||
51 | protected $manager; |
||
52 | |||
53 | /** |
||
54 | * @var SchemaLocator |
||
55 | */ |
||
56 | protected $locator; |
||
57 | |||
58 | /** |
||
59 | * @invisible |
||
60 | * @var MemoryInterface |
||
61 | */ |
||
62 | protected $memory; |
||
63 | |||
64 | /** |
||
65 | * Container defines working scope for all Documents and DocumentEntities. |
||
66 | * |
||
67 | * @var ContainerInterface |
||
68 | */ |
||
69 | protected $container; |
||
70 | |||
71 | /** |
||
72 | * @param DatabaseManager $manager |
||
73 | * @param LocatorInterface $locator |
||
74 | * @param MemoryInterface $memory |
||
75 | * @param ContainerInterface $container |
||
76 | */ |
||
77 | public function __construct( |
||
92 | |||
93 | /** |
||
94 | * Create instance of ORM SchemaBuilder. |
||
95 | * |
||
96 | * @param bool $locate Set to true to automatically locate available records and record sources |
||
97 | * sources in a project files (based on tokenizer scope). |
||
98 | * |
||
99 | * @return SchemaBuilder |
||
100 | * |
||
101 | * @throws SchemaException |
||
102 | */ |
||
103 | public function schemaBuilder(bool $locate = true): SchemaBuilder |
||
122 | |||
123 | public function requireSync() |
||
127 | |||
128 | /** |
||
129 | * Specify behaviour schema for ORM to be used. Attention, you have to call renderSchema() |
||
130 | * prior to passing builder into this method. |
||
131 | * |
||
132 | * @param SchemaBuilder $builder |
||
133 | * @param bool $remember Set to true to remember packed schema in memory. |
||
134 | */ |
||
135 | public function buildSchema(SchemaBuilder $builder, bool $remember = false) |
||
143 | |||
144 | /** |
||
145 | * {@inheritdoc} |
||
146 | */ |
||
147 | public function define(string $class, int $property) |
||
165 | |||
166 | //other methods |
||
167 | |||
168 | /** |
||
169 | * {@inheritdoc} |
||
170 | */ |
||
171 | public function make( |
||
180 | |||
181 | //todo: __clone |
||
182 | |||
183 | /** |
||
184 | * Get object responsible for class instantiation. |
||
185 | * |
||
186 | * @param string $class |
||
187 | * |
||
188 | * @return InstantiatorInterface |
||
189 | */ |
||
190 | protected function instantiator(string $class): InstantiatorInterface |
||
209 | |||
210 | /** |
||
211 | * Load packed schema from memory. |
||
212 | * |
||
213 | * @return array |
||
214 | */ |
||
215 | protected function loadSchema(): array |
||
219 | |||
220 | /** |
||
221 | * Get ODM specific factory. |
||
222 | * |
||
223 | * @return FactoryInterface |
||
224 | */ |
||
225 | protected function getFactory(): FactoryInterface |
||
233 | } |
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.