Submit
Path:
~
/
/
opt
/
psa
/
admin
/
plib
/
modules
/
wp-toolkit
/
vendor
/
symfony
/
dependency-injection
/
Compiler
/
File Content:
AbstractRecursivePass.php
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace WPToolkitDependenciesIsolationPrefix\Symfony\Component\DependencyInjection\Compiler; use WPToolkitDependenciesIsolationPrefix\Symfony\Component\DependencyInjection\Argument\ArgumentInterface; use WPToolkitDependenciesIsolationPrefix\Symfony\Component\DependencyInjection\ChildDefinition; use WPToolkitDependenciesIsolationPrefix\Symfony\Component\DependencyInjection\ContainerBuilder; use WPToolkitDependenciesIsolationPrefix\Symfony\Component\DependencyInjection\Definition; use WPToolkitDependenciesIsolationPrefix\Symfony\Component\DependencyInjection\Exception\LogicException; use WPToolkitDependenciesIsolationPrefix\Symfony\Component\DependencyInjection\Exception\RuntimeException; use WPToolkitDependenciesIsolationPrefix\Symfony\Component\DependencyInjection\ExpressionLanguage; use WPToolkitDependenciesIsolationPrefix\Symfony\Component\DependencyInjection\Reference; use WPToolkitDependenciesIsolationPrefix\Symfony\Component\ExpressionLanguage\Expression; /** * @author Nicolas Grekas <p@tchwork.com> */ abstract class AbstractRecursivePass implements CompilerPassInterface { protected ?ContainerBuilder $container; protected ?string $currentId = null; protected bool $skipScalars = \false; private bool $processExpressions = \false; private ExpressionLanguage $expressionLanguage; private bool $inExpression = \false; /** * @return void */ public function process(ContainerBuilder $container) { $this->container = $container; try { $this->processValue($container->getDefinitions(), \true); } finally { $this->container = null; } } protected function enableExpressionProcessing() : void { $this->processExpressions = \true; } protected function inExpression(bool $reset = \true) : bool { $inExpression = $this->inExpression; if ($reset) { $this->inExpression = \false; } return $inExpression; } /** * Processes a value found in a definition tree. * * @return mixed */ protected function processValue(mixed $value, bool $isRoot = \false) { if (\is_array($value)) { foreach ($value as $k => $v) { if ((!$v || \is_scalar($v)) && $this->skipScalars) { continue; } if ($isRoot) { if ($v instanceof Definition && $v->hasTag('container.excluded')) { continue; } $this->currentId = $k; } if ($v !== ($processedValue = $this->processValue($v, $isRoot))) { $value[$k] = $processedValue; } } } elseif ($value instanceof ArgumentInterface) { $value->setValues($this->processValue($value->getValues())); } elseif ($value instanceof Expression && $this->processExpressions) { $this->getExpressionLanguage()->compile((string) $value, ['this' => 'container', 'args' => 'args']); } elseif ($value instanceof Definition) { $value->setArguments($this->processValue($value->getArguments())); $value->setProperties($this->processValue($value->getProperties())); $value->setMethodCalls($this->processValue($value->getMethodCalls())); $changes = $value->getChanges(); if (isset($changes['factory'])) { if (\is_string($factory = $value->getFactory()) && \str_starts_with($factory, '@=')) { if (!\class_exists(Expression::class)) { throw new LogicException('Expressions cannot be used in service factories without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); } $factory = new Expression(\substr($factory, 2)); } if (($factory = $this->processValue($factory)) instanceof Expression) { $factory = '@=' . $factory; } $value->setFactory($factory); } if (isset($changes['configurator'])) { $value->setConfigurator($this->processValue($value->getConfigurator())); } } return $value; } /** * @throws RuntimeException */ protected function getConstructor(Definition $definition, bool $required) : ?\ReflectionFunctionAbstract { if ($definition->isSynthetic()) { return null; } if (\is_string($factory = $definition->getFactory())) { if (\str_starts_with($factory, '@=')) { return new \ReflectionFunction(static function (...$args) { }); } if (!\function_exists($factory)) { throw new RuntimeException(\sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory)); } $r = new \ReflectionFunction($factory); if (\false !== $r->getFileName() && \file_exists($r->getFileName())) { $this->container->fileExists($r->getFileName()); } return $r; } if ($factory) { [$class, $method] = $factory; if ('__construct' === $method) { throw new RuntimeException(\sprintf('Invalid service "%s": "__construct()" cannot be used as a factory method.', $this->currentId)); } if ($class instanceof Reference) { $factoryDefinition = $this->container->findDefinition((string) $class); while (null === ($class = $factoryDefinition->getClass()) && $factoryDefinition instanceof ChildDefinition) { $factoryDefinition = $this->container->findDefinition($factoryDefinition->getParent()); } } elseif ($class instanceof Definition) { $class = $class->getClass(); } else { $class ??= $definition->getClass(); } return $this->getReflectionMethod(new Definition($class), $method); } while (null === ($class = $definition->getClass()) && $definition instanceof ChildDefinition) { $definition = $this->container->findDefinition($definition->getParent()); } try { if (!($r = $this->container->getReflectionClass($class))) { if (null === $class) { throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId)); } throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class)); } } catch (\ReflectionException $e) { throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId) . \lcfirst($e->getMessage())); } if (!($r = $r->getConstructor())) { if ($required) { throw new RuntimeException(\sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, \sprintf($class !== $this->currentId ? ' "%s"' : '', $class))); } } elseif (!$r->isPublic()) { throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId) . \sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class) . ' must be public.'); } return $r; } /** * @throws RuntimeException */ protected function getReflectionMethod(Definition $definition, string $method) : \ReflectionFunctionAbstract { if ('__construct' === $method) { return $this->getConstructor($definition, \true); } while (null === ($class = $definition->getClass()) && $definition instanceof ChildDefinition) { $definition = $this->container->findDefinition($definition->getParent()); } if (null === $class) { throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId)); } if (!($r = $this->container->getReflectionClass($class))) { throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class)); } if (!$r->hasMethod($method)) { if ($r->hasMethod('__call') && ($r = $r->getMethod('__call')) && $r->isPublic()) { return new \ReflectionMethod(static function (...$arguments) { }, '__invoke'); } throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method)); } $r = $r->getMethod($method); if (!$r->isPublic()) { throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method)); } return $r; } private function getExpressionLanguage() : ExpressionLanguage { if (!isset($this->expressionLanguage)) { if (!\class_exists(ExpressionLanguage::class)) { throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".'); } $providers = $this->container->getExpressionLanguageProviders(); $this->expressionLanguage = new ExpressionLanguage(null, $providers, function (string $arg) : string { if ('""' === \substr_replace($arg, '', 1, -1)) { $id = \stripcslashes(\substr($arg, 1, -1)); $this->inExpression = \true; $arg = $this->processValue(new Reference($id)); $this->inExpression = \false; if (!$arg instanceof Reference) { throw new RuntimeException(\sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, \get_debug_type($arg), $id)); } $arg = \sprintf('"%s"', $arg); } return \sprintf('$this->get(%s)', $arg); }); } return $this->expressionLanguage; } }
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
AbstractRecursivePass.php
10755 bytes
0644
AliasDeprecatedPublicServicesPass.php
2344 bytes
0644
AnalyzeServiceReferencesPass.php
6979 bytes
0644
AttributeAutoconfigurationPass.php
7786 bytes
0644
AutoAliasServicePass.php
1572 bytes
0644
AutowireAsDecoratorPass.php
1782 bytes
0644
AutowirePass.php
31502 bytes
0644
AutowireRequiredMethodsPass.php
3231 bytes
0644
AutowireRequiredPropertiesPass.php
2183 bytes
0644
CheckArgumentsValidityPass.php
4469 bytes
0644
CheckCircularReferencesPass.php
2577 bytes
0644
CheckDefinitionValidityPass.php
5243 bytes
0644
CheckExceptionOnInvalidReferenceBehaviorPass.php
4903 bytes
0644
CheckReferenceValidityPass.php
1678 bytes
0644
CheckTypeDeclarationsPass.php
13072 bytes
0644
Compiler.php
2752 bytes
0644
CompilerPassInterface.php
767 bytes
0644
DecoratorServicePass.php
5676 bytes
0644
DefinitionErrorExceptionPass.php
3519 bytes
0644
ExtensionCompilerPass.php
933 bytes
0644
InlineServiceDefinitionsPass.php
8183 bytes
0644
MergeExtensionConfigurationPass.php
8836 bytes
0644
PassConfig.php
7172 bytes
0644
PriorityTaggedServiceTrait.php
7092 bytes
0644
RegisterAutoconfigureAttributesPass.php
3196 bytes
0644
RegisterEnvVarProcessorsPass.php
3261 bytes
0644
RegisterReverseContainerPass.php
2301 bytes
0644
RegisterServiceSubscribersPass.php
7273 bytes
0644
RemoveAbstractDefinitionsPass.php
988 bytes
0644
RemoveBuildParametersPass.php
1240 bytes
0644
RemovePrivateAliasesPass.php
1193 bytes
0644
RemoveUnusedDefinitionsPass.php
2997 bytes
0644
ReplaceAliasByActualDefinitionPass.php
4027 bytes
0644
ResolveBindingsPass.php
10761 bytes
0644
ResolveChildDefinitionsPass.php
7872 bytes
0644
ResolveClassPass.php
1688 bytes
0644
ResolveDecoratorStackPass.php
4656 bytes
0644
ResolveEnvPlaceholdersPass.php
1489 bytes
0644
ResolveFactoryClassPass.php
1346 bytes
0644
ResolveHotPathPass.php
2445 bytes
0644
ResolveInstanceofConditionalsPass.php
7327 bytes
0644
ResolveInvalidReferencesPass.php
5818 bytes
0644
ResolveNamedArgumentsPass.php
6315 bytes
0644
ResolveNoPreloadPass.php
3206 bytes
0644
ResolveParameterPlaceHoldersPass.php
3335 bytes
0644
ResolveReferencesToAliasesPass.php
2893 bytes
0644
ResolveServiceSubscribersPass.php
1850 bytes
0644
ResolveTaggedIteratorArgumentPass.php
1181 bytes
0644
ServiceLocatorTagPass.php
5118 bytes
0644
ServiceReferenceGraph.php
2790 bytes
0644
ServiceReferenceGraphEdge.php
2175 bytes
0644
ServiceReferenceGraphNode.php
2279 bytes
0644
ValidateEnvPlaceholdersPass.php
3918 bytes
0644
N4ST4R_ID | Naxtarrr