Clean code

This commit is contained in:
ldestailleur
2025-09-18 15:00:47 +02:00
parent f665a0301e
commit b30aa97ba9
4 changed files with 37 additions and 22 deletions

View File

@@ -307,8 +307,23 @@ class GlobalToFunction extends AbstractRector
if (empty($constName)) {
return;
}
// Test the type after the comparison conf->global->xxx to know the name of function
$typeleft = $node->left->getType();
switch ($typeleft) {
case 'Scalar_LNumber':
$funcName = 'getDolGlobalInt';
break;
case 'Scalar_String':
$funcName = 'getDolGlobalString';
break;
default: // Can be Expr_FuncCall
$funcName = 'getDolGlobalString';
break;
}
$node->right = new FuncCall(
new Name('getDolGlobalString'),
new Name($funcName),
[new Arg($constName)]
);
return $node;