@@ -70,15 +70,15 @@ final class Entity
7070 private array |string |null $ typecast = null ;
7171
7272 private array $ schema = [];
73-
7473 private FieldMap $ fields ;
75-
7674 private RelationMap $ relations ;
7775 private FieldMap $ primaryFields ;
7876 private array $ schemaModifiers = [];
7977 private ?Inheritance $ inheritance = null ;
78+
8079 /** @var class-string|null */
8180 private ?string $ stiParent = null ;
81+
8282 private ForeignKeyMap $ foreignKeys ;
8383
8484 public function __construct ()
@@ -90,18 +90,6 @@ public function __construct()
9090 $ this ->foreignKeys = new ForeignKeyMap ();
9191 }
9292
93- /**
94- * Full entity copy.
95- */
96- public function __clone ()
97- {
98- $ this ->options = clone $ this ->options ;
99- $ this ->fields = clone $ this ->fields ;
100- $ this ->primaryFields = clone $ this ->primaryFields ;
101- $ this ->relations = clone $ this ->relations ;
102- $ this ->foreignKeys = clone $ this ->foreignKeys ;
103- }
104-
10593 public function getOptions (): OptionMap
10694 {
10795 return $ this ->options ;
@@ -253,7 +241,7 @@ public function getForeignKeys(): ForeignKeyMap
253241 public function addSchemaModifier (SchemaModifierInterface $ modifier ): self
254242 {
255243 $ this ->schemaModifiers [] = $ modifier ->withRole ($ this ->role ?? throw new EntityException (
256- 'Entity must have a `role` to be able to add a modifier. '
244+ 'Entity must have a `role` to be able to add a modifier. ' ,
257245 ));
258246
259247 return $ this ;
@@ -364,25 +352,6 @@ public function getPrimaryFields(): FieldMap
364352 return $ this ->primaryFields ;
365353 }
366354
367- /**
368- * @template T of object
369- *
370- * @param class-string<T>|null $class
371- *
372- * @return ($class is class-string<T> ? class-string<T> : null)
373- */
374- private function normalizeClass (string $ class = null ): ?string
375- {
376- if ($ class === null ) {
377- return null ;
378- }
379-
380- /** @var class-string<T> $class */
381- $ class = \ltrim ($ class , '\\' );
382-
383- return $ class ;
384- }
385-
386355 public function setInheritance (Inheritance $ inheritance ): void
387356 {
388357 $ this ->inheritance = $ inheritance ;
@@ -434,4 +403,35 @@ public function setTableName(string $tableName): void
434403 {
435404 $ this ->tableName = $ tableName ;
436405 }
406+
407+ /**
408+ * Full entity copy.
409+ */
410+ public function __clone ()
411+ {
412+ $ this ->options = clone $ this ->options ;
413+ $ this ->fields = clone $ this ->fields ;
414+ $ this ->primaryFields = clone $ this ->primaryFields ;
415+ $ this ->relations = clone $ this ->relations ;
416+ $ this ->foreignKeys = clone $ this ->foreignKeys ;
417+ }
418+
419+ /**
420+ * @template T of object
421+ *
422+ * @param class-string<T>|null $class
423+ *
424+ * @return ($class is class-string<T> ? class-string<T> : null)
425+ */
426+ private function normalizeClass (?string $ class = null ): ?string
427+ {
428+ if ($ class === null ) {
429+ return null ;
430+ }
431+
432+ /** @var class-string<T> $class */
433+ $ class = \ltrim ($ class , '\\' );
434+
435+ return $ class ;
436+ }
437437}
0 commit comments