mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 07:12:26 +02:00
N°8834 - Add compatibility with PHP 8.4 (#819)
* N°8834 - Add compatibility with PHP 8.4 * Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
@@ -43,18 +43,15 @@ abstract class AbstractConfigurator
|
||||
return $this->{'set'.$method}(...$args);
|
||||
}
|
||||
|
||||
throw new \BadMethodCallException(sprintf('Call to undefined method "%s::%s()".', static::class, $method));
|
||||
throw new \BadMethodCallException(\sprintf('Call to undefined method "%s::%s()".', static::class, $method));
|
||||
}
|
||||
|
||||
public function __sleep(): array
|
||||
public function __serialize(): array
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||
}
|
||||
@@ -98,7 +95,7 @@ abstract class AbstractConfigurator
|
||||
}
|
||||
|
||||
if ($value instanceof self) {
|
||||
throw new InvalidArgumentException(sprintf('"%s()" can be used only at the root of service configuration files.', $value::FACTORY));
|
||||
throw new InvalidArgumentException(\sprintf('"%s()" can be used only at the root of service configuration files.', $value::FACTORY));
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
@@ -118,6 +115,6 @@ abstract class AbstractConfigurator
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Cannot use values of type "%s" in service configuration files.', get_debug_type($value)));
|
||||
throw new InvalidArgumentException(\sprintf('Cannot use values of type "%s" in service configuration files.', get_debug_type($value)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ abstract class AbstractServiceConfigurator extends AbstractConfigurator
|
||||
protected $id;
|
||||
private array $defaultTags = [];
|
||||
|
||||
public function __construct(ServicesConfigurator $parent, Definition $definition, string $id = null, array $defaultTags = [])
|
||||
public function __construct(ServicesConfigurator $parent, Definition $definition, ?string $id = null, array $defaultTags = [])
|
||||
{
|
||||
$this->parent = $parent;
|
||||
$this->definition = $definition;
|
||||
@@ -42,7 +42,7 @@ abstract class AbstractServiceConfigurator extends AbstractConfigurator
|
||||
/**
|
||||
* Registers a service.
|
||||
*/
|
||||
final public function set(?string $id, string $class = null): ServiceConfigurator
|
||||
final public function set(?string $id, ?string $class = null): ServiceConfigurator
|
||||
{
|
||||
$this->__destruct();
|
||||
|
||||
@@ -106,7 +106,7 @@ abstract class AbstractServiceConfigurator extends AbstractConfigurator
|
||||
/**
|
||||
* Registers a service.
|
||||
*/
|
||||
final public function __invoke(string $id, string $class = null): ServiceConfigurator
|
||||
final public function __invoke(string $id, ?string $class = null): ServiceConfigurator
|
||||
{
|
||||
$this->__destruct();
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class ContainerConfigurator extends AbstractConfigurator
|
||||
private int $anonymousCount = 0;
|
||||
private ?string $env;
|
||||
|
||||
public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path, string $file, string $env = null)
|
||||
public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path, string $file, ?string $env = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->loader = $loader;
|
||||
@@ -52,13 +52,13 @@ class ContainerConfigurator extends AbstractConfigurator
|
||||
{
|
||||
if (!$this->container->hasExtension($namespace)) {
|
||||
$extensions = array_filter(array_map(fn (ExtensionInterface $ext) => $ext->getAlias(), $this->container->getExtensions()));
|
||||
throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $this->file, $namespace, $extensions ? implode('", "', $extensions) : 'none'));
|
||||
throw new InvalidArgumentException(\sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $this->file, $namespace, $extensions ? implode('", "', $extensions) : 'none'));
|
||||
}
|
||||
|
||||
$this->container->loadFromExtension($namespace, static::processValue($config));
|
||||
}
|
||||
|
||||
final public function import(string $resource, string $type = null, bool|string $ignoreErrors = false): void
|
||||
final public function import(string $resource, ?string $type = null, bool|string $ignoreErrors = false): void
|
||||
{
|
||||
$this->loader->setCurrentDir(\dirname($this->path));
|
||||
$this->loader->import($resource, $type, $ignoreErrors, $this->file);
|
||||
@@ -111,7 +111,7 @@ function service(string $serviceId): ReferenceConfigurator
|
||||
/**
|
||||
* Creates an inline service.
|
||||
*/
|
||||
function inline_service(string $class = null): InlineServiceConfigurator
|
||||
function inline_service(?string $class = null): InlineServiceConfigurator
|
||||
{
|
||||
return new InlineServiceConfigurator(new Definition($class));
|
||||
}
|
||||
@@ -145,7 +145,7 @@ function iterator(array $values): IteratorArgument
|
||||
/**
|
||||
* Creates a lazy iterator by tag name.
|
||||
*/
|
||||
function tagged_iterator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, string $defaultPriorityMethod = null, string|array $exclude = [], bool $excludeSelf = true): TaggedIteratorArgument
|
||||
function tagged_iterator(string $tag, ?string $indexAttribute = null, ?string $defaultIndexMethod = null, ?string $defaultPriorityMethod = null, string|array $exclude = [], bool $excludeSelf = true): TaggedIteratorArgument
|
||||
{
|
||||
return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, false, $defaultPriorityMethod, (array) $exclude, $excludeSelf);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ function tagged_iterator(string $tag, string $indexAttribute = null, string $def
|
||||
/**
|
||||
* Creates a service locator by tag name.
|
||||
*/
|
||||
function tagged_locator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, string $defaultPriorityMethod = null, string|array $exclude = [], bool $excludeSelf = true): ServiceLocatorArgument
|
||||
function tagged_locator(string $tag, ?string $indexAttribute = null, ?string $defaultIndexMethod = null, ?string $defaultPriorityMethod = null, string|array $exclude = [], bool $excludeSelf = true): ServiceLocatorArgument
|
||||
{
|
||||
return new ServiceLocatorArgument(new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, true, $defaultPriorityMethod, (array) $exclude, $excludeSelf));
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class DefaultsConfigurator extends AbstractServiceConfigurator
|
||||
|
||||
private ?string $path;
|
||||
|
||||
public function __construct(ServicesConfigurator $parent, Definition $definition, string $path = null)
|
||||
public function __construct(ServicesConfigurator $parent, Definition $definition, ?string $path = null)
|
||||
{
|
||||
parent::__construct($parent, $definition, null, []);
|
||||
|
||||
@@ -70,7 +70,7 @@ class DefaultsConfigurator extends AbstractServiceConfigurator
|
||||
$this->validateAttributes($tag, $value, [...$path, $name]);
|
||||
} elseif (!\is_scalar($value ?? '')) {
|
||||
$name = implode('.', [...$path, $name]);
|
||||
throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type or an array of scalar-type.', $tag, $name));
|
||||
throw new InvalidArgumentException(\sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type or an array of scalar-type.', $tag, $name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class InstanceofConfigurator extends AbstractServiceConfigurator
|
||||
|
||||
private ?string $path;
|
||||
|
||||
public function __construct(ServicesConfigurator $parent, Definition $definition, string $id, string $path = null)
|
||||
public function __construct(ServicesConfigurator $parent, Definition $definition, string $id, ?string $path = null)
|
||||
{
|
||||
parent::__construct($parent, $definition, $id, []);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class ParametersConfigurator extends AbstractConfigurator
|
||||
final public function set(string $name, mixed $value): static
|
||||
{
|
||||
if ($value instanceof Expression) {
|
||||
throw new InvalidArgumentException(sprintf('Using an expression in parameter "%s" is not allowed.', $name));
|
||||
throw new InvalidArgumentException(\sprintf('Using an expression in parameter "%s" is not allowed.', $name));
|
||||
}
|
||||
|
||||
$this->container->setParameter($name, static::processValue($value, true));
|
||||
|
||||
@@ -44,7 +44,7 @@ class PrototypeConfigurator extends AbstractServiceConfigurator
|
||||
private bool $allowParent;
|
||||
private ?string $path;
|
||||
|
||||
public function __construct(ServicesConfigurator $parent, PhpFileLoader $loader, Definition $defaults, string $namespace, string $resource, bool $allowParent, string $path = null)
|
||||
public function __construct(ServicesConfigurator $parent, PhpFileLoader $loader, Definition $defaults, string $namespace, string $resource, bool $allowParent, ?string $path = null)
|
||||
{
|
||||
$definition = new Definition();
|
||||
if (!$defaults->isPublic() || !$defaults->isPrivate()) {
|
||||
|
||||
@@ -49,7 +49,7 @@ class ServiceConfigurator extends AbstractServiceConfigurator
|
||||
private ?string $path;
|
||||
private bool $destructed = false;
|
||||
|
||||
public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, ?string $id, array $defaultTags, string $path = null)
|
||||
public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, ?string $id, array $defaultTags, ?string $path = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->instanceof = $instanceof;
|
||||
|
||||
@@ -34,7 +34,7 @@ class ServicesConfigurator extends AbstractConfigurator
|
||||
private string $anonymousHash;
|
||||
private int $anonymousCount;
|
||||
|
||||
public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path = null, int &$anonymousCount = 0)
|
||||
public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, ?string $path = null, int &$anonymousCount = 0)
|
||||
{
|
||||
$this->defaults = new Definition();
|
||||
$this->container = $container;
|
||||
@@ -70,7 +70,7 @@ class ServicesConfigurator extends AbstractConfigurator
|
||||
* @param string|null $id The service id, or null to create an anonymous service
|
||||
* @param string|null $class The class of the service, or null when $id is also the class name
|
||||
*/
|
||||
final public function set(?string $id, string $class = null): ServiceConfigurator
|
||||
final public function set(?string $id, ?string $class = null): ServiceConfigurator
|
||||
{
|
||||
$defaults = $this->defaults;
|
||||
$definition = new Definition();
|
||||
@@ -80,7 +80,7 @@ class ServicesConfigurator extends AbstractConfigurator
|
||||
throw new \LogicException('Anonymous services must have a class name.');
|
||||
}
|
||||
|
||||
$id = sprintf('.%d_%s', ++$this->anonymousCount, preg_replace('/^.*\\\\/', '', $class).'~'.$this->anonymousHash);
|
||||
$id = \sprintf('.%d_%s', ++$this->anonymousCount, preg_replace('/^.*\\\\/', '', $class).'~'.$this->anonymousHash);
|
||||
} elseif (!$defaults->isPublic() || !$defaults->isPrivate()) {
|
||||
$definition->setPublic($defaults->isPublic() && !$defaults->isPrivate());
|
||||
}
|
||||
@@ -163,7 +163,7 @@ class ServicesConfigurator extends AbstractConfigurator
|
||||
|
||||
$services[$i] = $definition;
|
||||
} elseif (!$service instanceof ReferenceConfigurator) {
|
||||
throw new InvalidArgumentException(sprintf('"%s()" expects a list of definitions as returned by "%s()" or "%s()", "%s" given at index "%s" for service "%s".', __METHOD__, InlineServiceConfigurator::FACTORY, ReferenceConfigurator::FACTORY, $service instanceof AbstractConfigurator ? $service::FACTORY.'()' : get_debug_type($service), $i, $id));
|
||||
throw new InvalidArgumentException(\sprintf('"%s()" expects a list of definitions as returned by "%s()" or "%s()", "%s" given at index "%s" for service "%s".', __METHOD__, InlineServiceConfigurator::FACTORY, ReferenceConfigurator::FACTORY, $service instanceof AbstractConfigurator ? $service::FACTORY.'()' : get_debug_type($service), $i, $id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ class ServicesConfigurator extends AbstractConfigurator
|
||||
/**
|
||||
* Registers a service.
|
||||
*/
|
||||
final public function __invoke(string $id, string $class = null): ServiceConfigurator
|
||||
final public function __invoke(string $id, ?string $class = null): ServiceConfigurator
|
||||
{
|
||||
return $this->set($id, $class);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ trait DecorateTrait
|
||||
*
|
||||
* @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals
|
||||
*/
|
||||
final public function decorate(?string $id, string $renamedId = null, int $priority = 0, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE): static
|
||||
final public function decorate(?string $id, ?string $renamedId = null, int $priority = 0, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE): static
|
||||
{
|
||||
$this->definition->setDecoratedService($id, $renamedId, $priority, $invalidBehavior);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ trait FactoryTrait
|
||||
if (\is_string($factory) && 1 === substr_count($factory, ':')) {
|
||||
$factoryParts = explode(':', $factory);
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Invalid factory "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[service(\'%s\'), \'%s\']" instead.', $factory, $factoryParts[0], $factoryParts[1]));
|
||||
throw new InvalidArgumentException(\sprintf('Invalid factory "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[service(\'%s\'), \'%s\']" instead.', $factory, $factoryParts[0], $factoryParts[1]));
|
||||
}
|
||||
|
||||
if ($factory instanceof Expression) {
|
||||
|
||||
@@ -35,7 +35,7 @@ trait FromCallableTrait
|
||||
'calls' => 'getMethodCalls',
|
||||
] as $key => $method) {
|
||||
if ($this->definition->$method()) {
|
||||
throw new InvalidArgumentException(sprintf('The configuration key "%s" is unsupported when using "fromCallable()".', $key));
|
||||
throw new InvalidArgumentException(\sprintf('The configuration key "%s" is unsupported when using "fromCallable()".', $key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ trait FromCallableTrait
|
||||
if (\is_string($callable) && 1 === substr_count($callable, ':')) {
|
||||
$parts = explode(':', $callable);
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Invalid callable "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[service(\'%s\'), \'%s\']" instead.', $callable, $parts[0], $parts[1]));
|
||||
throw new InvalidArgumentException(\sprintf('Invalid callable "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[service(\'%s\'), \'%s\']" instead.', $callable, $parts[0], $parts[1]));
|
||||
}
|
||||
|
||||
if ($callable instanceof Expression) {
|
||||
|
||||
@@ -26,7 +26,7 @@ trait ParentTrait
|
||||
final public function parent(string $parent): static
|
||||
{
|
||||
if (!$this->allowParent) {
|
||||
throw new InvalidArgumentException(sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id));
|
||||
throw new InvalidArgumentException(\sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id));
|
||||
}
|
||||
|
||||
if ($this->definition instanceof ChildDefinition) {
|
||||
|
||||
@@ -23,7 +23,7 @@ trait TagTrait
|
||||
final public function tag(string $name, array $attributes = []): static
|
||||
{
|
||||
if ('' === $name) {
|
||||
throw new InvalidArgumentException(sprintf('The tag name for service "%s" must be a non-empty string.', $this->id));
|
||||
throw new InvalidArgumentException(\sprintf('The tag name for service "%s" must be a non-empty string.', $this->id));
|
||||
}
|
||||
|
||||
$this->validateAttributes($name, $attributes);
|
||||
@@ -40,7 +40,7 @@ trait TagTrait
|
||||
$this->validateAttributes($tag, $value, [...$path, $name]);
|
||||
} elseif (!\is_scalar($value ?? '')) {
|
||||
$name = implode('.', [...$path, $name]);
|
||||
throw new InvalidArgumentException(sprintf('A tag attribute must be of a scalar-type or an array of scalar-types for service "%s", tag "%s", attribute "%s".', $this->id, $tag, $name));
|
||||
throw new InvalidArgumentException(\sprintf('A tag attribute must be of a scalar-type or an array of scalar-types for service "%s", tag "%s", attribute "%s".', $this->id, $tag, $name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user