File tree 2 files changed +10
-7
lines changed
2 files changed +10
-7
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 ? $ 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,17 +1250,20 @@ 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 ();
1253
+ $ dataRef = $ this ->persistence ->{$ fromTryLoad ? 'tryLoad ' : 'load ' }($ this ->getModel (), $ this ->remapIdLoadToPersistence ($ id ));
1254
+ if ($ fromTryLoad && $ dataRef === null ) {
1255
+ return null ;
1257
1256
} else {
1258
1257
if ($ this ->id_field ) {
1259
1258
$ this ->setId ($ this ->getId ());
1260
1259
}
1261
1260
1262
1261
$ ret = $ this ->hook (self ::HOOK_AFTER_LOAD );
1263
1262
if ($ ret === false ) {
1263
+ if ($ fromTryLoad ) {
1264
+ return null ;
1265
+ }
1266
+
1264
1267
$ this ->unload ();
1265
1268
} elseif (is_object ($ ret )) {
1266
1269
return $ ret ; // @phpstan-ignore-line
You can’t perform that action at this time.
0 commit comments