forked from Wavyzz/dolibarr
More valid rector rules to change conf->global->xxx
This commit is contained in:
@@ -48,6 +48,7 @@ return static function (RectorConfig $rectorConfig): void {
|
||||
__DIR__ . '/../../../scripts/',
|
||||
__DIR__ . '/../../../test/phpunit/',
|
||||
]);
|
||||
|
||||
$rectorConfig->skip([
|
||||
'**/includes/**',
|
||||
'**/custom/**',
|
||||
@@ -55,6 +56,7 @@ return static function (RectorConfig $rectorConfig): void {
|
||||
'**/rector/**', // Disable this line to test the "test.php" file.
|
||||
__DIR__ . '/../../../htdocs/custom/',
|
||||
__DIR__ . '/../../../htdocs/install/doctemplates/*'
|
||||
//'test.php',
|
||||
]);
|
||||
$rectorConfig->parallel(240);
|
||||
|
||||
@@ -70,9 +72,9 @@ return static function (RectorConfig $rectorConfig): void {
|
||||
|
||||
//$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class);
|
||||
|
||||
|
||||
$rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector::class);
|
||||
$rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class);
|
||||
$rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
|
||||
//Not yet ready: $rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class);
|
||||
$rectorConfig->rule(Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class);
|
||||
|
||||
@@ -82,6 +84,11 @@ return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class);
|
||||
//$rectorConfig->rule(Dolibarr\Rector\Renaming\UsePositiveExit::class);
|
||||
|
||||
|
||||
// This fix <> into != but it breaks other rules, so added at end.
|
||||
$rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
|
||||
|
||||
|
||||
// Add all predefined rules to migrate to up to php 71.
|
||||
// Warning this break tab spacing of arrays on several lines
|
||||
/*$rectorConfig->sets([
|
||||
|
||||
@@ -238,6 +238,7 @@ class GlobalToFunction extends AbstractRector
|
||||
$node = $nodes->getFirstExpr();
|
||||
}
|
||||
|
||||
|
||||
// Now process all comparison like:
|
||||
// $conf->global->... Operator Value
|
||||
|
||||
@@ -264,11 +265,14 @@ class GlobalToFunction extends AbstractRector
|
||||
$typeofcomparison = 'NotIdentical';
|
||||
//var_dump($node->left);
|
||||
}
|
||||
|
||||
if (empty($typeofcomparison)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->isGlobalVar($node->left)) {
|
||||
$isconfglobal = $this->isGlobalVar($node->left);
|
||||
if (!$isconfglobal) {
|
||||
// The left side is not conf->global->xxx, so we leave
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -282,7 +286,8 @@ class GlobalToFunction extends AbstractRector
|
||||
$funcName = 'getDolGlobalString';
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
$funcName = 'getDolGlobalString';
|
||||
break;
|
||||
}
|
||||
|
||||
$constName = $this->getConstName($node->left);
|
||||
|
||||
Reference in New Issue
Block a user