Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not add
return
in LazyClosure
when return type of closure is `…
…void` The LazyClosure was introduced in #49639 and generates PHP code using reflection. It works, but when the callable has a `void` return type, it would produce code like this: ```php return $container->services['closure2'] = (new class(fn() => new \Symfony\Component\DependencyInjection\Tests\Compiler\FooVoid()) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure { public function __invoke(string $name) : void { return $this->service->__invoke(...\func_get_args()); } })->__invoke(...); ``` That `return` statement before calling the `$this->service` is not allowed and causes an error: ``` Compile Error: A void function must not return a value ```
- Loading branch information
Showing
4 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters