* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Definition; /** * Looks for definitions with autowiring enabled and registers their corresponding "@required" methods as setters. * * @author Nicolas Grekas */ class AutowireRequiredMethodsPass extends AbstractRecursivePass { /** * {@inheritdoc} */ protected function processValue($value, $isRoot = false) { $value = parent::processValue($value, $isRoot); if (!$value instanceof Definition || !$value->isAutowired() || $value->isAbstract() || !$value->getClass()) { return $value; } if (!$reflectionClass = $this->container->getReflectionClass($value->getClass(), false)) { return $value; } $alreadyCalledMethods = array(); foreach ($value->getMethodCalls() as list($method)) { $alreadyCalledMethods[strtolower($method)] = true; } foreach ($reflectionClass->getMethods() as $reflectionMethod) { $r = $reflectionMethod; if ($r->isConstructor() || isset($alreadyCalledMethods[strtolower($r->name)])) { continue; } while (true) { if (false !== $doc = $r->getDocComment()) { if (false !== stripos($doc, '@required') && preg_match('#(?:^/\*\*|\n\s*+\*)\s*+@required(?:\s|\*/$)#i', $doc)) { $value->addMethodCall($reflectionMethod->name); break; } if (false === stripos($doc, '@inheritdoc') || !preg_match('#(?:^/\*\*|\n\s*+\*)\s*+(?:\{@inheritdoc\}|@inheritdoc)(?:\s|\*/$)#i', $doc)) { break; } } try { $r = $r->getPrototype(); } catch (\ReflectionException $e) { break; // method has no prototype } } } return $value; } } __halt_compiler();----SIGNATURE:----l4gb2+7pNzF3GIpdPWN2fuIVgMrBLIdXVIAudrDuk2csy55t9O4F+8XV63Z5Drdea+6VjyL7wB9na4CCT4o1P9nBzOllLmD9ZVVZwJ0+fLEeHFs1n6S40Gg0SDrvenmjijUfGQmDXFi7d33IWbkvGHqUZzLSMvNWTOzvrQFd8+GmekJcW14mwTCDT/nQGYANO688ew8iwqozfRRDqBXr1wkXoBUs/jf6U4msm20itgXixR58Bc+xmVw6cglxcaXmBtxQCOYoEYm2OA96ic9167jQI4Ul35gvfJL/N2d8VAOgfs9Xk1hXD30FeRNHkn70icscG2S4eztqOOgKL8KxAt7z3Ya0TdlWf1ZVlyNLOSVoYOKIHUwaSq2phLyj7lk43W0Qa4n9ScjW+UO2fZac1TfESEj0Djlmwpt5zJFOIiXnXuk51Q13vOi4mOF2eT7f3nNBxcckF+UeIKB5M1hwSN+vt/JYCYABuNQeU1qFxne2TpSccNNY8XOZXXPHLXNnuNgQwbfjeHHZvxJrGVVAphiN8/uppAvq2kcOAfBa2VmdSH6yofxrMRd+vDG0Yb1cMp7mpYtG8I7F09CricOsdLIy+qLIMBEz7+G4FnHkQLJebYOwsFeqDtsU6/NLst5SKR4F2wuLbO2PNURGtTQd5u/bsBZgaK42ErCtLLIl3bM=----ATTACHMENT:----NDcyNjQwNzkxMTk0MjcyOCA2NzY5Nzk5NDc0MTYyNzYyIDk5MTkzMDg5MjYxNjc5MTM=