File tree 2 files changed +22
-16
lines changed
2 files changed +22
-16
lines changed Original file line number Diff line number Diff line change 50
50
"friendsofphp/php-cs-fixer" : " ^3.0" ,
51
51
"johnkary/phpunit-speedtrap" : " ^3.3" ,
52
52
"phpstan/extension-installer" : " ^1.1" ,
53
- "phpstan/phpstan" : " ^1.0 " ,
53
+ "phpstan/phpstan" : " ^1.6 " ,
54
54
"phpstan/phpstan-deprecation-rules" : " ^1.0" ,
55
55
"phpunit/phpunit" : " ^9.5.5"
56
56
},
Original file line number Diff line number Diff line change @@ -1234,9 +1234,9 @@ private function remapIdLoadToPersistence($id)
1234
1234
/**
1235
1235
* @param mixed $id
1236
1236
*
1237
- * @return $ this
1237
+ * @return ($fromTryLoad is true ? $ this|null : $this)
1238
1238
*/
1239
- private function _loadThis (bool $ isTryLoad , $ id )
1239
+ private function _loadThis (bool $ fromTryLoad , $ id )
1240
1240
{
1241
1241
$ this ->assertIsEntity ();
1242
1242
if ($ this ->isLoaded ()) {
@@ -1250,21 +1250,27 @@ private function _loadThis(bool $isTryLoad, $id)
1250
1250
return $ this ;
1251
1251
}
1252
1252
$ dataRef = &$ this ->getDataRef ();
1253
- $ dataRef = $ this ->persistence ->{$ isTryLoad ? 'tryLoad ' : 'load ' }($ this ->getModel (), $ this ->remapIdLoadToPersistence ($ id ));
1254
- if ($ isTryLoad && $ dataRef === null ) {
1255
- $ dataRef = [];
1256
- $ this ->unload ();
1257
- } else {
1258
- if ($ this ->id_field ) {
1259
- $ this ->setId ($ this ->getId ());
1260
- }
1253
+ $ dataRef = $ this ->persistence ->{$ fromTryLoad ? 'tryLoad ' : 'load ' }($ this ->getModel (), $ this ->remapIdLoadToPersistence ($ id ));
1261
1254
1262
- $ ret = $ this ->hook (self ::HOOK_AFTER_LOAD );
1263
- if ($ ret === false ) {
1264
- $ this ->unload ();
1265
- } elseif (is_object ($ ret )) {
1266
- return $ ret ; // @phpstan-ignore-line
1255
+ if ($ dataRef === null ) {
1256
+ // $fromTryLoad is true here
1257
+
1258
+ return null ;
1259
+ }
1260
+
1261
+ if ($ this ->id_field ) {
1262
+ $ this ->setId ($ this ->getId ());
1263
+ }
1264
+
1265
+ $ ret = $ this ->hook (self ::HOOK_AFTER_LOAD );
1266
+ if ($ ret === false ) {
1267
+ if ($ fromTryLoad ) {
1268
+ return null ;
1267
1269
}
1270
+
1271
+ $ this ->unload ();
1272
+ } elseif (is_object ($ ret )) {
1273
+ return $ ret ; // @phpstan-ignore-line
1268
1274
}
1269
1275
1270
1276
return $ this ;
You can’t perform that action at this time.
0 commit comments