@@ -33,27 +33,35 @@ private function id(EntityManagerInterface $entityManager, object $entity): mixe
33
33
}
34
34
35
35
if (isset ($ meta ->fieldMappings [$ pk ])) {
36
+ \assert (\is_string ($ meta ->fieldMappings [$ pk ]['type ' ]));
36
37
$ type = Type::getType ($ meta ->fieldMappings [$ pk ]['type ' ]);
37
38
39
+ \assert (\is_object ($ meta ->getReflectionProperty ($ pk )));
40
+
38
41
return $ this ->value ($ entityManager , $ type , $ meta ->getReflectionProperty ($ pk )->getValue ($ entity ));
39
42
}
40
43
41
- /**
44
+ /*
42
45
* Primary key is not part of fieldMapping.
43
46
*
44
47
* @see https://github.com/DamienHarper/auditor-bundle/issues/40
45
48
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html#identity-through-foreign-entities
46
49
* We try to get it from associationMapping (will throw a MappingException if not available)
47
50
*/
51
+ \assert (\is_object ($ meta ->getReflectionProperty ($ pk )));
48
52
$ targetEntity = $ meta ->getReflectionProperty ($ pk )->getValue ($ entity );
49
53
50
54
$ mapping = $ meta ->getAssociationMapping ($ pk );
51
55
56
+ \assert (\is_string ($ mapping ['targetEntity ' ]));
52
57
$ meta = $ entityManager ->getClassMetadata ($ mapping ['targetEntity ' ]);
53
58
$ pk = $ meta ->getSingleIdentifierFieldName ();
59
+
60
+ \assert (\is_string ($ meta ->fieldMappings [$ pk ]['type ' ]));
54
61
$ type = Type::getType ($ meta ->fieldMappings [$ pk ]['type ' ]);
55
62
56
63
\assert (\is_object ($ targetEntity ));
64
+ \assert (\is_object ($ meta ->getReflectionProperty ($ pk )));
57
65
58
66
return $ this ->value ($ entityManager , $ type , $ meta ->getReflectionProperty ($ pk )->getValue ($ targetEntity ));
59
67
}
@@ -151,6 +159,7 @@ private function diff(EntityManagerInterface $entityManager, object $entity, arr
151
159
&& $ this ->provider ->isAuditedField ($ entity , $ fieldName )
152
160
) {
153
161
$ mapping = $ meta ->fieldMappings [$ fieldName ];
162
+ \assert (\is_string ($ mapping ['type ' ]));
154
163
$ type = Type::getType ($ mapping ['type ' ]);
155
164
$ o = $ this ->value ($ entityManager , $ type , $ old );
156
165
$ n = $ this ->value ($ entityManager , $ type , $ new );
0 commit comments