/opt/cpanel/ea-wappspector/vendor/rector/rector/rules/Php81/NodeAnalyzer
Edit: /opt/cpanel/ea-wappspector/vendor/rector/rector/rules/Php81/NodeAnalyzer/ComplexNewAnalyzer.php (2045B)
exprAnalyzer = $exprAnalyzer;
}
public function isDynamic(New_ $new) : bool
{
if (!$new->class instanceof FullyQualified) {
return \true;
}
if ($new->isFirstClassCallable()) {
return \false;
}
$args = $new->getArgs();
foreach ($args as $arg) {
$value = $arg->value;
if ($this->isAllowedNew($value)) {
continue;
}
// new inside array is allowed for New in initializer
if ($value instanceof Array_ && $this->isAllowedArray($value)) {
continue;
}
if (!$this->exprAnalyzer->isDynamicExpr($value)) {
continue;
}
return \true;
}
return \false;
}
private function isAllowedNew(Expr $expr) : bool
{
if ($expr instanceof New_) {
return !$this->isDynamic($expr);
}
return \false;
}
private function isAllowedArray(Array_ $array) : bool
{
if (!$this->exprAnalyzer->isDynamicArray($array)) {
return \true;
}
$arrayItems = $array->items;
foreach ($arrayItems as $arrayItem) {
if (!$arrayItem instanceof ArrayItem) {
continue;
}
if (!$arrayItem->value instanceof New_) {
return \false;
}
if ($this->isDynamic($arrayItem->value)) {
return \false;
}
}
return \true;
}
}