Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DependencyInjection] Do not addreturn inLazyClosure when return type of closure isvoid#51251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:6.3fromruudk:lazy-closure-void
Aug 3, 2023

Conversation

@ruudk
Copy link
Contributor

@ruudkruudk commentedAug 3, 2023
edited
Loading

QA
Branch?6.3
Bug fix?yes
New feature?no
Deprecations?no
Tickets
LicenseMIT
Doc PR

The LazyClosure was introduced in#49639 and generates PHP code using reflection.

It works, but when the callable has avoid return type, it would produce code like this:

return$container->services['closure2'] = (newclass(fn() =>new \Symfony\Component\DependencyInjection\Tests\Compiler\FooVoid())extends \Symfony\Component\DependencyInjection\Argument\LazyClosure {publicfunction__invoke(string$name) :void    {// the `return` below causes the errorreturn$this->service->__invoke(...\func_get_args());    }})->__invoke(...);

Thatreturn statement before calling the$this->service is not allowed and causes an error:

Compile Error: A void function must not return a value

/cc@nicolas-grekas

nicolas-grekas reacted with thumbs up emoji
@carsonbotcarsonbot added this to the6.3 milestoneAug 3, 2023
@ruudkruudkforce-pushed thelazy-closure-void branch 2 times, most recently fromc06e574 to2cab4b7CompareAugust 3, 2023 11:07
@carsonbotcarsonbot changed the titleDo not addreturn inLazyClosure when return type of closure isvoid[DependencyInjection] Do not addreturn inLazyClosure when return type of closure isvoidAug 3, 2023
@nicolas-grekas
Copy link
Member

Thank you@ruudk.

steef reacted with hooray emoji

@nicolas-grekasnicolas-grekas merged commitbbb5f5c intosymfony:6.3Aug 3, 2023
@ruudkruudk deleted the lazy-closure-void branchAugust 3, 2023 11:41
@fabpotfabpot mentioned this pull requestAug 26, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.3

Development

Successfully merging this pull request may close these issues.

3 participants

@ruudk@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp