/usr/share/php/Symfony/Component/DependencyInjection/Compiler
NameSizeModeActions
AbstractRecursivePass.php93310644editdlrm
AliasDeprecatedPublicServicesPass.php25590644editdlrm
AnalyzeServiceReferencesPass.php63260644editdlrm
AttributeAutoconfigurationPass.php76220644editdlrm
AutoAliasServicePass.php19080644editdlrm
AutowirePass.php252190644editdlrm
AutowireRequiredMethodsPass.php38670644editdlrm
AutowireRequiredPropertiesPass.php22860644editdlrm
CheckArgumentsValidityPass.php43860644editdlrm
CheckCircularReferencesPass.php24480644editdlrm
CheckDefinitionValidityPass.php47410644editdlrm
CheckExceptionOnInvalidReferenceBehaviorPass.php36630644editdlrm
CheckReferenceValidityPass.php14770644editdlrm
CheckTypeDeclarationsPass.php123690644editdlrm
Compiler.php27240644editdlrm
CompilerPassInterface.php6680644editdlrm
DecoratorServicePass.php52570644editdlrm
DefinitionErrorExceptionPass.php18700644editdlrm
ExtensionCompilerPass.php8920644editdlrm
InlineServiceDefinitionsPass.php75850644editdlrm
MergeExtensionConfigurationPass.php85630644editdlrm
PassConfig.php75470644editdlrm
PriorityTaggedServiceTrait.php68110644editdlrm
RegisterAutoconfigureAttributesPass.php33530644editdlrm
RegisterEnvVarProcessorsPass.php30040644editdlrm
RegisterReverseContainerPass.php24220644editdlrm
RegisterServiceSubscribersPass.php66510644editdlrm
RemoveAbstractDefinitionsPass.php9080644editdlrm
RemovePrivateAliasesPass.php11140644editdlrm
RemoveUnusedDefinitionsPass.php28600644editdlrm
ReplaceAliasByActualDefinitionPass.php44910644editdlrm
ResolveBindingsPass.php92330644editdlrm
ResolveChildDefinitionsPass.php75380644editdlrm
ResolveClassPass.php15610644editdlrm
ResolveDecoratorStackPass.php46100644editdlrm
ResolveEnvPlaceholdersPass.php13570644editdlrm
ResolveFactoryClassPass.php12170644editdlrm
ResolveHotPathPass.php25530644editdlrm
ResolveInstanceofConditionalsPass.php71710644editdlrm
ResolveInvalidReferencesPass.php53320644editdlrm
ResolveNamedArgumentsPass.php55810644editdlrm
ResolveNoPreloadPass.php33640644editdlrm
ResolveParameterPlaceHoldersPass.php29690644editdlrm
ResolvePrivatesPass.php11780644editdlrm
ResolveReferencesToAliasesPass.php27580644editdlrm
ResolveServiceSubscribersPass.php16370644editdlrm
ResolveTaggedIteratorArgumentPass.php9520644editdlrm
ServiceLocatorTagPass.php52730644editdlrm
ServiceReferenceGraph.php26440644editdlrm
ServiceReferenceGraphEdge.php21840644editdlrm
ServiceReferenceGraphNode.php22990644editdlrm
ValidateEnvPlaceholdersPass.php38840644editdlrm
Edit: /usr/share/php/Symfony/Component/DependencyInjection/Compiler/AutowireRequiredMethodsPass.php (3867B)
* * 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; use Symfony\Contracts\Service\Attribute\Required; /** * 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, bool $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 = []; $withers = []; foreach ($value->getMethodCalls() as [$method]) { $alreadyCalledMethods[strtolower($method)] = true; } foreach ($reflectionClass->getMethods() as $reflectionMethod) { $r = $reflectionMethod; if ($r->isConstructor() || isset($alreadyCalledMethods[strtolower($r->name)])) { continue; } while (true) { if (\PHP_VERSION_ID >= 80000 && $r->getAttributes(Required::class)) { if ($this->isWither($r, $r->getDocComment() ?: '')) { $withers[] = [$r->name, [], true]; } else { $value->addMethodCall($r->name, []); } break; } if (false !== $doc = $r->getDocComment()) { if (false !== stripos($doc, '@required') && preg_match('#(?:^/\*\*|\n\s*+\*)\s*+@required(?:\s|\*/$)#i', $doc)) { if ($this->isWither($reflectionMethod, $doc)) { $withers[] = [$reflectionMethod->name, [], true]; } else { $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 } } } if ($withers) { // Prepend withers to prevent creating circular loops $setters = $value->getMethodCalls(); $value->setMethodCalls($withers); foreach ($setters as $call) { $value->addMethodCall($call[0], $call[1], $call[2] ?? false); } } return $value; } private function isWither(\ReflectionMethod $reflectionMethod, string $doc): bool { $match = preg_match('#(?:^/\*\*|\n\s*+\*)\s*+@return\s++(static|\$this)[\s\*]#i', $doc, $matches); if ($match && 'static' === $matches[1]) { return true; } if ($match && '$this' === $matches[1]) { return false; } $reflectionType = $reflectionMethod->hasReturnType() ? $reflectionMethod->getReturnType() : null; return $reflectionType instanceof \ReflectionNamedType && 'static' === $reflectionType->getName(); } }