Skip to content

Commit f6a4fa7

Browse files
[DI] minor fix
1 parent cdb18ad commit f6a4fa7

File tree

1 file changed

+8
-4
lines changed
  • src/Symfony/Component/DependencyInjection/Attribute

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ public function __construct(
4343
string $param = null,
4444
public bool $lazy = false,
4545
) {
46-
if ($lazy && null !== ($expression ?? $env ?? $param)) {
47-
throw new LogicException('#[Autowire] attribute cannot be $lazy and use $env, $param, or $value.');
48-
}
49-
if (!$lazy && !(null !== $value xor null !== $service xor null !== $expression xor null !== $env xor null !== $param)) {
46+
if ($lazy) {
47+
if (null !== ($expression ?? $env ?? $param)) {
48+
throw new LogicException('#[Autowire] attribute cannot be $lazy and use $expression, $env, or $param.');
49+
}
50+
if (null !== $value && null !== $service) {
51+
throw new LogicException('#[Autowire] attribute cannot declare $value and $service at the same time.');
52+
}
53+
} elseif (!(null !== $value xor null !== $service xor null !== $expression xor null !== $env xor null !== $param)) {
5054
throw new LogicException('#[Autowire] attribute must declare exactly one of $service, $expression, $env, $param or $value.');
5155
}
5256

0 commit comments

Comments
 (0)