mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 14:58:43 +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:
@@ -82,7 +82,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
|
||||
continue;
|
||||
}
|
||||
if ($isRoot) {
|
||||
if ($v->hasTag('container.excluded')) {
|
||||
if ($v instanceof Definition && $v->hasTag('container.excluded')) {
|
||||
continue;
|
||||
}
|
||||
$this->currentId = $k;
|
||||
@@ -136,7 +136,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
if (!\function_exists($factory)) {
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory));
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory));
|
||||
}
|
||||
$r = new \ReflectionFunction($factory);
|
||||
if (false !== $r->getFileName() && file_exists($r->getFileName())) {
|
||||
@@ -150,7 +150,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
|
||||
[$class, $method] = $factory;
|
||||
|
||||
if ('__construct' === $method) {
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": "__construct()" cannot be used as a factory method.', $this->currentId));
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": "__construct()" cannot be used as a factory method.', $this->currentId));
|
||||
}
|
||||
|
||||
if ($class instanceof Reference) {
|
||||
@@ -174,20 +174,20 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
|
||||
try {
|
||||
if (!$r = $this->container->getReflectionClass($class)) {
|
||||
if (null === $class) {
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": the class is not set.', $this->currentId));
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId));
|
||||
}
|
||||
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage()));
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage()));
|
||||
}
|
||||
if (!$r = $r->getConstructor()) {
|
||||
if ($required) {
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, \sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
|
||||
}
|
||||
} elseif (!$r->isPublic()) {
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.');
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId).\sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.');
|
||||
}
|
||||
|
||||
return $r;
|
||||
@@ -207,11 +207,11 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
if (null === $class) {
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": the class is not set.', $this->currentId));
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId));
|
||||
}
|
||||
|
||||
if (!$r = $this->container->getReflectionClass($class)) {
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
|
||||
}
|
||||
|
||||
if (!$r->hasMethod($method)) {
|
||||
@@ -219,12 +219,16 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
|
||||
return new \ReflectionMethod(static function (...$arguments) {}, '__invoke');
|
||||
}
|
||||
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
|
||||
if ($r->hasMethod('__callStatic') && ($r = $r->getMethod('__callStatic')) && $r->isPublic()) {
|
||||
return new \ReflectionMethod(static function (...$arguments) {}, '__invoke');
|
||||
}
|
||||
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
|
||||
}
|
||||
|
||||
$r = $r->getMethod($method);
|
||||
if (!$r->isPublic()) {
|
||||
throw new RuntimeException(sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
|
||||
throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
|
||||
}
|
||||
|
||||
return $r;
|
||||
@@ -245,12 +249,12 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
|
||||
$arg = $this->processValue(new Reference($id));
|
||||
$this->inExpression = false;
|
||||
if (!$arg instanceof Reference) {
|
||||
throw new RuntimeException(sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, get_debug_type($arg), $id));
|
||||
throw new RuntimeException(\sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, get_debug_type($arg), $id));
|
||||
}
|
||||
$arg = sprintf('"%s"', $arg);
|
||||
$arg = \sprintf('"%s"', $arg);
|
||||
}
|
||||
|
||||
return sprintf('$this->get(%s)', $arg);
|
||||
return \sprintf('$this->get(%s)', $arg);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user