[DI] Add getter injection

by @nicolas-grekas

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

curl https://fabbot.io/patch/symfony/symfony/20973/cb498580d107051a5b7ab1ee7c8c88206165879f/cs.diff | patch -p0
diff -ru src/Symfony/Component/DependencyInjection/ContainerBuilder.php src/Symfony/Component/DependencyInjection/ContainerBuilder.php
--- src/Symfony/Component/DependencyInjection/ContainerBuilder.php	2018-05-07 01:46:36.784261793 +0000
+++ src/Symfony/Component/DependencyInjection/ContainerBuilder.php	2018-05-07 01:46:41.313160477 +0000
@@ -474,7 +474,7 @@
      *
      * @throws BadMethodCallException When this ContainerBuilder is frozen
      */
-    public function merge(ContainerBuilder $container)
+    public function merge(self $container)
     {
         if ($this->isFrozen()) {
             throw new BadMethodCallException('Cannot merge on a frozen container.');
@@ -1306,7 +1306,7 @@
             foreach ($value as $v) {
                 $services = array_unique(array_merge($services, self::getServiceConditionals($v)));
             }
-        } elseif ($value instanceof Reference && $value->getInvalidBehavior() === ContainerInterface::IGNORE_ON_INVALID_REFERENCE) {
+        } elseif ($value instanceof Reference && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) {
             $services[] = (string) $value;
         }
 
diff -ru src/Symfony/Component/DependencyInjection/Definition.php src/Symfony/Component/DependencyInjection/Definition.php
--- src/Symfony/Component/DependencyInjection/Definition.php	2018-05-07 01:46:36.918258796 +0000
+++ src/Symfony/Component/DependencyInjection/Definition.php	2018-05-07 01:46:40.450179783 +0000
@@ -61,7 +61,7 @@
      */
     public function setFactory($factory)
     {
-        if (is_string($factory) && strpos($factory, '::') !== false) {
+        if (is_string($factory) && false !== strpos($factory, '::')) {
             $factory = explode('::', $factory, 2);
         }
 
@@ -89,7 +89,7 @@
      *
      * @return $this
      *
-     * @throws InvalidArgumentException In case the decorated service id and the new decorated service id are equals.
+     * @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals
      */
     public function setDecoratedService($id, $renamedId = null, $priority = 0)
     {
@@ -597,7 +597,7 @@
      *
      * @return $this
      *
-     * @throws InvalidArgumentException When the message template is invalid.
+     * @throws InvalidArgumentException when the message template is invalid
      */
     public function setDeprecated($status = true, $template = null)
     {
@@ -650,7 +650,7 @@
      */
     public function setConfigurator($configurator)
     {
-        if (is_string($configurator) && strpos($configurator, '::') !== false) {
+        if (is_string($configurator) && false !== strpos($configurator, '::')) {
             $configurator = explode('::', $configurator, 2);
         }
 
diff -ru src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
--- src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php	2018-05-07 01:46:37.427247409 +0000
+++ src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php	2018-05-07 01:46:43.423113276 +0000
@@ -303,9 +303,9 @@
                 $element->setAttribute('type', 'service');
                 $element->setAttribute('id', (string) $value);
                 $behaviour = $value->getInvalidBehavior();
-                if ($behaviour == ContainerInterface::NULL_ON_INVALID_REFERENCE) {
+                if (ContainerInterface::NULL_ON_INVALID_REFERENCE == $behaviour) {
                     $element->setAttribute('on-invalid', 'null');
-                } elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) {
+                } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE == $behaviour) {
                     $element->setAttribute('on-invalid', 'ignore');
                 }
             } elseif ($value instanceof Definition) {
diff -ru src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
--- src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php	2018-05-07 01:46:37.830238394 +0000
+++ src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php	2018-05-07 01:46:44.912079967 +0000
@@ -515,7 +515,7 @@
     {
         $children = array();
         foreach ($node->childNodes as $child) {
-            if ($child instanceof \DOMElement && $child->localName === $name && $child->namespaceURI === self::NS) {
+            if ($child instanceof \DOMElement && $child->localName === $name && self::NS === $child->namespaceURI) {
                 $children[] = $child;
             }
         }
@@ -612,7 +612,7 @@
         }
 
         foreach ($alias->childNodes as $child) {
-            if ($child instanceof \DOMElement && $child->namespaceURI === self::NS) {
+            if ($child instanceof \DOMElement && self::NS === $child->namespaceURI) {
                 @trigger_error(sprintf('Using the element "%s" is deprecated for the service "%s" which is defined as an alias in "%s". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported elements.', $child->localName, $alias->getAttribute('id'), $file), E_USER_DEPRECATED);
             }
         }
@@ -655,7 +655,7 @@
     private function loadFromExtensions(\DOMDocument $xml)
     {
         foreach ($xml->documentElement->childNodes as $node) {
-            if (!$node instanceof \DOMElement || $node->namespaceURI === self::NS) {
+            if (!$node instanceof \DOMElement || self::NS === $node->namespaceURI) {
                 continue;
             }
 
diff -ru src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container29.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container29.php
--- src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container29.php	2018-05-07 01:46:38.696219021 +0000
+++ src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container29.php	2018-05-07 01:46:45.050076879 +0000
@@ -9,6 +9,7 @@
     abstract class Foo
     {
         abstract public function getPublic();
+
         abstract protected function getProtected();
 
         public function getSelf()

0
Common Typos

0
License Headers

0
Pull Request Contributor Headers

0
YAML Files Syntax

0
File Permissions