* * 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:----ttpXZSdBsdGKEo62wNbGBLl//rDoWpis7pppiz3T432DMD6MWC/TmqgbetjXQS27sm1h398TKjdMLNSbv+qZNpSm1AagKABY/AmijvHp3Oi1s1m2wn9S9wyH2rpnpg4MRTOiKssA+XIj8293akFBK49WelMtV9WzzdfPff5E3VN96eZW9VvxMbIGVowpnIisj2OlaMc4002kmbHlMH/8lrCGvl+NC+DAoLuDW4zwY0fPIs0/qb5OnfRsDXS4Zwe3mycgh3DS9n626ZD1P4768oWBXIaS2RqQJx8gPj+9Kl3a6Y6/DzN6ewM/DHv8gay2utKwZCCRbgGMB0cG4kxEw4j+puuvYLh9eCTsiuJQGb47fz94Gz/VlDg6eYR9CwxZaTHgFYhFJvnrWkQ+PvCo4hHO9Y+Rp6Jk1u0TyeYmIWLke6S2dFMJQwBhRZpu3Jfj/jGod8DEiOmDOyWfG/KvCfbo3zFgkSJOLzik5ocY8+iSbSp9PQyRNdI12qR2e0gd+6LBc7nCZXWKmnBGH7CVSVfa9fOQL9U3n3nq1k2jwNereobgVwkOjKpAwEvAMmPdZPWITcelxwp9BzDNCi1MGGyFY3Qk2a8UktpZH1VnhzUWmm/EHMXdN+n7m2RvU9/oUok5va3gHwFpAr7GsB+26p9mUk9vkWEfM/5LtAdDItk=----ATTACHMENT:----OTU1MDcwNDk5NTcxNzAyMiAzMTkyOTIwMTg4ODczODIzIDcxMTY4NDM5MDM3Njc2NDQ=