@@ -120,14 +120,22 @@ private function completeDefinition($id, Definition $definition, array $autowire
120120 *
121121 * @param string $id
122122 * @param \ReflectionClass $reflectionClass
123- * @param string[] $autowiredMethods
123+ * @param string[] $configuredAutowiredMethods
124124 *
125125 * @return \ReflectionMethod[]
126126 */
127- private function getMethodsToAutowire ($ id , \ReflectionClass $ reflectionClass , array $ autowiredMethods )
127+ private function getMethodsToAutowire ($ id , \ReflectionClass $ reflectionClass , array $ configuredAutowiredMethods )
128128 {
129129 $ found = array ();
130130 $ regexList = array ();
131+
132+ // Always try to autowire the constructor
133+ if (in_array ('__construct ' , $ configuredAutowiredMethods , true )) {
134+ $ autowiredMethods = $ configuredAutowiredMethods ;
135+ } else {
136+ $ autowiredMethods = array_merge (array ('__construct ' ), $ configuredAutowiredMethods );
137+ }
138+
131139 foreach ($ autowiredMethods as $ pattern ) {
132140 $ regexList [] = '/^ ' .str_replace ('\* ' , '.* ' , preg_quote ($ pattern , '/ ' )).'$/i ' ;
133141 }
@@ -147,7 +155,7 @@ private function getMethodsToAutowire($id, \ReflectionClass $reflectionClass, ar
147155 }
148156 }
149157
150- if ($ notFound = array_diff ($ autowiredMethods , $ found )) {
158+ if ($ notFound = array_diff ($ configuredAutowiredMethods , $ found )) {
151159 $ compiler = $ this ->container ->getCompiler ();
152160 $ compiler ->addLogMessage ($ compiler ->getLoggingFormatter ()->formatUnusedAutowiringPatterns ($ this , $ id , $ notFound ));
153161 }
0 commit comments