Skip to content

[DependencyInjection] Fix code generating lazy closures #50119

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static function getCode(string $initializer, array $callable, Definition
throw new RuntimeException(sprintf('Cannot create lazy closure for service "%s" because its corresponding callable is invalid.', $id));
}

$code = ProxyHelper::exportSignature($r->getMethod($method));
$code = ProxyHelper::exportSignature($r->getMethod($method), true, $args);

if ($asClosure) {
$code = ' { '.preg_replace('/: static$/', ': \\'.$r->name, $code);
Expand All @@ -81,7 +81,7 @@ public static function getCode(string $initializer, array $callable, Definition
}

$code = 'new class('.$initializer.') extends \\'.self::class
.$code.' { return $this->service->'.$callable[1].'(...\func_get_args()); } '
.$code.' { return $this->service->'.$callable[1].'('.$args.'); } '
.'}';

return $asClosure ? '('.$code.')->'.$method.'(...)' : $code;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/DependencyInjection/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"psr/container": "^1.1|^2.0",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/service-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^6.2.7"
"symfony/var-exporter": "^6.2.10"
},
"require-dev": {
"symfony/yaml": "^5.4|^6.0",
Expand Down