From 12a33c4a33e9c35bdb27cb4db62ee8bfe5a0e9f8 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 5 Oct 2020 11:35:11 +0200 Subject: [PATCH] More transforms --- src/Plugin/NestedExpressionFixer.php | 6 +- src/Target/Php70/IssetExpressionFixer.php | 78 ++- src/Target/Php70/NestedExpressionFixer.php | 78 ++- src/Target/Php70/NullCoalesceReplacer.php | 37 +- src/Target/Php71/IssetExpressionFixer.php | 4 - src/Target/Php71/ListExpression.php | 37 ++ src/Target/Php71/NestedExpressionFixer.php | 4 - src/Target/Php72/IssetExpressionFixer.php | 4 - src/Target/Php72/NestedExpressionFixer.php | 4 - src/Target/Php73/IssetExpressionFixer.php | 4 - src/Target/Php73/ListReference.php | 4 +- src/Target/Php73/NestedExpressionFixer.php | 4 - src/Target/Php74/IssetExpressionFixer.php | 4 - src/Target/Php74/NestedExpressionFixer.php | 4 - src/Target/Php80/IssetExpressionFixer.php | 33 +- src/Target/Php80/NestedExpressionFixer.php | 570 ++++++++++++++++++++- test/exprGen.php | 2 +- 17 files changed, 814 insertions(+), 63 deletions(-) create mode 100644 src/Target/Php71/ListExpression.php diff --git a/src/Plugin/NestedExpressionFixer.php b/src/Plugin/NestedExpressionFixer.php index 2cb478c..86ec09f 100644 --- a/src/Plugin/NestedExpressionFixer.php +++ b/src/Plugin/NestedExpressionFixer.php @@ -101,12 +101,14 @@ class NestedExpressionFixer extends Plugin new LNumber(0) ); // 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 StaticPropertyFetch::class: case FuncCall::class: $this->traverser->traverseAst($expr); $valueCopy = $value; + $context->insertBefore($expr, new Assign($value = $context->getVariable(), $valueCopy)); + /* return new ErrorSuppress( new MethodCall( self::callPoly( @@ -122,7 +124,7 @@ class NestedExpressionFixer extends Plugin ), '__invoke' ) - ); + );*/ } } } diff --git a/src/Target/Php70/IssetExpressionFixer.php b/src/Target/Php70/IssetExpressionFixer.php index 89f0493..69a5c86 100644 --- a/src/Target/Php70/IssetExpressionFixer.php +++ b/src/Target/Php70/IssetExpressionFixer.php @@ -5,10 +5,6 @@ namespace Phabel\Target\Php70; use Phabel\Plugin; use Phabel\Plugin\IssetExpressionFixer as fixer; -/** - * @author Daniil Gentili - * @license MIT - */ class IssetExpressionFixer extends Plugin { /** @@ -112,14 +108,88 @@ class IssetExpressionFixer extends Plugin [ '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\\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\\Include_' => true, + 'PhpParser\\Node\\Expr\\Instanceof_' => true, + 'PhpParser\\Node\\Expr\\Isset_' => 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\\ShellExec' => true, 'PhpParser\\Node\\Expr\\StaticCall' => 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\\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\\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' => diff --git a/src/Target/Php70/NestedExpressionFixer.php b/src/Target/Php70/NestedExpressionFixer.php index 959590c..c13dd1a 100644 --- a/src/Target/Php70/NestedExpressionFixer.php +++ b/src/Target/Php70/NestedExpressionFixer.php @@ -5,10 +5,6 @@ namespace Phabel\Target\Php70; use Phabel\Plugin; use Phabel\Plugin\NestedExpressionFixer as fixer; -/** - * @author Daniil Gentili - * @license MIT - */ class NestedExpressionFixer extends Plugin { /** @@ -108,14 +104,88 @@ class NestedExpressionFixer extends Plugin [ '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\\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\\Include_' => true, + 'PhpParser\\Node\\Expr\\Instanceof_' => true, + 'PhpParser\\Node\\Expr\\Isset_' => 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\\ShellExec' => true, 'PhpParser\\Node\\Expr\\StaticCall' => 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\\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\\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' => diff --git a/src/Target/Php70/NullCoalesceReplacer.php b/src/Target/Php70/NullCoalesceReplacer.php index 1523e8c..e6e8580 100644 --- a/src/Target/Php70/NullCoalesceReplacer.php +++ b/src/Target/Php70/NullCoalesceReplacer.php @@ -3,9 +3,14 @@ namespace Phabel\Target\Php70; use Phabel\Plugin; +use Phabel\Target\Php74\ArrowClosure; +use Phabel\Tools; use PhpParser\Node; +use PhpParser\Node\Expr; +use PhpParser\Node\Expr\ArrowFunction; use PhpParser\Node\Expr\BinaryOp\Coalesce; -use PhpParser\Node\Expr\StaticCall; +use PhpParser\Node\Expr\Isset_; +use PhpParser\Node\Expr\Ternary; /** * @author Daniil Gentili @@ -18,14 +23,22 @@ class NullCoalesceReplacer extends Plugin * * @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)) { $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. @@ -39,4 +52,20 @@ class NullCoalesceReplacer extends Plugin { return isset($ifNotNull) ? $ifNotNull : $then; } + /** + * Coalesce (with side effects on the right). + * + * @param null|mixed $ifNotNull If not null, return this + * @param callable $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]; + } } diff --git a/src/Target/Php71/IssetExpressionFixer.php b/src/Target/Php71/IssetExpressionFixer.php index 4faad9a..eee203a 100644 --- a/src/Target/Php71/IssetExpressionFixer.php +++ b/src/Target/Php71/IssetExpressionFixer.php @@ -4,10 +4,6 @@ namespace Phabel\Target\Php71; use Phabel\Plugin; -/** - * @author Daniil Gentili - * @license MIT - */ class IssetExpressionFixer extends Plugin { } diff --git a/src/Target/Php71/ListExpression.php b/src/Target/Php71/ListExpression.php new file mode 100644 index 0000000..7332806 --- /dev/null +++ b/src/Target/Php71/ListExpression.php @@ -0,0 +1,37 @@ +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; + } +} diff --git a/src/Target/Php71/NestedExpressionFixer.php b/src/Target/Php71/NestedExpressionFixer.php index c9792d8..5b33376 100644 --- a/src/Target/Php71/NestedExpressionFixer.php +++ b/src/Target/Php71/NestedExpressionFixer.php @@ -4,10 +4,6 @@ namespace Phabel\Target\Php71; use Phabel\Plugin; -/** - * @author Daniil Gentili - * @license MIT - */ class NestedExpressionFixer extends Plugin { } diff --git a/src/Target/Php72/IssetExpressionFixer.php b/src/Target/Php72/IssetExpressionFixer.php index b2849e7..7dd3a91 100644 --- a/src/Target/Php72/IssetExpressionFixer.php +++ b/src/Target/Php72/IssetExpressionFixer.php @@ -4,10 +4,6 @@ namespace Phabel\Target\Php72; use Phabel\Plugin; -/** - * @author Daniil Gentili - * @license MIT - */ class IssetExpressionFixer extends Plugin { } diff --git a/src/Target/Php72/NestedExpressionFixer.php b/src/Target/Php72/NestedExpressionFixer.php index 7c12d25..5fac756 100644 --- a/src/Target/Php72/NestedExpressionFixer.php +++ b/src/Target/Php72/NestedExpressionFixer.php @@ -4,10 +4,6 @@ namespace Phabel\Target\Php72; use Phabel\Plugin; -/** - * @author Daniil Gentili - * @license MIT - */ class NestedExpressionFixer extends Plugin { } diff --git a/src/Target/Php73/IssetExpressionFixer.php b/src/Target/Php73/IssetExpressionFixer.php index a637994..9be43a8 100644 --- a/src/Target/Php73/IssetExpressionFixer.php +++ b/src/Target/Php73/IssetExpressionFixer.php @@ -4,10 +4,6 @@ namespace Phabel\Target\Php73; use Phabel\Plugin; -/** - * @author Daniil Gentili - * @license MIT - */ class IssetExpressionFixer extends Plugin { } diff --git a/src/Target/Php73/ListReference.php b/src/Target/Php73/ListReference.php index 12076c0..db0dacb 100644 --- a/src/Target/Php73/ListReference.php +++ b/src/Target/Php73/ListReference.php @@ -57,7 +57,7 @@ class ListReference extends Plugin 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); return $var; } @@ -69,7 +69,7 @@ class ListReference extends Plugin * * @return (Assign|AssignRef)[] */ - private static function splitList($list, Variable $var): array + public static function splitList($list, Variable $var): array { $assignments = []; $key = 0; // Technically a list assignment does not support mixed keys, but we need this for nested assignments diff --git a/src/Target/Php73/NestedExpressionFixer.php b/src/Target/Php73/NestedExpressionFixer.php index 83ba09c..040ec38 100644 --- a/src/Target/Php73/NestedExpressionFixer.php +++ b/src/Target/Php73/NestedExpressionFixer.php @@ -5,10 +5,6 @@ namespace Phabel\Target\Php73; use Phabel\Plugin; use Phabel\Plugin\NestedExpressionFixer as fixer; -/** - * @author Daniil Gentili - * @license MIT - */ class NestedExpressionFixer extends Plugin { /** diff --git a/src/Target/Php74/IssetExpressionFixer.php b/src/Target/Php74/IssetExpressionFixer.php index 6b659a5..318138a 100644 --- a/src/Target/Php74/IssetExpressionFixer.php +++ b/src/Target/Php74/IssetExpressionFixer.php @@ -4,10 +4,6 @@ namespace Phabel\Target\Php74; use Phabel\Plugin; -/** - * @author Daniil Gentili - * @license MIT - */ class IssetExpressionFixer extends Plugin { } diff --git a/src/Target/Php74/NestedExpressionFixer.php b/src/Target/Php74/NestedExpressionFixer.php index e681aac..7857691 100644 --- a/src/Target/Php74/NestedExpressionFixer.php +++ b/src/Target/Php74/NestedExpressionFixer.php @@ -4,10 +4,6 @@ namespace Phabel\Target\Php74; use Phabel\Plugin; -/** - * @author Daniil Gentili - * @license MIT - */ class NestedExpressionFixer extends Plugin { } diff --git a/src/Target/Php80/IssetExpressionFixer.php b/src/Target/Php80/IssetExpressionFixer.php index 8142636..48aa514 100644 --- a/src/Target/Php80/IssetExpressionFixer.php +++ b/src/Target/Php80/IssetExpressionFixer.php @@ -5,10 +5,6 @@ namespace Phabel\Target\Php80; use Phabel\Plugin; use Phabel\Plugin\IssetExpressionFixer as fixer; -/** - * @author Daniil Gentili - * @license MIT - */ class IssetExpressionFixer extends Plugin { /** @@ -20,11 +16,15 @@ class IssetExpressionFixer extends Plugin { return [ 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' => @@ -32,6 +32,25 @@ class IssetExpressionFixer extends Plugin 'var' => [ '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, ], ], ] diff --git a/src/Target/Php80/NestedExpressionFixer.php b/src/Target/Php80/NestedExpressionFixer.php index 36fd033..d7dfc57 100644 --- a/src/Target/Php80/NestedExpressionFixer.php +++ b/src/Target/Php80/NestedExpressionFixer.php @@ -5,10 +5,6 @@ namespace Phabel\Target\Php80; use Phabel\Plugin; use Phabel\Plugin\NestedExpressionFixer as fixer; -/** - * @author Daniil Gentili - * @license MIT - */ class NestedExpressionFixer extends Plugin { /** @@ -20,11 +16,64 @@ class NestedExpressionFixer extends Plugin { return [ 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_' => @@ -33,10 +82,26 @@ class NestedExpressionFixer extends Plugin [ '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\\AssignOp\\BitwiseAnd' => true, @@ -73,11 +138,26 @@ class NestedExpressionFixer extends Plugin '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\\MethodCall' => @@ -85,13 +165,98 @@ class NestedExpressionFixer extends Plugin 'var' => [ 'PhpParser\\Node\\Expr\\ConstFetch' => true, + 'PhpParser\\Node\\Expr\\Throw_' => true, ], ], 'PhpParser\\Node\\Expr\\New_' => [ '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\\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' => @@ -99,6 +264,397 @@ class NestedExpressionFixer extends Plugin 'var' => [ '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, ], ], ] diff --git a/test/exprGen.php b/test/exprGen.php index 6d403b6..1500f4a 100644 --- a/test/exprGen.php +++ b/test/exprGen.php @@ -86,7 +86,7 @@ function checkSyntax(string $code, int $startFrom = 56): int return $startFrom; } - foreach ([56, 70, 73, 74, 80] as $version) { + foreach ([56, 70, 71, 72, 73, 74, 80] as $version) { if ($version < $startFrom) { continue; }