mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-21 08:51:24 +01:00
Fix phpcs
This commit is contained in:
@@ -20,39 +20,56 @@ use Symplify\RuleDocGenerator\Exception\PoorDocumentationException;
|
|||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class with Rector custom rule to fix code
|
||||||
|
*/
|
||||||
class GlobalToFunction extends AbstractRector
|
class GlobalToFunction extends AbstractRector
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Rector\Core\NodeManipulator\BinaryOpManipulator
|
* @var \Rector\Core\NodeManipulator\BinaryOpManipulator
|
||||||
*/
|
*/
|
||||||
private BinaryOpManipulator $binaryOpManipulator;
|
private BinaryOpManipulator $binaryOpManipulator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param BinaryOpManipulator $binaryOpManipulator The $binaryOpManipulator
|
||||||
|
*/
|
||||||
public function __construct(BinaryOpManipulator $binaryOpManipulator)
|
public function __construct(BinaryOpManipulator $binaryOpManipulator)
|
||||||
{
|
{
|
||||||
$this->binaryOpManipulator = $binaryOpManipulator;
|
$this->binaryOpManipulator = $binaryOpManipulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* getRuleDefinition
|
||||||
|
*
|
||||||
|
* @return RuleDefinition
|
||||||
* @throws PoorDocumentationException
|
* @throws PoorDocumentationException
|
||||||
*/
|
*/
|
||||||
public function getRuleDefinition(): RuleDefinition
|
public function getRuleDefinition(): RuleDefinition
|
||||||
{
|
{
|
||||||
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\')'
|
||||||
)]);
|
)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getNodeTypes
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getNodeTypes(): array
|
public function getNodeTypes(): array
|
||||||
{
|
{
|
||||||
return [Equal::class, BooleanAnd::class];
|
return [Equal::class, BooleanAnd::class];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Node $node
|
* refactor
|
||||||
* @return Equal|void
|
*
|
||||||
|
* @param Node $node A node
|
||||||
|
* @return Equal|void
|
||||||
*/
|
*/
|
||||||
public function refactor(Node $node)
|
public function refactor(Node $node)
|
||||||
{
|
{
|
||||||
@@ -82,7 +99,6 @@ class GlobalToFunction extends AbstractRector
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
$constName = $this->getName($node->left);
|
$constName = $this->getName($node->left);
|
||||||
if (empty($constName)) {
|
if (empty($constName)) {
|
||||||
@@ -99,8 +115,9 @@ class GlobalToFunction extends AbstractRector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get nodes with check empty
|
* Get nodes with check empty
|
||||||
* @param BooleanAnd $booleanAnd
|
*
|
||||||
* @return TwoNodeMatch|null
|
* @param BooleanAnd $booleanAnd A BooleandAnd
|
||||||
|
* @return TwoNodeMatch|null
|
||||||
*/
|
*/
|
||||||
private function resolveTwoNodeMatch(BooleanAnd $booleanAnd): ?TwoNodeMatch
|
private function resolveTwoNodeMatch(BooleanAnd $booleanAnd): ?TwoNodeMatch
|
||||||
{
|
{
|
||||||
@@ -128,7 +145,8 @@ class GlobalToFunction extends AbstractRector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check node is global access
|
* Check node is global access
|
||||||
* @param $node
|
*
|
||||||
|
* @param $node A node
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function isGlobalVar($node)
|
private function isGlobalVar($node)
|
||||||
|
|||||||
Reference in New Issue
Block a user