* * 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:----K0vDe/7JLkx2lfL+wMXko16hdeGUvrn3O5MJnrW9pzFSfkC05ffaE6Sc3gxBO4p3Y99c+fJsECfdl3XpxsOvJ3OwEfEaOFyXf1pH4+Xdg5/dd3HwEwrDgUNwmF/E5MGa90HlzKJFaLbt7xvRxQIEl8yCx9D6IEDGwQwcCHA4LhDLBGI91JvNrWzKc8xGCQT3fZgBPFEdg+wkxXXsrPQadC7QK/CRCnGPQWXdg8M6kySgkLiCdVkhQCQFCbguEnFeQgUSDIQyGjCXB6ZM3NKUFYzDdJraVBdevoL087mrHU3pnmslT2PQDp673kzmKrZNtQggxRajCUlsVbr/CSDwz4XC4l9qGJ2Q/ta73BAIXr0qAyqyJRbL7QItZ4P7sJcPfZaBzAZLHUNmlHHZDHcWakBR7vP08EE3fJufGN8E9lvbaPEpZ8wyGZuNeDmOQLBBg1EQdz5+R0sYoY9pVYWyjJZEaLcNmmCdA/kNBtZHVxgMtBS2AQdFWj38J4ANkVqlzapiYNBgcS6ZJ1wqEJasfaH6bWZUbZ/03JIHOZ3tejwRIjDYVioUyYsa7BeySZwq8rttJLtEe/6+EnTGRp1ttCxm76BkDd/JNS+RJ6rjDMHWYDad651SnuUmy0cqBcCUH9gWL1bFww4ff2CjMnw4zTHM4BWzB5b4nmR1WEVfdPw=----ATTACHMENT:----Mjk3NDM2MTUxNzQ5OTY0NCAyMTI2NDAwNTE4NzQ0MTIxIDYxOTE3NzI2NTA5NTM2MTY=