@@ -705,7 +705,7 @@ class ClassMetadataInfo implements ClassMetadata
705
705
/**
706
706
* The ReflectionProperty instances of the mapped class.
707
707
*
708
- * @var ReflectionProperty[] |null[]
708
+ * @var array<string, ReflectionProperty|null>
709
709
*/
710
710
public $ reflFields = [];
711
711
@@ -993,7 +993,8 @@ public function wakeupReflection($reflService)
993
993
994
994
foreach ($ this ->embeddedClasses as $ property => $ embeddedClass ) {
995
995
if (isset ($ embeddedClass ['declaredField ' ])) {
996
- $ childProperty = $ reflService ->getAccessibleProperty (
996
+ $ childProperty = $ this ->getAccessibleProperty (
997
+ $ reflService ,
997
998
$ this ->embeddedClasses [$ embeddedClass ['declaredField ' ]]['class ' ],
998
999
$ embeddedClass ['originalField ' ]
999
1000
);
@@ -1007,7 +1008,8 @@ public function wakeupReflection($reflService)
1007
1008
continue ;
1008
1009
}
1009
1010
1010
- $ fieldRefl = $ reflService ->getAccessibleProperty (
1011
+ $ fieldRefl = $ this ->getAccessibleProperty (
1012
+ $ reflService ,
1011
1013
$ embeddedClass ['declared ' ] ?? $ this ->name ,
1012
1014
$ property
1013
1015
);
@@ -1020,15 +1022,15 @@ public function wakeupReflection($reflService)
1020
1022
if (isset ($ mapping ['declaredField ' ]) && isset ($ parentReflFields [$ mapping ['declaredField ' ]])) {
1021
1023
$ this ->reflFields [$ field ] = new ReflectionEmbeddedProperty (
1022
1024
$ parentReflFields [$ mapping ['declaredField ' ]],
1023
- $ reflService ->getAccessibleProperty ($ mapping ['originalClass ' ], $ mapping ['originalField ' ]),
1025
+ $ this ->getAccessibleProperty ($ reflService , $ mapping ['originalClass ' ], $ mapping ['originalField ' ]),
1024
1026
$ mapping ['originalClass ' ]
1025
1027
);
1026
1028
continue ;
1027
1029
}
1028
1030
1029
1031
$ this ->reflFields [$ field ] = isset ($ mapping ['declared ' ])
1030
- ? $ reflService ->getAccessibleProperty ($ mapping ['declared ' ], $ field )
1031
- : $ reflService ->getAccessibleProperty ($ this ->name , $ field );
1032
+ ? $ this ->getAccessibleProperty ($ reflService , $ mapping ['declared ' ], $ field )
1033
+ : $ this ->getAccessibleProperty ($ reflService , $ this ->name , $ field );
1032
1034
1033
1035
if (isset ($ mapping ['enumType ' ]) && $ this ->reflFields [$ field ] !== null ) {
1034
1036
$ this ->reflFields [$ field ] = new ReflectionEnumProperty (
@@ -1040,8 +1042,8 @@ public function wakeupReflection($reflService)
1040
1042
1041
1043
foreach ($ this ->associationMappings as $ field => $ mapping ) {
1042
1044
$ this ->reflFields [$ field ] = isset ($ mapping ['declared ' ])
1043
- ? $ reflService ->getAccessibleProperty ($ mapping ['declared ' ], $ field )
1044
- : $ reflService ->getAccessibleProperty ($ this ->name , $ field );
1045
+ ? $ this ->getAccessibleProperty ($ reflService , $ mapping ['declared ' ], $ field )
1046
+ : $ this ->getAccessibleProperty ($ reflService , $ this ->name , $ field );
1045
1047
}
1046
1048
}
1047
1049
@@ -3779,4 +3781,17 @@ private function assertMappingOrderBy(array $mapping): void
3779
3781
throw new InvalidArgumentException ("'orderBy' is expected to be an array, not " . gettype ($ mapping ['orderBy ' ]));
3780
3782
}
3781
3783
}
3784
+
3785
+ /**
3786
+ * @psalm-param class-string $class
3787
+ */
3788
+ private function getAccessibleProperty (ReflectionService $ reflService , string $ class , string $ field ): ?ReflectionProperty
3789
+ {
3790
+ $ reflectionProperty = $ reflService ->getAccessibleProperty ($ class , $ field );
3791
+ if ($ reflectionProperty !== null && PHP_VERSION_ID >= 80100 && $ reflectionProperty ->isReadOnly ()) {
3792
+ $ reflectionProperty = new ReflectionReadonlyProperty ($ reflectionProperty );
3793
+ }
3794
+
3795
+ return $ reflectionProperty ;
3796
+ }
3782
3797
}
0 commit comments