mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
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:
@@ -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 '';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user