8000 [DependencyInjection] Partially revert #40406 · symfony/symfony@5aa773c · GitHub
[go: up one dir, main page]

Skip to content

Commit 5aa773c

Browse files
committed
[DependencyInjection] Partially revert #40406
1 parent d00b7ec commit 5aa773c

File tree

2 files changed

+5
-30
lines changed

2 files changed

+5
-30
lines changed

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\Config\Resource\ClassExistenceResource;
15-
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
16-
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
17-
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
18-
use Symfony\Component\DependencyInjection\Attribute\TaggedLocator;
1915
use Symfony\Component\DependencyInjection\Attribute\Target;
2016
use Symfony\Component\DependencyInjection\ContainerBuilder;
2117
use Symfony\Component\DependencyInjection\Definition;
@@ -135,8 +131,7 @@ private function doProcessValue($value, bool $isRoot = false)
135131
array_unshift($this->methodCalls, [$constructor, $value->getArguments()]);
136132
}
137133

138-
$checkAttributes = 80000 <= \PHP_VERSION_ID && !$value->hasTag('container.ignore_attributes');
139-
$this->methodCalls = $this->autowireCalls($reflectionClass, $isRoot, $checkAttributes);
134+
$this->methodCalls = $this->autowireCalls($reflectionClass, $isRoot);
140135

141136
if ($constructor) {
142137
[, $arguments] = array_shift($this->methodCalls);
@@ -153,7 +148,7 @@ private function doProcessValue($value, bool $isRoot = false)
153148
return $value;
154149
}
155150

156-
private function autowireCalls(\ReflectionClass $reflectionClass, bool $isRoot, bool $checkAttributes): array
151+
private function autowireCalls(\ReflectionClass $reflectionClass, bool $isRoot): array
157152
{
158153
$this->decoratedId = null;
159154
$this->decoratedClass = null;
@@ -182,7 +177,7 @@ private function autowireCalls(\ReflectionClass $reflectionClass, bool $isRoot,
182177
}
183178
}
184179

185-
$arguments = $this->autowireMethod($reflectionMethod, $arguments, $checkAttributes, $i);
180+
$arguments = $this->autowireMethod($reflectionMethod, $arguments, $i);
186181

187182
if ($arguments !== $call[1]) {
188183
$this->methodCalls[$i][1] = $arguments;
@@ -225,7 +220,7 @@ private function autowireCalls(\ReflectionClass $reflectionClass, bool $isRoot,
225220
*
226221
* @throws AutowiringFailedException
227222
*/
228-
private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, array $arguments, bool $checkAttributes, int $methodIndex): array
223+
private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, array $arguments, int $methodIndex): array
229224
{
230225
$class = $reflectionMethod instanceof \ReflectionMethod ? $reflectionMethod->class : $this->currentId;
231226
$method = $reflectionMethod->name;
@@ -244,26 +239,6 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a
244239

245240
$type = ProxyHelper::getTypeHint($reflectionMethod, $parameter, true);
246241

247-
if ($checkAttributes) {
248-
foreach ($parameter->getAttributes() as $attribute) {
249-
if (TaggedIterator::class === $attribute->getName()) {
250-
$attribute = $attribute->newInstance();
251-
$arguments[$index] = new TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute);
252-
break;
253-
}
254-
255-
if (TaggedLocator::class === $attribute->getName()) {
256-
$attribute = $attribute->newInstance();
257-
$arguments[$index] = new ServiceLocatorArgument(new TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, null, true));
258-
break;
259-
}
260-
}
261-
262-
if ('' !== ($arguments[$index] ?? '')) {
263-
continue;
264-
}
265-
}
266-
267242
if (!$type) {
268243
if (isset($arguments[$index])) {
269244
continue;

src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public function __construct()
6262
new AutowireRequiredMethodsPass(),
6363
new AutowireRequiredPropertiesPass(),
6464
new ResolveBindingsPass(),
65+
new ServiceLocatorTagPass(),
6566
new DecoratorServicePass(),
6667
new CheckDefinitionValidityPass(),
6768
new AutowirePass(false),
68-
new ServiceLocatorTagPass(),
6969
new ResolveTaggedIteratorArgumentPass(),
7070
new ResolveServiceSubscribersPass(),
7171
new ResolveReferencesToAliasesPass(),

0 commit comments

Comments
 (0)
0