2
0
forked from Wavyzz/dolibarr

Fix phpcs

This commit is contained in:
Laurent Destailleur
2023-12-04 10:23:11 +01:00
parent b282251fbc
commit 23c6b59818
3 changed files with 22 additions and 18 deletions

View File

@@ -53,9 +53,11 @@ class EmptyGlobalToFunction extends AbstractRector
{ {
return new RuleDefinition( return new RuleDefinition(
'Change $conf->global to getDolGlobal', 'Change $conf->global to getDolGlobal',
[new CodeSample('$conf->global->CONSTANT', [new CodeSample(
'$conf->global->CONSTANT',
'getDolGlobalInt(\'CONSTANT\')' 'getDolGlobalInt(\'CONSTANT\')'
)]); )]
);
} }
/** /**
@@ -106,7 +108,7 @@ class EmptyGlobalToFunction extends AbstractRector
return new FuncCall( return new FuncCall(
new Name('getDolGlobalString'), new Name('getDolGlobalString'),
[new Arg($constName)] [new Arg($constName)]
); );
} }
@@ -136,7 +138,7 @@ class EmptyGlobalToFunction extends AbstractRector
return new BooleanNot(new FuncCall( return new BooleanNot(new FuncCall(
new Name('getDolGlobalString'), new Name('getDolGlobalString'),
[new Arg($constName)] [new Arg($constName)]
)); ));
} }
return null; return null;
@@ -169,7 +171,7 @@ class EmptyGlobalToFunction extends AbstractRector
} }
return \true; return \true;
} }
); );
} }
/** /**

View File

@@ -56,9 +56,11 @@ class GlobalToFunction extends AbstractRector
{ {
return new RuleDefinition( return new RuleDefinition(
'Change $conf->global to getDolGlobal', 'Change $conf->global to getDolGlobal',
[new CodeSample('$conf->global->CONSTANT', [new CodeSample(
'$conf->global->CONSTANT',
'getDolGlobalInt(\'CONSTANT\')' 'getDolGlobalInt(\'CONSTANT\')'
)]); )]
);
} }
/** /**
@@ -188,36 +190,36 @@ class GlobalToFunction extends AbstractRector
new FuncCall( new FuncCall(
new Name($funcName), new Name($funcName),
[new Arg($constName)] [new Arg($constName)]
), ),
$node->right $node->right
); );
} }
if ($typeofcomparison == 'GreaterOrEqual') { if ($typeofcomparison == 'GreaterOrEqual') {
return new GreaterOrEqual( return new GreaterOrEqual(
new FuncCall( new FuncCall(
new Name($funcName), new Name($funcName),
[new Arg($constName)] [new Arg($constName)]
), ),
$node->right $node->right
); );
} }
if ($typeofcomparison == 'Smaller') { if ($typeofcomparison == 'Smaller') {
return new Smaller( return new Smaller(
new FuncCall( new FuncCall(
new Name($funcName), new Name($funcName),
[new Arg($constName)] [new Arg($constName)]
), ),
$node->right $node->right
); );
} }
if ($typeofcomparison == 'SmallerOrEqual') { if ($typeofcomparison == 'SmallerOrEqual') {
return new SmallerOrEqual( return new SmallerOrEqual(
new FuncCall( new FuncCall(
new Name($funcName), new Name($funcName),
[new Arg($constName)] [new Arg($constName)]
), ),
$node->right $node->right
); );
} }
} }

View File

@@ -2,7 +2,6 @@
namespace Dolibarr\Rector\Renaming; namespace Dolibarr\Rector\Renaming;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Arg; use PhpParser\Node\Arg;
use PhpParser\Node\Scalar\String_; use PhpParser\Node\Scalar\String_;
@@ -36,7 +35,8 @@ class UserRightsToFunction extends AbstractRector
[new CodeSample( [new CodeSample(
'$user->rights->module->permission', '$user->rights->module->permission',
'$user->hasRight(\'module\', \'permission\')' '$user->hasRight(\'module\', \'permission\')'
)]); )]
);
} }
/** /**
@@ -122,7 +122,7 @@ class UserRightsToFunction extends AbstractRector
return null; return null;
} }
// Add a test to avoid rector error on html.formsetup.class.php // Add a test to avoid rector error on html.formsetup.class.php
if (! $node->name instanceof Node\Expr\Variable && is_null($this->getName($node))) { if (!$node->name instanceof Node\Expr\Variable && is_null($this->getName($node))) {
//var_dump($node); //var_dump($node);
return null; return null;
//exit; //exit;