Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
[DependencyInjection] Fix code generating lazy closures
  • Loading branch information
nicolas-grekas committed Apr 22, 2023
commit 9f7abbe5a617e8c94f3a29f79127f5a387ea9ed5
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