migration symfony 5 4 (#300)

* symfony 5.4 (diff dev)

* symfony 5.4 (working)

* symfony 5.4 (update autoload)

* symfony 5.4 (remove swiftmailer mailer implementation)

* symfony 5.4 (php doc and split Global accessor class)


### Impacted packages:

composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies

composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
bdalsass
2022-06-16 09:13:24 +02:00
committed by GitHub
parent abb13b70b9
commit 79da71ecf8
2178 changed files with 87439 additions and 59451 deletions

View File

@@ -11,7 +11,10 @@
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use Symfony\Component\Config\Loader\ParamConfigurator;
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Parameter;
@@ -20,20 +23,38 @@ use Symfony\Component\ExpressionLanguage\Expression;
abstract class AbstractConfigurator
{
const FACTORY = 'unknown';
public const FACTORY = 'unknown';
/**
* @var callable(mixed, bool $allowService)|null
*/
public static $valuePreProcessor;
/** @internal */
protected $definition;
public function __call($method, $args)
public function __call(string $method, array $args)
{
if (method_exists($this, 'set'.$method)) {
return \call_user_func_array([$this, 'set'.$method], $args);
return $this->{'set'.$method}(...$args);
}
throw new \BadMethodCallException(sprintf('Call to undefined method "%s::%s()".', static::class, $method));
}
/**
* @return array
*/
public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
/**
* Checks that a value is valid, optionally replacing Definition and Reference configurators by their configure value.
*
@@ -49,11 +70,17 @@ abstract class AbstractConfigurator
$value[$k] = static::processValue($v, $allowServices);
}
return $value;
return self::$valuePreProcessor ? (self::$valuePreProcessor)($value, $allowServices) : $value;
}
if (self::$valuePreProcessor) {
$value = (self::$valuePreProcessor)($value, $allowServices);
}
if ($value instanceof ReferenceConfigurator) {
return new Reference($value->id, $value->invalidBehavior);
$reference = new Reference($value->id, $value->invalidBehavior);
return $value instanceof ClosureReferenceConfigurator ? new ServiceClosureArgument($reference) : $reference;
}
if ($value instanceof InlineServiceConfigurator) {
@@ -63,6 +90,10 @@ abstract class AbstractConfigurator
return $def;
}
if ($value instanceof ParamConfigurator) {
return (string) $value;
}
if ($value instanceof self) {
throw new InvalidArgumentException(sprintf('"%s()" can be used only at the root of service configuration files.', $value::FACTORY));
}
@@ -76,12 +107,13 @@ abstract class AbstractConfigurator
case $value instanceof Definition:
case $value instanceof Expression:
case $value instanceof Parameter:
case $value instanceof AbstractArgument:
case $value instanceof Reference:
if ($allowServices) {
return $value;
}
}
throw new InvalidArgumentException(sprintf('Cannot use values of type "%s" in service configuration files.', \is_object($value) ? \get_class($value) : \gettype($value)));
throw new InvalidArgumentException(sprintf('Cannot use values of type "%s" in service configuration files.', get_debug_type($value)));
}
}