@@ -172,10 +172,18 @@ public function &__get($name): mixed
172
172
$ scope = Registry::getScope ($ propertyScopes , $ class , $ name );
173
173
$ state = $ this ->lazyObjectState ?? null ;
174
174
175
- if ($ state && (null === $ scope || isset ($ propertyScopes ["\0$ scope \0$ name " ]))
176
- && LazyObjectState::STATUS_UNINITIALIZED_PARTIAL !== $ state ->initialize ($ this , $ name , $ readonlyScope ?? $ scope )
177
- ) {
178
- goto get_in_scope;
175
+ if ($ state && (null === $ scope || isset ($ propertyScopes ["\0$ scope \0$ name " ]))) {
176
+ if (LazyObjectState::STATUS_INITIALIZED_FULL === $ state ->status ) {
177
+ // Work around php/php-src#12695
178
+ $ property = $ propertyScopes [null === $ scope ? $ name : "\0$ scope \0$ name " ][3 ]
179
+ ?? (Hydrator::$ propertyScopes [$ this ::class] = Hydrator::getPropertyScopes ($ this ::class))[3 ];
180
+ } else {
181
+ $ property = null ;
182
+ }
183
+
184
+ if ($ property ?->isInitialized($ this ) ?? LazyObjectState::STATUS_UNINITIALIZED_PARTIAL !== $ state ->initialize ($ this , $ name , $ readonlyScope ?? $ scope )) {
185
+ goto get_in_scope;
186
+ }
179
187
}
180
188
}
181
189
@@ -237,7 +245,9 @@ public function __set($name, $value): void
237
245
$ scope = Registry::getScope ($ propertyScopes , $ class , $ name , $ readonlyScope );
238
246
$ state = $ this ->lazyObjectState ?? null ;
239
247
240
- if ($ state && ($ readonlyScope === $ scope || isset ($ propertyScopes ["\0$ scope \0$ name " ]))) {
248
+ if ($ state && ($ readonlyScope === $ scope || isset ($ propertyScopes ["\0$ scope \0$ name " ]))
249
+ && LazyObjectState::STATUS_INITIALIZED_FULL !== $ state ->status
250
+ ) {
241
251
if (LazyObjectState::STATUS_UNINITIALIZED_FULL === $ state ->status ) {
242
252
$ state ->initialize ($ this , $ name , $ readonlyScope ?? $ scope );
243
253
}
@@ -271,6 +281,7 @@ public function __isset($name): bool
271
281
$ state = $ this ->lazyObjectState ?? null ;
272
282
273
283
if ($ state && (null === $ scope || isset ($ propertyScopes ["\0$ scope \0$ name " ]))
284
+ && LazyObjectState::STATUS_INITIALIZED_FULL !== $ state ->status
274
285
&& LazyObjectState::STATUS_UNINITIALIZED_PARTIAL !== $ state ->initialize ($ this , $ name , $ readonlyScope ?? $ scope )
275
286
) {
276
287
goto isset_in_scope;
@@ -300,7 +311,9 @@ public function __unset($name): void
300
311
$ scope = Registry::getScope ($ propertyScopes , $ class , $ name , $ readonlyScope );
301
312
$ state = $ this ->lazyObjectState ?? null ;
302
313
303
- if ($ state && ($ readonlyScope === $ scope || isset ($ propertyScopes ["\0$ scope \0$ name " ]))) {
314
+ if ($ state && ($ readonlyScope === $ scope || isset ($ propertyScopes ["\0$ scope \0$ name " ]))
315
+ && LazyObjectState::STATUS_INITIALIZED_FULL !== $ state ->status
316
+ ) {
304
317
if (LazyObjectState::STATUS_UNINITIALIZED_FULL === $ state ->status ) {
305
318
$ state ->initialize ($ this , $ name , $ readonlyScope ?? $ scope );
306
319
}
0 commit comments