mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 06:28:46 +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:
@@ -11,9 +11,11 @@
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Target;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
@@ -56,11 +58,11 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
}
|
||||
|
||||
if ($argumentType) {
|
||||
$message .= sprintf('of type "%s" ', $argumentType);
|
||||
$message .= \sprintf('of type "%s" ', $argumentType);
|
||||
}
|
||||
|
||||
if ($argumentName) {
|
||||
$message .= sprintf('named "%s" ', $argumentName);
|
||||
$message .= \sprintf('named "%s" ', $argumentName);
|
||||
}
|
||||
|
||||
if (BoundArgument::DEFAULTS_BINDING === $bindingType) {
|
||||
@@ -68,17 +70,17 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
} elseif (BoundArgument::INSTANCEOF_BINDING === $bindingType) {
|
||||
$message .= 'under "_instanceof"';
|
||||
} else {
|
||||
$message .= sprintf('for service "%s"', $serviceId);
|
||||
$message .= \sprintf('for service "%s"', $serviceId);
|
||||
}
|
||||
|
||||
if ($file) {
|
||||
$message .= sprintf(' in file "%s"', $file);
|
||||
$message .= \sprintf(' in file "%s"', $file);
|
||||
}
|
||||
|
||||
$message = sprintf('A binding is configured for an argument %s, but no corresponding argument has been found. It may be unused and should be removed, or it may have a typo.', $message);
|
||||
$message = \sprintf('A binding is configured for an argument %s, but no corresponding argument has been found. It may be unused and should be removed, or it may have a typo.', $message);
|
||||
|
||||
if ($this->errorMessages) {
|
||||
$message .= sprintf("\nCould be related to%s:", 1 < \count($this->errorMessages) ? ' one of' : '');
|
||||
$message .= \sprintf("\nCould be related to%s:", 1 < \count($this->errorMessages) ? ' one of' : '');
|
||||
}
|
||||
foreach ($this->errorMessages as $m) {
|
||||
$message .= "\n - ".$m;
|
||||
@@ -119,10 +121,10 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
foreach ($bindings as $key => $binding) {
|
||||
[$bindingValue, $bindingId, $used, $bindingType, $file] = $binding->getValues();
|
||||
if ($used) {
|
||||
$this->usedBindings[$bindingId] = true;
|
||||
unset($this->unusedBindings[$bindingId]);
|
||||
} elseif (!isset($this->usedBindings[$bindingId])) {
|
||||
$this->unusedBindings[$bindingId] = [$key, $this->currentId, $bindingType, $file];
|
||||
$this->usedBindings[$bindingId ?? ''] = true;
|
||||
unset($this->unusedBindings[$bindingId ?? '']);
|
||||
} elseif (!isset($this->usedBindings[$bindingId ?? ''])) {
|
||||
$this->unusedBindings[$bindingId ?? ''] = [$key, $this->currentId, $bindingType, $file];
|
||||
}
|
||||
|
||||
if (preg_match('/^(?:(?:array|bool|float|int|string|iterable|([^ $]++)) )\$/', $key, $m)) {
|
||||
@@ -139,7 +141,7 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
}
|
||||
|
||||
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected "%s", "%s", "%s", "%s" or null, "%s" given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, ServiceLocatorArgument::class, get_debug_type($bindingValue)));
|
||||
throw new InvalidArgumentException(\sprintf('Invalid value for binding key "%s" for service "%s": expected "%s", "%s", "%s", "%s" or null, "%s" given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, ServiceLocatorArgument::class, get_debug_type($bindingValue)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,10 +183,17 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
foreach ($reflectionMethod->getParameters() as $key => $parameter) {
|
||||
$names[$key] = $parameter->name;
|
||||
|
||||
if (\array_key_exists($key, $arguments) && '' !== $arguments[$key]) {
|
||||
if (\array_key_exists($key, $arguments) && '' !== $arguments[$key] && !$arguments[$key] instanceof AbstractArgument) {
|
||||
continue;
|
||||
}
|
||||
if (\array_key_exists($parameter->name, $arguments) && '' !== $arguments[$parameter->name]) {
|
||||
if (\array_key_exists($parameter->name, $arguments) && '' !== $arguments[$parameter->name] && !$arguments[$parameter->name] instanceof AbstractArgument) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
$value->isAutowired()
|
||||
&& !$value->hasTag('container.ignore_attributes')
|
||||
&& $parameter->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -216,13 +225,15 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
if (isset($bindingNames[$name]) || isset($bindingNames[$parsedName]) || isset($bindingNames[$parameter->name])) {
|
||||
$bindingKey = array_search($binding, $bindings, true);
|
||||
$argumentType = substr($bindingKey, 0, strpos($bindingKey, ' '));
|
||||
$this->errorMessages[] = sprintf('Did you forget to add the type "%s" to argument "$%s" of method "%s::%s()"?', $argumentType, $parameter->name, $reflectionMethod->class, $reflectionMethod->name);
|
||||
$this->errorMessages[] = \sprintf('Did you forget to add the type "%s" to argument "$%s" of method "%s::%s()"?', $argumentType, $parameter->name, $reflectionMethod->class, $reflectionMethod->name);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($names as $key => $name) {
|
||||
if (\array_key_exists($name, $arguments) && (0 === $key || \array_key_exists($key - 1, $arguments))) {
|
||||
$arguments[$key] = $arguments[$name];
|
||||
if (!\array_key_exists($key, $arguments)) {
|
||||
$arguments[$key] = $arguments[$name];
|
||||
}
|
||||
unset($arguments[$name]);
|
||||
}
|
||||
}
|
||||
@@ -252,8 +263,8 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
{
|
||||
[$bindingValue, $bindingId] = $binding->getValues();
|
||||
|
||||
$this->usedBindings[$bindingId] = true;
|
||||
unset($this->unusedBindings[$bindingId]);
|
||||
$this->usedBindings[$bindingId ?? ''] = true;
|
||||
unset($this->unusedBindings[$bindingId ?? '']);
|
||||
|
||||
return $bindingValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user