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

Skip to content

Commit 9131bd1

Browse files
Merge branch '4.0'
* 4.0: [DI] Dont tell about autoregistration in strict autowiring mode [DI] Cleanup remainings from autoregistration [Process] Remove a useless cast [PHPunit] suite variable should be used
2 parents bbeca51 + 0c8ca6a commit 9131bd1

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFo
3636

3737
public function startTestSuite(TestSuite $suite): void
3838
{
39-
$this->trait->startTest($test);
39+
$this->trait->startTest($suite);
4040
}
4141
}

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

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
class AutowirePass extends AbstractRecursivePass
2929
{
3030
private $types;
31-
private $ambiguousServiceTypes = array();
32-
private $autowired = array();
31+
private $ambiguousServiceTypes;
3332
private $lastFailure;
3433
private $throwOnAutowiringException;
3534
private $decoratedClass;
@@ -53,8 +52,7 @@ public function process(ContainerBuilder $container)
5352
parent::process($container);
5453
} finally {
5554
$this->types = null;
56-
$this->ambiguousServiceTypes = array();
57-
$this->autowired = array();
55+
$this->ambiguousServiceTypes = null;
5856
$this->decoratedClass = null;
5957
$this->decoratedId = null;
6058
$this->methodCalls = null;
@@ -85,7 +83,7 @@ protected function processValue($value, $isRoot = false)
8583
private function doProcessValue($value, $isRoot = false)
8684
{
8785
if ($value instanceof TypedReference) {
88-
if ($ref = $this->getAutowiredReference($value, $value->getRequiringClass() ? sprintf('for "%s" in "%s"', $value->getType(), $value->getRequiringClass()) : '')) {
86+
if ($ref = $this->getAutowiredReference($value)) {
8987
return $ref;
9088
}
9189
$this->container->log($this, $this->createTypeNotFoundMessage($value, 'it'));
@@ -210,7 +208,7 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a
210208
}
211209

212210
$getValue = function () use ($type, $parameter, $class, $method) {
213-
if (!$value = $this->getAutowiredReference($ref = new TypedReference($type, $type, !$parameter->isOptional() ? $class : ''), 'for '.sprintf('argument "$%s" of method "%s()"', $parameter->name, $class.'::'.$method))) {
211+
if (!$value = $this->getAutowiredReference($ref = new TypedReference($type, $type, !$parameter->isOptional() ? $class : ''))) {
214212
$failureMessage = $this->createTypeNotFoundMessage($ref, sprintf('argument "$%s" of method "%s()"', $parameter->name, $class !== $this->currentId ? $class.'::'.$method : $method));
215213

216214
if ($parameter->isDefaultValueAvailable()) {
@@ -265,30 +263,14 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a
265263
/**
266264
* @return TypedReference|null A reference to the service matching the given type, if any
267265
*/
268-
private function getAutowiredReference(TypedReference $reference, $deprecationMessage)
266+
private function getAutowiredReference(TypedReference $reference)
269267
{
270268
$this->lastFailure = null;
271269
$type = $reference->getType();
272270

273271
if ($type !== (string) $reference || ($this->container->has($type) && !$this->container->findDefinition($type)->isAbstract())) {
274272
return $reference;
275273
}
276-
277-
if (!$reference->canBeAutoregistered()) {
278-
return;
279-
}
280-
281-
if (null === $this->types) {
282-
$this->populateAvailableTypes();
283-
}
284-
285-
if (isset($this->types[$type]) || isset($this->ambiguousServiceTypes[$type])) {
286-
return;
287-
}
288-
289-
if (isset($this->autowired[$type])) {
290-
return $this->autowired[$type] ? new TypedReference($this->autowired[$type], $type) : null;
291-
}
292274
}
293275

294276
/**
@@ -297,6 +279,7 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
297279
private function populateAvailableTypes()
298280
{
299281
$this->types = array();
282+
$this->ambiguousServiceTypes = array();
300283

301284
foreach ($this->container->getDefinitions() as $id => $definition) {
302285
$this->populateAvailableType($id, $definition);
@@ -392,6 +375,9 @@ private function createTypeAlternatives(TypedReference $reference)
392375
if ($message = $this->getAliasesSuggestionForType($type = $reference->getType())) {
393376
return ' '.$message;
394377
}
378+
if (null === $this->ambiguousServiceTypes) {
379+
$this->populateAvailableTypes();
380+
}
395381

396382
$servicesAndAliases = $this->container->getServiceIds();
397383
if (!$this->container->has($type) && false !== $key = array_search(strtolower($type), array_map('strtolower', $servicesAndAliases))) {
@@ -400,8 +386,6 @@ private function createTypeAlternatives(TypedReference $reference)
400386
$message = sprintf('one of these existing services: "%s"', implode('", "', $this->ambiguousServiceTypes[$type]));
401387
} elseif (isset($this->types[$type])) {
402388
$message = sprintf('the existing "%s" service', $this->types[$type]);
403-
} elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered()) {
404-
return ' It cannot be auto-registered because it is from a different root namespace.';
405389
} else {
406390
return;
407391
}

src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ public function provideNotWireableCalls()
700700
{
701701
return array(
702702
array('setNotAutowireable', 'Cannot autowire service "foo": argument "$n" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setNotAutowireable()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\NotARealClass" but this class was not found.'),
703-
array('setDifferentNamespace', 'Cannot autowire service "foo": argument "$n" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setDifferentNamespace()" references class "stdClass" but no such service exists. It cannot be auto-registered because it is from a different root namespace.'),
703+
array('setDifferentNamespace', 'Cannot autowire service "foo": argument "$n" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setDifferentNamespace()" references class "stdClass" but no such service exists.'),
704704
array(null, 'Invalid service "foo": method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setProtectedMethod()" must be public.'),
705705
);
706706
}

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ private function doSignal(int $signal, bool $throwException): bool
14491449
}
14501450
}
14511451

1452-
$this->latestSignal = (int) $signal;
1452+
$this->latestSignal = $signal;
14531453
$this->fallbackStatus['signaled'] = true;
14541454
$this->fallbackStatus['exitcode'] = -1;
14551455
$this->fallbackStatus['termsig'] = $this->latestSignal;

0 commit comments

Comments
 (0)