Skip to content

Commit e3b80f3

Browse files
committed
bug symfony#57310 [DependencyInjection] Fix ternary in AutowireCallable attribute (alamirault)
This PR was merged into the 6.4 branch. Discussion ---------- [DependencyInjection] Fix ternary in `AutowireCallable` attribute | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Although `AutowireCallable` construct is ```php public function __construct( ... bool|string $lazy = false, ) { ``` It call `Autowire::__construct(..., lazy: $lazy);` And in this class construct is ```php public function __construct( ... bool|string|array $lazy = false, ) { if ($this->lazy = \is_string($lazy) ? [$lazy] : $lazy) {} } ``` So `$this->lazy` is always `bool|array` and ternary always false Commits ------- f4792bc [DependencyInjection] Fix ternary in AutowireCallable attribute
2 parents 672874f + f4792bc commit e3b80f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/DependencyInjection/Attribute/AutowireCallable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(
4242

4343
public function buildDefinition(mixed $value, ?string $type, \ReflectionParameter $parameter): Definition
4444
{
45-
return (new Definition($type = \is_string($this->lazy) ? $this->lazy : ($type ?: 'Closure')))
45+
return (new Definition($type = \is_array($this->lazy) ? current($this->lazy) : ($type ?: 'Closure')))
4646
->setFactory(['Closure', 'fromCallable'])
4747
->setArguments([\is_array($value) ? $value + [1 => '__invoke'] : $value])
4848
->setLazy($this->lazy || 'Closure' !== $type && 'callable' !== (string) $parameter->getType());

0 commit comments

Comments
 (0)