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:
@@ -28,7 +28,7 @@ final class BoundArgument implements ArgumentInterface
|
||||
private int $type;
|
||||
private ?string $file;
|
||||
|
||||
public function __construct(mixed $value, bool $trackUsage = true, int $type = 0, string $file = null)
|
||||
public function __construct(mixed $value, bool $trackUsage = true, int $type = 0, ?string $file = null)
|
||||
{
|
||||
$this->value = $value;
|
||||
if ($trackUsage) {
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\DependencyInjection\Argument;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@@ -36,42 +35,42 @@ class LazyClosure
|
||||
public function __get(mixed $name): mixed
|
||||
{
|
||||
if ('service' !== $name) {
|
||||
throw new InvalidArgumentException(sprintf('Cannot read property "%s" from a lazy closure.', $name));
|
||||
throw new InvalidArgumentException(\sprintf('Cannot read property "%s" from a lazy closure.', $name));
|
||||
}
|
||||
|
||||
if (isset($this->initializer)) {
|
||||
$this->service = ($this->initializer)();
|
||||
if (\is_string($service = ($this->initializer)())) {
|
||||
$service = (new \ReflectionClass($service))->newInstanceWithoutConstructor();
|
||||
}
|
||||
$this->service = $service;
|
||||
unset($this->initializer);
|
||||
}
|
||||
|
||||
return $this->service;
|
||||
}
|
||||
|
||||
public static function getCode(string $initializer, array $callable, Definition $definition, ContainerBuilder $container, ?string $id): string
|
||||
public static function getCode(string $initializer, array $callable, string $class, ContainerBuilder $container, ?string $id): string
|
||||
{
|
||||
$method = $callable[1];
|
||||
$asClosure = 'Closure' === ($definition->getClass() ?: 'Closure');
|
||||
|
||||
if ($asClosure) {
|
||||
if ($asClosure = 'Closure' === $class) {
|
||||
$class = ($callable[0] instanceof Reference ? $container->findDefinition($callable[0]) : $callable[0])->getClass();
|
||||
} else {
|
||||
$class = $definition->getClass();
|
||||
}
|
||||
|
||||
$r = $container->getReflectionClass($class);
|
||||
|
||||
if (null !== $id) {
|
||||
$id = sprintf(' for service "%s"', $id);
|
||||
$id = \sprintf(' for service "%s"', $id);
|
||||
}
|
||||
|
||||
if (!$asClosure) {
|
||||
$id = str_replace('%', '%%', (string) $id);
|
||||
|
||||
if (!$r || !$r->isInterface()) {
|
||||
throw new RuntimeException(sprintf("Cannot create adapter{$id} because \"%s\" is not an interface.", $class));
|
||||
throw new RuntimeException(\sprintf("Cannot create adapter{$id} because \"%s\" is not an interface.", $class));
|
||||
}
|
||||
if (1 !== \count($method = $r->getMethods())) {
|
||||
throw new RuntimeException(sprintf("Cannot create adapter{$id} because interface \"%s\" doesn't have exactly one method.", $class));
|
||||
throw new RuntimeException(\sprintf("Cannot create adapter{$id} because interface \"%s\" doesn't have exactly one method.", $class));
|
||||
}
|
||||
$method = $method[0]->name;
|
||||
} elseif (!$r || !$r->hasMethod($method)) {
|
||||
|
||||
@@ -51,7 +51,7 @@ trait ReferenceSetArgumentTrait
|
||||
{
|
||||
foreach ($values as $k => $v) {
|
||||
if (null !== $v && !$v instanceof Reference) {
|
||||
throw new InvalidArgumentException(sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, get_debug_type($v)));
|
||||
throw new InvalidArgumentException(\sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, get_debug_type($v)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class ServiceLocator extends BaseServiceLocator
|
||||
private array $serviceMap;
|
||||
private ?array $serviceTypes;
|
||||
|
||||
public function __construct(\Closure $factory, array $serviceMap, array $serviceTypes = null)
|
||||
public function __construct(\Closure $factory, array $serviceMap, ?array $serviceTypes = null)
|
||||
{
|
||||
$this->factory = $factory;
|
||||
$this->serviceMap = $serviceMap;
|
||||
|
||||
@@ -35,7 +35,7 @@ class TaggedIteratorArgument extends IteratorArgument
|
||||
* @param array $exclude Services to exclude from the iterator
|
||||
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the iterator
|
||||
*/
|
||||
public function __construct(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, bool $needsIndexes = false, string $defaultPriorityMethod = null, array $exclude = [], bool $excludeSelf = true)
|
||||
public function __construct(string $tag, ?string $indexAttribute = null, ?string $defaultIndexMethod = null, bool $needsIndexes = false, ?string $defaultPriorityMethod = null, array $exclude = [], bool $excludeSelf = true)
|
||||
{
|
||||
parent::__construct([]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user