From 8b8541e680ebe31304b76dbd63dd28da1320ec98 Mon Sep 17 00:00:00 2001 From: Daniel Bannert Date: Wed, 21 Mar 2018 00:37:33 +0100 Subject: [PATCH 1/2] [PHPunit] suite variable should be used --- src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php index 699d4bde35..1d29a88441 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php @@ -36,6 +36,6 @@ class CoverageListenerForV7 implements TestListener public function startTestSuite(TestSuite $suite): void { - $this->trait->startTest($test); + $this->trait->startTest($suite); } } From 5e922db4de0c25c9cc062508f43afc37a5608449 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 22 Mar 2018 11:04:59 +0100 Subject: [PATCH 2/2] [DI] Dont tell about autoregistration in strict autowiring mode --- .../Compiler/AutowirePass.php | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 59fa1b502c..b29bba5efd 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -30,7 +30,7 @@ class AutowirePass extends AbstractRecursivePass { private $definedTypes = array(); private $types; - private $ambiguousServiceTypes = array(); + private $ambiguousServiceTypes; private $autowired = array(); private $lastFailure; private $throwOnAutowiringException; @@ -71,7 +71,7 @@ class AutowirePass extends AbstractRecursivePass } finally { $this->definedTypes = array(); $this->types = null; - $this->ambiguousServiceTypes = array(); + $this->ambiguousServiceTypes = null; $this->autowired = array(); } } @@ -286,7 +286,7 @@ class AutowirePass extends AbstractRecursivePass } if (null === $this->types) { - $this->populateAvailableTypes(); + $this->populateAvailableTypes($this->strictMode); } if (isset($this->definedTypes[$type])) { @@ -322,12 +322,15 @@ class AutowirePass extends AbstractRecursivePass /** * Populates the list of available types. */ - private function populateAvailableTypes() + private function populateAvailableTypes($onlyAutowiringTypes = false) { $this->types = array(); + if (!$onlyAutowiringTypes) { + $this->ambiguousServiceTypes = array(); + } foreach ($this->container->getDefinitions() as $id => $definition) { - $this->populateAvailableType($id, $definition); + $this->populateAvailableType($id, $definition, $onlyAutowiringTypes); } } @@ -337,7 +340,7 @@ class AutowirePass extends AbstractRecursivePass * @param string $id * @param Definition $definition */ - private function populateAvailableType($id, Definition $definition) + private function populateAvailableType($id, Definition $definition, $onlyAutowiringTypes) { // Never use abstract services if ($definition->isAbstract()) { @@ -350,6 +353,10 @@ class AutowirePass extends AbstractRecursivePass unset($this->ambiguousServiceTypes[$type]); } + if ($onlyAutowiringTypes) { + return; + } + if (preg_match('/^\d+_[^~]++~[._a-zA-Z\d]{7}$/', $id) || $definition->isDeprecated() || !$reflectionClass = $this->container->getReflectionClass($definition->getClass(), false)) { return; } @@ -479,12 +486,15 @@ class AutowirePass extends AbstractRecursivePass if ($message = $this->getAliasesSuggestionForType($type = $reference->getType())) { return ' '.$message; } + if (null === $this->ambiguousServiceTypes) { + $this->populateAvailableTypes(); + } if (isset($this->ambiguousServiceTypes[$type])) { $message = sprintf('one of these existing services: "%s"', implode('", "', $this->ambiguousServiceTypes[$type])); } elseif (isset($this->types[$type])) { $message = sprintf('the existing "%s" service', $this->types[$type]); - } elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered()) { + } elseif ($reference->getRequiringClass() && !$reference->canBeAutoregistered() && !$this->strictMode) { return ' It cannot be auto-registered because it is from a different root namespace.'; } else { return;