N°9319 increase php min. version to 8.2 (#887)

* Update minimum PHP version to 8.2
* Fix previous wrong resolution of merge conflict
This commit is contained in:
jf-cbd
2026-04-20 14:47:44 +02:00
committed by GitHub
parent f439490bfc
commit 805087a01b
171 changed files with 5629 additions and 1446 deletions

View File

@@ -1295,16 +1295,9 @@ EOF;
}
}
if (Container::class !== $this->baseClass) {
$r = $this->container->getReflectionClass($this->baseClass, false);
if (null !== $r
&& (null !== $constructor = $r->getConstructor())
&& 0 === $constructor->getNumberOfRequiredParameters()
&& Container::class !== $constructor->getDeclaringClass()->name
) {
$code .= " parent::__construct();\n";
$code .= " \$this->parameterBag = null;\n\n";
}
if ($this->needsUnsetParameterBag()) {
$code .= " parent::__construct();\n";
$code .= " unset(\$this->parameterBag);\n\n";
}
if ($this->container->getParameterBag()->all()) {
@@ -1582,9 +1575,22 @@ EOF;
return $code ? \sprintf("\n \$this->privates['service_container'] = static function (\$container) {%s\n };\n", $code) : '';
}
private function needsUnsetParameterBag(): bool
{
if (Container::class === $this->baseClass) {
return false;
}
$r = $this->container->getReflectionClass($this->baseClass, false);
return null !== $r
&& (null !== $constructor = $r->getConstructor())
&& 0 === $constructor->getNumberOfRequiredParameters()
&& Container::class !== $constructor->getDeclaringClass()->name;
}
private function addDefaultParametersMethod(): string
{
if (!$this->container->getParameterBag()->all()) {
if (!$this->container->getParameterBag()->all() && !$this->needsUnsetParameterBag()) {
return '';
}

View File

@@ -77,6 +77,18 @@ abstract class AbstractConfigurator
$value = (self::$valuePreProcessor)($value, $allowServices);
}
if ($value instanceof ParamConfigurator) {
return (string) $value;
}
if (\is_scalar($value ?? '') || $value instanceof \UnitEnum) {
return $value;
}
if (!$allowServices) {
throw new InvalidArgumentException(\sprintf('Cannot use values of type "%s" in service configuration files.', get_debug_type($value)));
}
if ($value instanceof ReferenceConfigurator) {
$reference = new Reference($value->id, $value->invalidBehavior);
@@ -90,29 +102,18 @@ 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));
}
switch (true) {
case null === $value:
case \is_scalar($value):
case $value instanceof \UnitEnum:
return $value;
case $value instanceof ArgumentInterface:
case $value instanceof Definition:
case $value instanceof Expression:
case $value instanceof Parameter:
case $value instanceof AbstractArgument:
case $value instanceof Reference:
if ($allowServices) {
return $value;
}
return $value;
}
throw new InvalidArgumentException(\sprintf('Cannot use values of type "%s" in service configuration files.', get_debug_type($value)));