updated-packages
This commit is contained in:
@@ -12,9 +12,10 @@
|
||||
namespace Symfony\Component\HttpKernel\DependencyInjection;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Symfony\Component\Debug\DebugClassLoader;
|
||||
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\ErrorHandler\DebugClassLoader;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
/**
|
||||
@@ -54,16 +55,14 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
*
|
||||
* @param array $patterns The class patterns to expand
|
||||
* @param array $classes The existing classes to match against the patterns
|
||||
*
|
||||
* @return array A list of classes derivated from the patterns
|
||||
*/
|
||||
private function expandClasses(array $patterns, array $classes)
|
||||
private function expandClasses(array $patterns, array $classes): array
|
||||
{
|
||||
$expanded = array();
|
||||
$expanded = [];
|
||||
|
||||
// Explicit classes declared in the patterns are returned directly
|
||||
foreach ($patterns as $key => $pattern) {
|
||||
if ('\\' !== substr($pattern, -1) && false === strpos($pattern, '*')) {
|
||||
if (!str_ends_with($pattern, '\\') && !str_contains($pattern, '*')) {
|
||||
unset($patterns[$key]);
|
||||
$expanded[] = ltrim($pattern, '\\');
|
||||
}
|
||||
@@ -83,16 +82,16 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
return array_unique($expanded);
|
||||
}
|
||||
|
||||
private function getClassesInComposerClassMaps()
|
||||
private function getClassesInComposerClassMaps(): array
|
||||
{
|
||||
$classes = array();
|
||||
$classes = [];
|
||||
|
||||
foreach (spl_autoload_functions() as $function) {
|
||||
if (!\is_array($function)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($function[0] instanceof DebugClassLoader) {
|
||||
if ($function[0] instanceof DebugClassLoader || $function[0] instanceof LegacyDebugClassLoader) {
|
||||
$function = $function[0]->getClassLoader();
|
||||
}
|
||||
|
||||
@@ -104,16 +103,16 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
return array_keys($classes);
|
||||
}
|
||||
|
||||
private function patternsToRegexps($patterns)
|
||||
private function patternsToRegexps(array $patterns): array
|
||||
{
|
||||
$regexps = array();
|
||||
$regexps = [];
|
||||
|
||||
foreach ($patterns as $pattern) {
|
||||
// Escape user input
|
||||
$regex = preg_quote(ltrim($pattern, '\\'));
|
||||
|
||||
// Wildcards * and **
|
||||
$regex = strtr($regex, array('\\*\\*' => '.*?', '\\*' => '[^\\\\]*?'));
|
||||
$regex = strtr($regex, ['\\*\\*' => '.*?', '\\*' => '[^\\\\]*?']);
|
||||
|
||||
// If this class does not end by a slash, anchor the end
|
||||
if ('\\' !== substr($regex, -1)) {
|
||||
@@ -126,12 +125,12 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
return $regexps;
|
||||
}
|
||||
|
||||
private function matchAnyRegexps($class, $regexps)
|
||||
private function matchAnyRegexps(string $class, array $regexps): bool
|
||||
{
|
||||
$blacklisted = false !== strpos($class, 'Test');
|
||||
$isTest = str_contains($class, 'Test');
|
||||
|
||||
foreach ($regexps as $regex) {
|
||||
if ($blacklisted && false === strpos($regex, 'Test')) {
|
||||
if ($isTest && !str_contains($regex, 'Test')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,7 @@ class ControllerArgumentValueResolverPass implements CompilerPassInterface
|
||||
$id = (string) $resolverReference;
|
||||
$container->register("debug.$id", TraceableValueResolver::class)
|
||||
->setDecoratedService($id)
|
||||
->setArguments(array(new Reference("debug.$id.inner"), new Reference($this->traceableResolverStopwatch)));
|
||||
->setArguments([new Reference("debug.$id.inner"), new Reference($this->traceableResolverStopwatch)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ use Symfony\Component\DependencyInjection\Extension\Extension as BaseExtension;
|
||||
*/
|
||||
abstract class Extension extends BaseExtension
|
||||
{
|
||||
private $annotatedClasses = array();
|
||||
private $annotatedClasses = [];
|
||||
|
||||
/**
|
||||
* Gets the annotated classes to cache.
|
||||
|
@@ -41,7 +41,7 @@ class FragmentRendererPass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
$definition = $container->getDefinition($this->handlerService);
|
||||
$renderers = array();
|
||||
$renderers = [];
|
||||
foreach ($container->findTaggedServiceIds($this->rendererTag, true) as $id => $tags) {
|
||||
$def = $container->getDefinition($id);
|
||||
$class = $container->getParameterBag()->resolveValue($def->getClass());
|
||||
|
@@ -23,19 +23,19 @@ use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
|
||||
class LazyLoadingFragmentHandler extends FragmentHandler
|
||||
{
|
||||
private $container;
|
||||
private $initialized = array();
|
||||
private $initialized = [];
|
||||
|
||||
public function __construct(ContainerInterface $container, RequestStack $requestStack, bool $debug = false)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
parent::__construct($requestStack, array(), $debug);
|
||||
parent::__construct($requestStack, [], $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($uri, $renderer = 'inline', array $options = array())
|
||||
public function render($uri, $renderer = 'inline', array $options = [])
|
||||
{
|
||||
if (!isset($this->initialized[$renderer]) && $this->container->has($renderer)) {
|
||||
$this->addRenderer($this->container->get($renderer));
|
||||
|
@@ -32,7 +32,7 @@ class MergeExtensionConfigurationPass extends BaseMergeExtensionConfigurationPas
|
||||
{
|
||||
foreach ($this->extensions as $extension) {
|
||||
if (!\count($container->getExtensionConfig($extension))) {
|
||||
$container->loadFromExtension($extension, array());
|
||||
$container->loadFromExtension($extension, []);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,22 +34,24 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
private $resolverServiceId;
|
||||
private $controllerTag;
|
||||
private $controllerLocator;
|
||||
private $notTaggedControllerResolverServiceId;
|
||||
|
||||
public function __construct(string $resolverServiceId = 'argument_resolver.service', string $controllerTag = 'controller.service_arguments', string $controllerLocator = 'argument_resolver.controller_locator')
|
||||
public function __construct(string $resolverServiceId = 'argument_resolver.service', string $controllerTag = 'controller.service_arguments', string $controllerLocator = 'argument_resolver.controller_locator', string $notTaggedControllerResolverServiceId = 'argument_resolver.not_tagged_controller')
|
||||
{
|
||||
$this->resolverServiceId = $resolverServiceId;
|
||||
$this->controllerTag = $controllerTag;
|
||||
$this->controllerLocator = $controllerLocator;
|
||||
$this->notTaggedControllerResolverServiceId = $notTaggedControllerResolverServiceId;
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (false === $container->hasDefinition($this->resolverServiceId)) {
|
||||
if (false === $container->hasDefinition($this->resolverServiceId) && false === $container->hasDefinition($this->notTaggedControllerResolverServiceId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parameterBag = $container->getParameterBag();
|
||||
$controllers = array();
|
||||
$controllers = [];
|
||||
|
||||
foreach ($container->findTaggedServiceIds($this->controllerTag, true) as $id => $tags) {
|
||||
$def = $container->getDefinition($id);
|
||||
@@ -72,14 +74,14 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
$isContainerAware = $r->implementsInterface(ContainerAwareInterface::class) || is_subclass_of($class, AbstractController::class);
|
||||
|
||||
// get regular public methods
|
||||
$methods = array();
|
||||
$arguments = array();
|
||||
$methods = [];
|
||||
$arguments = [];
|
||||
foreach ($r->getMethods(\ReflectionMethod::IS_PUBLIC) as $r) {
|
||||
if ('setContainer' === $r->name && $isContainerAware) {
|
||||
continue;
|
||||
}
|
||||
if (!$r->isConstructor() && !$r->isDestructor() && !$r->isAbstract()) {
|
||||
$methods[strtolower($r->name)] = array($r, $r->getParameters());
|
||||
$methods[strtolower($r->name)] = [$r, $r->getParameters()];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,15 +91,15 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
$autowire = true;
|
||||
continue;
|
||||
}
|
||||
foreach (array('action', 'argument', 'id') as $k) {
|
||||
foreach (['action', 'argument', 'id'] as $k) {
|
||||
if (!isset($attributes[$k][0])) {
|
||||
throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "%s" %s for service "%s".', $k, $this->controllerTag, json_encode($attributes, JSON_UNESCAPED_UNICODE), $id));
|
||||
throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "%s" %s for service "%s".', $k, $this->controllerTag, json_encode($attributes, \JSON_UNESCAPED_UNICODE), $id));
|
||||
}
|
||||
}
|
||||
if (!isset($methods[$action = strtolower($attributes['action'])])) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid "action" attribute on tag "%s" for service "%s": no public "%s()" method found on class "%s".', $this->controllerTag, $id, $attributes['action'], $class));
|
||||
}
|
||||
list($r, $parameters) = $methods[$action];
|
||||
[$r, $parameters] = $methods[$action];
|
||||
$found = false;
|
||||
|
||||
foreach ($parameters as $p) {
|
||||
@@ -115,14 +117,14 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($methods as list($r, $parameters)) {
|
||||
foreach ($methods as [$r, $parameters]) {
|
||||
/** @var \ReflectionMethod $r */
|
||||
|
||||
// create a per-method map of argument-names to service/type-references
|
||||
$args = array();
|
||||
$args = [];
|
||||
foreach ($parameters as $p) {
|
||||
/** @var \ReflectionParameter $p */
|
||||
$type = ltrim($target = ProxyHelper::getTypeHint($r, $p), '\\');
|
||||
$type = ltrim($target = (string) ProxyHelper::getTypeHint($r, $p), '\\');
|
||||
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
|
||||
|
||||
if (isset($arguments[$r->name][$p->name])) {
|
||||
@@ -137,14 +139,14 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
} elseif (isset($bindings[$bindingName = $type.' $'.$p->name]) || isset($bindings[$bindingName = '$'.$p->name]) || isset($bindings[$bindingName = $type])) {
|
||||
$binding = $bindings[$bindingName];
|
||||
|
||||
list($bindingValue, $bindingId) = $binding->getValues();
|
||||
$binding->setValues(array($bindingValue, $bindingId, true));
|
||||
[$bindingValue, $bindingId, , $bindingType, $bindingFile] = $binding->getValues();
|
||||
$binding->setValues([$bindingValue, $bindingId, true, $bindingType, $bindingFile]);
|
||||
|
||||
if (!$bindingValue instanceof Reference) {
|
||||
$args[$p->name] = new Reference('.value.'.$container->hash($bindingValue));
|
||||
$container->register((string) $args[$p->name], 'mixed')
|
||||
->setFactory('current')
|
||||
->addArgument(array($bindingValue));
|
||||
->addArgument([$bindingValue]);
|
||||
} else {
|
||||
$args[$p->name] = $bindingValue;
|
||||
}
|
||||
@@ -152,6 +154,9 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
continue;
|
||||
} elseif (!$type || !$autowire || '\\' !== $target[0]) {
|
||||
continue;
|
||||
} elseif (is_subclass_of($type, \UnitEnum::class)) {
|
||||
// do not attempt to register enum typed arguments if not already present in bindings
|
||||
continue;
|
||||
} elseif (!$p->allowsNull()) {
|
||||
$invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE;
|
||||
}
|
||||
@@ -181,8 +186,17 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
}
|
||||
}
|
||||
|
||||
$container->getDefinition($this->resolverServiceId)
|
||||
->replaceArgument(0, $controllerLocatorRef = ServiceLocatorTagPass::register($container, $controllers));
|
||||
$controllerLocatorRef = ServiceLocatorTagPass::register($container, $controllers);
|
||||
|
||||
if ($container->hasDefinition($this->resolverServiceId)) {
|
||||
$container->getDefinition($this->resolverServiceId)
|
||||
->replaceArgument(0, $controllerLocatorRef);
|
||||
}
|
||||
|
||||
if ($container->hasDefinition($this->notTaggedControllerResolverServiceId)) {
|
||||
$container->getDefinition($this->notTaggedControllerResolverServiceId)
|
||||
->replaceArgument(0, $controllerLocatorRef);
|
||||
}
|
||||
|
||||
$container->setAlias($this->controllerLocator, (string) $controllerLocatorRef);
|
||||
}
|
||||
|
58
vendor/symfony/http-kernel/DependencyInjection/RegisterLocaleAwareServicesPass.php
vendored
Normal file
58
vendor/symfony/http-kernel/DependencyInjection/RegisterLocaleAwareServicesPass.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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 Symfony\Component\HttpKernel\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Register all services that have the "kernel.locale_aware" tag into the listener.
|
||||
*
|
||||
* @author Pierre Bobiet <pierrebobiet@gmail.com>
|
||||
*/
|
||||
class RegisterLocaleAwareServicesPass implements CompilerPassInterface
|
||||
{
|
||||
private $listenerServiceId;
|
||||
private $localeAwareTag;
|
||||
|
||||
public function __construct(string $listenerServiceId = 'locale_aware_listener', string $localeAwareTag = 'kernel.locale_aware')
|
||||
{
|
||||
$this->listenerServiceId = $listenerServiceId;
|
||||
$this->localeAwareTag = $localeAwareTag;
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition($this->listenerServiceId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$services = [];
|
||||
|
||||
foreach ($container->findTaggedServiceIds($this->localeAwareTag) as $id => $tags) {
|
||||
$services[] = new Reference($id);
|
||||
}
|
||||
|
||||
if (!$services) {
|
||||
$container->removeDefinition($this->listenerServiceId);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$container
|
||||
->getDefinition($this->listenerServiceId)
|
||||
->setArgument(0, new IteratorArgument($services))
|
||||
;
|
||||
}
|
||||
}
|
@@ -42,9 +42,9 @@ class RemoveEmptyControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
} else {
|
||||
// any methods listed for call-at-instantiation cannot be actions
|
||||
$reason = false;
|
||||
list($id, $action) = explode('::', $controller);
|
||||
[$id, $action] = explode('::', $controller);
|
||||
$controllerDef = $container->getDefinition($id);
|
||||
foreach ($controllerDef->getMethodCalls() as list($method)) {
|
||||
foreach ($controllerDef->getMethodCalls() as [$method]) {
|
||||
if (0 === strcasecmp($action, $method)) {
|
||||
$reason = sprintf('Removing method "%s" of service "%s" from controller candidates: the method is called at instantiation, thus cannot be an action.', $action, $id);
|
||||
break;
|
||||
|
@@ -39,20 +39,25 @@ class ResettableServicePass implements CompilerPassInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$services = $methods = array();
|
||||
$services = $methods = [];
|
||||
|
||||
foreach ($container->findTaggedServiceIds($this->tagName, true) as $id => $tags) {
|
||||
$services[$id] = new Reference($id, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE);
|
||||
$attributes = $tags[0];
|
||||
|
||||
if (!isset($attributes['method'])) {
|
||||
throw new RuntimeException(sprintf('Tag %s requires the "method" attribute to be set.', $this->tagName));
|
||||
foreach ($tags as $attributes) {
|
||||
if (!isset($attributes['method'])) {
|
||||
throw new RuntimeException(sprintf('Tag "%s" requires the "method" attribute to be set.', $this->tagName));
|
||||
}
|
||||
|
||||
if (!isset($methods[$id])) {
|
||||
$methods[$id] = [];
|
||||
}
|
||||
|
||||
$methods[$id][] = $attributes['method'];
|
||||
}
|
||||
|
||||
$methods[$id] = $attributes['method'];
|
||||
}
|
||||
|
||||
if (empty($services)) {
|
||||
if (!$services) {
|
||||
$container->removeAlias('services_resetter');
|
||||
$container->removeDefinition('services_resetter');
|
||||
|
||||
|
@@ -35,7 +35,9 @@ class ServicesResetter implements ResetInterface
|
||||
public function reset()
|
||||
{
|
||||
foreach ($this->resettableServices as $id => $service) {
|
||||
$service->{$this->resetMethods[$id]}();
|
||||
foreach ((array) $this->resetMethods[$id] as $resetMethod) {
|
||||
$service->$resetMethod();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user