Skip to content

Commit

Permalink
Add the propoer void return type on the __load method of proxies
Browse files Browse the repository at this point in the history
When using ghost objects, the method was leaking a `static` return type due to the way it was implemented, which is incompatible with the native return type that will be added in doctrine/persistence v4.
  • Loading branch information
stof committed Jun 20, 2024
1 parent 41cb5fb commit c06f6b9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Proxy/ProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,18 @@ private function generateUseLazyGhostTrait(ClassMetadata $class): string
$code = substr($code, 7 + (int) strpos($code, "\n{"));
$code = substr($code, 0, (int) strpos($code, "\n}"));
$code = str_replace('LazyGhostTrait;', str_replace("\n ", "\n", 'LazyGhostTrait {
initializeLazyObject as __load;
initializeLazyObject as private;
setLazyObjectAsInitialized as public __setInitialized;
isLazyObjectInitialized as private;
createLazyGhost as private;
resetLazyObject as private;
}'), $code);
}
public function __load(): void
{
$this->initializeLazyObject();
}
'), $code);

return $code;
}
Expand Down

0 comments on commit c06f6b9

Please sign in to comment.