More transforms
This commit is contained in:
parent
37e0cfac27
commit
12a33c4a33
@ -101,12 +101,14 @@ class NestedExpressionFixer extends Plugin
|
|||||||
new LNumber(0)
|
new LNumber(0)
|
||||||
);
|
);
|
||||||
// For all the following expressions, wrapping in a ternary breaks return-by-ref,
|
// For all the following expressions, wrapping in a ternary breaks return-by-ref,
|
||||||
// so for now wrap in a hack and fix once the expression bubbler is ready
|
// so for now wrap in a hack and fix once the expression bubbler is ready (READY NOW, done)
|
||||||
case StaticCall::class:
|
case StaticCall::class:
|
||||||
case StaticPropertyFetch::class:
|
case StaticPropertyFetch::class:
|
||||||
case FuncCall::class:
|
case FuncCall::class:
|
||||||
$this->traverser->traverseAst($expr);
|
$this->traverser->traverseAst($expr);
|
||||||
$valueCopy = $value;
|
$valueCopy = $value;
|
||||||
|
$context->insertBefore($expr, new Assign($value = $context->getVariable(), $valueCopy));
|
||||||
|
/*
|
||||||
return new ErrorSuppress(
|
return new ErrorSuppress(
|
||||||
new MethodCall(
|
new MethodCall(
|
||||||
self::callPoly(
|
self::callPoly(
|
||||||
@ -122,7 +124,7 @@ class NestedExpressionFixer extends Plugin
|
|||||||
),
|
),
|
||||||
'__invoke'
|
'__invoke'
|
||||||
)
|
)
|
||||||
);
|
);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,6 @@ namespace Phabel\Target\Php70;
|
|||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
use Phabel\Plugin\IssetExpressionFixer as fixer;
|
use Phabel\Plugin\IssetExpressionFixer as fixer;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class IssetExpressionFixer extends Plugin
|
class IssetExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -112,14 +108,88 @@ class IssetExpressionFixer extends Plugin
|
|||||||
[
|
[
|
||||||
'class' =>
|
'class' =>
|
||||||
[
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Assign' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignRef' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BitwiseNot' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BooleanNot' => true,
|
||||||
'PhpParser\\Node\\Expr\\ClassConstFetch' => true,
|
'PhpParser\\Node\\Expr\\ClassConstFetch' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Clone_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Closure' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ClosureUse' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Empty_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ErrorSuppress' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Eval_' => true,
|
||||||
'PhpParser\\Node\\Expr\\FuncCall' => true,
|
'PhpParser\\Node\\Expr\\FuncCall' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Include_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Instanceof_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Isset_' => true,
|
||||||
'PhpParser\\Node\\Expr\\MethodCall' => true,
|
'PhpParser\\Node\\Expr\\MethodCall' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\New_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PostDec' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PostInc' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PreDec' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PreInc' => true,
|
||||||
'PhpParser\\Node\\Expr\\PropertyFetch' => true,
|
'PhpParser\\Node\\Expr\\PropertyFetch' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ShellExec' => true,
|
||||||
'PhpParser\\Node\\Expr\\StaticCall' => true,
|
'PhpParser\\Node\\Expr\\StaticCall' => true,
|
||||||
'PhpParser\\Node\\Expr\\StaticPropertyFetch' => true,
|
'PhpParser\\Node\\Expr\\StaticPropertyFetch' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Ternary' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryMinus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryPlus' => true,
|
||||||
'PhpParser\\Node\\Expr\\Yield_' => true,
|
'PhpParser\\Node\\Expr\\Yield_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseXor' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Concat' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Div' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Minus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Mod' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Mul' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Plus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Pow' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\ShiftLeft' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\ShiftRight' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseXor' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BooleanAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BooleanOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Concat' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Div' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Equal' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Greater' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\GreaterOrEqual' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Identical' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalXor' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Minus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Mod' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Mul' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotEqual' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotIdentical' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Plus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Pow' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftLeft' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftRight' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Smaller' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\SmallerOrEqual' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Array_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Bool_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Double' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Int_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Object_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\String_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Unset_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\Encapsed' => true,
|
||||||
'PhpParser\\Node\\Scalar\\String_' => true,
|
'PhpParser\\Node\\Scalar\\String_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Class_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Dir' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\File' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Function_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Method' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Namespace_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Trait_' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PhpParser\\Node\\Expr\\PropertyFetch' =>
|
'PhpParser\\Node\\Expr\\PropertyFetch' =>
|
||||||
|
@ -5,10 +5,6 @@ namespace Phabel\Target\Php70;
|
|||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
use Phabel\Plugin\NestedExpressionFixer as fixer;
|
use Phabel\Plugin\NestedExpressionFixer as fixer;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class NestedExpressionFixer extends Plugin
|
class NestedExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -108,14 +104,88 @@ class NestedExpressionFixer extends Plugin
|
|||||||
[
|
[
|
||||||
'class' =>
|
'class' =>
|
||||||
[
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Assign' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignRef' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BitwiseNot' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BooleanNot' => true,
|
||||||
'PhpParser\\Node\\Expr\\ClassConstFetch' => true,
|
'PhpParser\\Node\\Expr\\ClassConstFetch' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Clone_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Closure' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ClosureUse' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Empty_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ErrorSuppress' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Eval_' => true,
|
||||||
'PhpParser\\Node\\Expr\\FuncCall' => true,
|
'PhpParser\\Node\\Expr\\FuncCall' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Include_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Instanceof_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Isset_' => true,
|
||||||
'PhpParser\\Node\\Expr\\MethodCall' => true,
|
'PhpParser\\Node\\Expr\\MethodCall' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\New_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PostDec' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PostInc' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PreDec' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PreInc' => true,
|
||||||
'PhpParser\\Node\\Expr\\PropertyFetch' => true,
|
'PhpParser\\Node\\Expr\\PropertyFetch' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ShellExec' => true,
|
||||||
'PhpParser\\Node\\Expr\\StaticCall' => true,
|
'PhpParser\\Node\\Expr\\StaticCall' => true,
|
||||||
'PhpParser\\Node\\Expr\\StaticPropertyFetch' => true,
|
'PhpParser\\Node\\Expr\\StaticPropertyFetch' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Ternary' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryMinus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryPlus' => true,
|
||||||
'PhpParser\\Node\\Expr\\Yield_' => true,
|
'PhpParser\\Node\\Expr\\Yield_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseXor' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Concat' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Div' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Minus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Mod' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Mul' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Plus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Pow' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\ShiftLeft' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\ShiftRight' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseXor' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BooleanAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BooleanOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Concat' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Div' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Equal' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Greater' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\GreaterOrEqual' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Identical' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalXor' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Minus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Mod' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Mul' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotEqual' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotIdentical' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Plus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Pow' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftLeft' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftRight' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Smaller' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\SmallerOrEqual' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Array_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Bool_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Double' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Int_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Object_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\String_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Unset_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\Encapsed' => true,
|
||||||
'PhpParser\\Node\\Scalar\\String_' => true,
|
'PhpParser\\Node\\Scalar\\String_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Class_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Dir' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\File' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Function_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Method' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Namespace_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Trait_' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PhpParser\\Node\\Expr\\FuncCall' =>
|
'PhpParser\\Node\\Expr\\FuncCall' =>
|
||||||
|
@ -3,9 +3,14 @@
|
|||||||
namespace Phabel\Target\Php70;
|
namespace Phabel\Target\Php70;
|
||||||
|
|
||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
|
use Phabel\Target\Php74\ArrowClosure;
|
||||||
|
use Phabel\Tools;
|
||||||
use PhpParser\Node;
|
use PhpParser\Node;
|
||||||
|
use PhpParser\Node\Expr;
|
||||||
|
use PhpParser\Node\Expr\ArrowFunction;
|
||||||
use PhpParser\Node\Expr\BinaryOp\Coalesce;
|
use PhpParser\Node\Expr\BinaryOp\Coalesce;
|
||||||
use PhpParser\Node\Expr\StaticCall;
|
use PhpParser\Node\Expr\Isset_;
|
||||||
|
use PhpParser\Node\Expr\Ternary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
* @author Daniil Gentili <daniil@daniil.it>
|
||||||
@ -18,14 +23,22 @@ class NullCoalesceReplacer extends Plugin
|
|||||||
*
|
*
|
||||||
* @param Coalesce $node Coalesce
|
* @param Coalesce $node Coalesce
|
||||||
*
|
*
|
||||||
* @return StaticCall
|
* @return Expr
|
||||||
*/
|
*/
|
||||||
public function enter(Coalesce $node): StaticCall
|
public function enter(Coalesce $node): Expr
|
||||||
{
|
{
|
||||||
|
if (!Tools::hasSideEffects($node->left)) {
|
||||||
|
return new Ternary(new Isset_([$node->left]), $node->left, $node->right);
|
||||||
|
}
|
||||||
|
$method = 'coalesce';
|
||||||
|
if (Tools::hasSideEffects($node->right)) {
|
||||||
|
$method = 'coalesceSide';
|
||||||
|
$node->right = new ArrowFunction(['expr' => $node->right]);
|
||||||
|
}
|
||||||
if (!($node->left instanceof Node\Expr\ErrorSuppress)) {
|
if (!($node->left instanceof Node\Expr\ErrorSuppress)) {
|
||||||
$node->left = new Node\Expr\ErrorSuppress($node->left);
|
$node->left = new Node\Expr\ErrorSuppress($node->left);
|
||||||
}
|
}
|
||||||
return self::callPoly('coalesce', $node->left, $node->right);
|
return self::callPoly($method, $node->left, $node->right);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Coalesce.
|
* Coalesce.
|
||||||
@ -39,4 +52,20 @@ class NullCoalesceReplacer extends Plugin
|
|||||||
{
|
{
|
||||||
return isset($ifNotNull) ? $ifNotNull : $then;
|
return isset($ifNotNull) ? $ifNotNull : $then;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Coalesce (with side effects on the right).
|
||||||
|
*
|
||||||
|
* @param null|mixed $ifNotNull If not null, return this
|
||||||
|
* @param callable<mixed> $then Else this
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function coalesceSide($ifNotNull, callable $then)
|
||||||
|
{
|
||||||
|
return isset($ifNotNull) ? $ifNotNull : $then();
|
||||||
|
}
|
||||||
|
public static function runBefore(): array
|
||||||
|
{
|
||||||
|
return [ArrowClosure::class];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,6 @@ namespace Phabel\Target\Php71;
|
|||||||
|
|
||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class IssetExpressionFixer extends Plugin
|
class IssetExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
37
src/Target/Php71/ListExpression.php
Normal file
37
src/Target/Php71/ListExpression.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Phabel\Target\Php71;
|
||||||
|
|
||||||
|
use Phabel\Context;
|
||||||
|
use Phabel\Plugin;
|
||||||
|
use PhpParser\Node\Expr\Array_;
|
||||||
|
use PhpParser\Node\Expr\Assign;
|
||||||
|
use PhpParser\Node\Expr\List_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polyfills list expression return value.
|
||||||
|
*/
|
||||||
|
class ListExpression extends Plugin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Parse list assignment.
|
||||||
|
*
|
||||||
|
* @param Assign $node List assignment
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function enterAssign(Assign $node, Context $ctx): void
|
||||||
|
{
|
||||||
|
$isStmt = $ctx->parents[0]->getAttribute('currentNode') === 'stmts';
|
||||||
|
if (!($node->var instanceof List_ || $node->var instanceof Array_) || $isStmt) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$list = $node->var;
|
||||||
|
$var = $ctx->getVariable();
|
||||||
|
$assignments = ListReference::splitList($list, $var);
|
||||||
|
|
||||||
|
// On newer versions of php, the list assignment expression returns the original array
|
||||||
|
$ctx->insertBefore($node, new Assign($var, $node->expr), ...$assignments);
|
||||||
|
return $var;
|
||||||
|
}
|
||||||
|
}
|
@ -4,10 +4,6 @@ namespace Phabel\Target\Php71;
|
|||||||
|
|
||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class NestedExpressionFixer extends Plugin
|
class NestedExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,6 @@ namespace Phabel\Target\Php72;
|
|||||||
|
|
||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class IssetExpressionFixer extends Plugin
|
class IssetExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,6 @@ namespace Phabel\Target\Php72;
|
|||||||
|
|
||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class NestedExpressionFixer extends Plugin
|
class NestedExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,6 @@ namespace Phabel\Target\Php73;
|
|||||||
|
|
||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class IssetExpressionFixer extends Plugin
|
class IssetExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class ListReference extends Plugin
|
|||||||
return $last;
|
return $last;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On newer versions of php, list assignment returns the original array
|
// On newer versions of php, the list assignment expression returns the original array
|
||||||
$ctx->insertBefore($node, new Assign($var, $node->expr), ...$assignments);
|
$ctx->insertBefore($node, new Assign($var, $node->expr), ...$assignments);
|
||||||
return $var;
|
return $var;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ class ListReference extends Plugin
|
|||||||
*
|
*
|
||||||
* @return (Assign|AssignRef)[]
|
* @return (Assign|AssignRef)[]
|
||||||
*/
|
*/
|
||||||
private static function splitList($list, Variable $var): array
|
public static function splitList($list, Variable $var): array
|
||||||
{
|
{
|
||||||
$assignments = [];
|
$assignments = [];
|
||||||
$key = 0; // Technically a list assignment does not support mixed keys, but we need this for nested assignments
|
$key = 0; // Technically a list assignment does not support mixed keys, but we need this for nested assignments
|
||||||
|
@ -5,10 +5,6 @@ namespace Phabel\Target\Php73;
|
|||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
use Phabel\Plugin\NestedExpressionFixer as fixer;
|
use Phabel\Plugin\NestedExpressionFixer as fixer;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class NestedExpressionFixer extends Plugin
|
class NestedExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -4,10 +4,6 @@ namespace Phabel\Target\Php74;
|
|||||||
|
|
||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class IssetExpressionFixer extends Plugin
|
class IssetExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,6 @@ namespace Phabel\Target\Php74;
|
|||||||
|
|
||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class NestedExpressionFixer extends Plugin
|
class NestedExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,6 @@ namespace Phabel\Target\Php80;
|
|||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
use Phabel\Plugin\IssetExpressionFixer as fixer;
|
use Phabel\Plugin\IssetExpressionFixer as fixer;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class IssetExpressionFixer extends Plugin
|
class IssetExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -20,11 +16,15 @@ class IssetExpressionFixer extends Plugin
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
fixer::class => [
|
fixer::class => [
|
||||||
'PhpParser\\Node\\Expr\\ClassConstFetch' =>
|
'PhpParser\\Node\\Expr\\ArrayDimFetch' =>
|
||||||
[
|
[
|
||||||
'class' =>
|
'var' =>
|
||||||
[
|
[
|
||||||
'PhpParser\\Node\\Scalar\\Encapsed' => true,
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
'dim' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PhpParser\\Node\\Expr\\PropertyFetch' =>
|
'PhpParser\\Node\\Expr\\PropertyFetch' =>
|
||||||
@ -32,6 +32,25 @@ class IssetExpressionFixer extends Plugin
|
|||||||
'var' =>
|
'var' =>
|
||||||
[
|
[
|
||||||
'PhpParser\\Node\\Expr\\ConstFetch' => true,
|
'PhpParser\\Node\\Expr\\ConstFetch' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
'name' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\StaticPropertyFetch' =>
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Variable' =>
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
@ -5,10 +5,6 @@ namespace Phabel\Target\Php80;
|
|||||||
use Phabel\Plugin;
|
use Phabel\Plugin;
|
||||||
use Phabel\Plugin\NestedExpressionFixer as fixer;
|
use Phabel\Plugin\NestedExpressionFixer as fixer;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniil Gentili <daniil@daniil.it>
|
|
||||||
* @license MIT
|
|
||||||
*/
|
|
||||||
class NestedExpressionFixer extends Plugin
|
class NestedExpressionFixer extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -20,11 +16,64 @@ class NestedExpressionFixer extends Plugin
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
fixer::class => [
|
fixer::class => [
|
||||||
'PhpParser\\Node\\Expr\\ClassConstFetch' =>
|
'PhpParser\\Node\\Expr\\ArrayDimFetch' =>
|
||||||
[
|
[
|
||||||
'class' =>
|
'var' =>
|
||||||
[
|
[
|
||||||
'PhpParser\\Node\\Scalar\\Encapsed' => true,
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
'dim' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Assign' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BooleanNot' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Clone_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Empty_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\ErrorSuppress' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Eval_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\FuncCall' =>
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PhpParser\\Node\\Expr\\Instanceof_' =>
|
'PhpParser\\Node\\Expr\\Instanceof_' =>
|
||||||
@ -33,10 +82,26 @@ class NestedExpressionFixer extends Plugin
|
|||||||
[
|
[
|
||||||
'PhpParser\\Node\\Expr\\Assign' => true,
|
'PhpParser\\Node\\Expr\\Assign' => true,
|
||||||
'PhpParser\\Node\\Expr\\AssignRef' => true,
|
'PhpParser\\Node\\Expr\\AssignRef' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BitwiseNot' => true,
|
||||||
'PhpParser\\Node\\Expr\\BooleanNot' => true,
|
'PhpParser\\Node\\Expr\\BooleanNot' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Clone_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Closure' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ClosureUse' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Empty_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ErrorSuppress' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Eval_' => true,
|
||||||
'PhpParser\\Node\\Expr\\Include_' => true,
|
'PhpParser\\Node\\Expr\\Include_' => true,
|
||||||
'PhpParser\\Node\\Expr\\Instanceof_' => true,
|
'PhpParser\\Node\\Expr\\Instanceof_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Isset_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\New_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PostDec' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PostInc' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PreDec' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PreInc' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ShellExec' => true,
|
||||||
'PhpParser\\Node\\Expr\\Ternary' => true,
|
'PhpParser\\Node\\Expr\\Ternary' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryMinus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryPlus' => true,
|
||||||
'PhpParser\\Node\\Expr\\YieldFrom' => true,
|
'PhpParser\\Node\\Expr\\YieldFrom' => true,
|
||||||
'PhpParser\\Node\\Expr\\Yield_' => true,
|
'PhpParser\\Node\\Expr\\Yield_' => true,
|
||||||
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseAnd' => true,
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseAnd' => true,
|
||||||
@ -73,11 +138,26 @@ class NestedExpressionFixer extends Plugin
|
|||||||
'PhpParser\\Node\\Expr\\BinaryOp\\NotEqual' => true,
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotEqual' => true,
|
||||||
'PhpParser\\Node\\Expr\\BinaryOp\\NotIdentical' => true,
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotIdentical' => true,
|
||||||
'PhpParser\\Node\\Expr\\BinaryOp\\Plus' => true,
|
'PhpParser\\Node\\Expr\\BinaryOp\\Plus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Pow' => true,
|
||||||
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftLeft' => true,
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftLeft' => true,
|
||||||
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftRight' => true,
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftRight' => true,
|
||||||
'PhpParser\\Node\\Expr\\BinaryOp\\Smaller' => true,
|
'PhpParser\\Node\\Expr\\BinaryOp\\Smaller' => true,
|
||||||
'PhpParser\\Node\\Expr\\BinaryOp\\SmallerOrEqual' => true,
|
'PhpParser\\Node\\Expr\\BinaryOp\\SmallerOrEqual' => true,
|
||||||
'PhpParser\\Node\\Expr\\BinaryOp\\Spaceship' => true,
|
'PhpParser\\Node\\Expr\\BinaryOp\\Spaceship' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Array_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Bool_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Double' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Int_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Object_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\String_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\Encapsed' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Class_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Dir' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\File' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Function_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Method' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Namespace_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Trait_' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PhpParser\\Node\\Expr\\MethodCall' =>
|
'PhpParser\\Node\\Expr\\MethodCall' =>
|
||||||
@ -85,13 +165,98 @@ class NestedExpressionFixer extends Plugin
|
|||||||
'var' =>
|
'var' =>
|
||||||
[
|
[
|
||||||
'PhpParser\\Node\\Expr\\ConstFetch' => true,
|
'PhpParser\\Node\\Expr\\ConstFetch' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PhpParser\\Node\\Expr\\New_' =>
|
'PhpParser\\Node\\Expr\\New_' =>
|
||||||
[
|
[
|
||||||
'class' =>
|
'class' =>
|
||||||
[
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Assign' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignRef' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BitwiseNot' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BooleanNot' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Clone_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Closure' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ClosureUse' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Empty_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ErrorSuppress' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Eval_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Include_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Instanceof_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Isset_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\New_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PostDec' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PostInc' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PreDec' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\PreInc' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\ShellExec' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Ternary' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryMinus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryPlus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\YieldFrom' => true,
|
||||||
'PhpParser\\Node\\Expr\\Yield_' => true,
|
'PhpParser\\Node\\Expr\\Yield_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseXor' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Coalesce' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Concat' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Div' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Minus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Mod' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Mul' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Plus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Pow' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\ShiftLeft' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\ShiftRight' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseXor' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BooleanAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BooleanOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Coalesce' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Concat' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Div' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Equal' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Greater' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\GreaterOrEqual' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Identical' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalAnd' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalOr' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalXor' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Minus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Mod' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Mul' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotEqual' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotIdentical' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Plus' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Pow' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftLeft' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftRight' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Smaller' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\SmallerOrEqual' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Spaceship' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Array_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Bool_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Double' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Int_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Object_' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\String_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\Encapsed' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Class_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Dir' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\File' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Function_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Method' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Namespace_' => true,
|
||||||
|
'PhpParser\\Node\\Scalar\\MagicConst\\Trait_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Print_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PhpParser\\Node\\Expr\\PropertyFetch' =>
|
'PhpParser\\Node\\Expr\\PropertyFetch' =>
|
||||||
@ -99,6 +264,397 @@ class NestedExpressionFixer extends Plugin
|
|||||||
'var' =>
|
'var' =>
|
||||||
[
|
[
|
||||||
'PhpParser\\Node\\Expr\\ConstFetch' => true,
|
'PhpParser\\Node\\Expr\\ConstFetch' => true,
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
'name' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\StaticPropertyFetch' =>
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Ternary' =>
|
||||||
|
[
|
||||||
|
'if' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
'else' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryMinus' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\UnaryPlus' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Variable' =>
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\YieldFrom' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Yield_' =>
|
||||||
|
[
|
||||||
|
'value' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
'key' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseAnd' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseOr' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\BitwiseXor' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Coalesce' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Concat' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Div' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Minus' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Mod' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Mul' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Plus' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\Pow' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\ShiftLeft' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\AssignOp\\ShiftRight' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseAnd' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseOr' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BitwiseXor' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BooleanAnd' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\BooleanOr' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Coalesce' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Concat' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Div' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Equal' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Greater' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\GreaterOrEqual' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Identical' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalAnd' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalOr' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\LogicalXor' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Minus' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Mod' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Mul' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotEqual' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\NotIdentical' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Plus' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Pow' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftLeft' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\ShiftRight' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Smaller' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\SmallerOrEqual' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\BinaryOp\\Spaceship' =>
|
||||||
|
[
|
||||||
|
'right' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Array_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Bool_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Double' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Int_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\Object_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'PhpParser\\Node\\Expr\\Cast\\String_' =>
|
||||||
|
[
|
||||||
|
'expr' =>
|
||||||
|
[
|
||||||
|
'PhpParser\\Node\\Expr\\Throw_' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
@ -86,7 +86,7 @@ function checkSyntax(string $code, int $startFrom = 56): int
|
|||||||
return $startFrom;
|
return $startFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ([56, 70, 73, 74, 80] as $version) {
|
foreach ([56, 70, 71, 72, 73, 74, 80] as $version) {
|
||||||
if ($version < $startFrom) {
|
if ($version < $startFrom) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user