File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
rules/DowngradePhp84/Rector/FuncCall Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 77use PhpParser \Node ;
88use PhpParser \Node \Expr \ClassConstFetch ;
99use PhpParser \Node \Expr \MethodCall ;
10+ use PhpParser \Node \Name ;
1011use Rector \Rector \AbstractRector ;
1112use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
1213use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
@@ -46,7 +47,7 @@ public function getRuleDefinition(): RuleDefinition
4647 */
4748 public function refactor (Node $ node ): ?Node
4849 {
49- if (!$ this ->isName ($ node , 'round ' )) {
50+ if (! $ this ->isName ($ node , 'round ' )) {
5051 return null ;
5152 }
5253
@@ -60,14 +61,17 @@ public function refactor(Node $node): ?Node
6061 return null ;
6162 }
6263
63- if (!isset ($ args [2 ])) {
64+ if (! isset ($ args [2 ])) {
6465 return null ;
6566 }
6667
6768 $ modeArg = $ args [2 ]->value ;
6869 $ hasChanged = false ;
6970 if ($ modeArg instanceof ClassConstFetch) {
70- if ($ modeArg ->class ->name === 'RoundingMode ' ) {
71+ if ($ modeArg ->class instanceof Name && $ modeArg ->class ->name === 'RoundingMode ' ) {
72+ if (!($ modeArg ->name instanceof Node \Identifier)) {
73+ return null ;
74+ }
7175 $ constantName = match ($ modeArg ->name ->name ) {
7276 'HalfAwayFromZero ' => 'PHP_ROUND_HALF_UP ' ,
7377 'HalfTowardsZero ' => 'PHP_ROUND_HALF_DOWN ' ,
You can’t perform that action at this time.
0 commit comments