Skip to content

Commit 31fe44a

Browse files
committed
skip new arg falsy
1 parent 1531a9e commit 31fe44a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeSubstrFalsyRector\Fixture;
4+
5+
class SkipNewArgFalsy
6+
{
7+
public function __construct(false|string $value)
8+
{
9+
}
10+
11+
public function run()
12+
{
13+
new self(substr('a', 2));
14+
}
15+
}

rules/DowngradePhp80/Rector/FuncCall/DowngradeSubstrFalsyRector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use PhpParser\Node\Expr\Empty_;
2121
use PhpParser\Node\Expr\FuncCall;
2222
use PhpParser\Node\Expr\MethodCall;
23+
use PhpParser\Node\Expr\New_;
2324
use PhpParser\Node\Expr\StaticCall;
2425
use PhpParser\Node\Expr\Ternary;
2526
use PhpParser\Node\Stmt\Do_;
@@ -76,6 +77,7 @@ public function getNodeTypes(): array
7677
Concat::class,
7778
MethodCall::class,
7879
StaticCall::class,
80+
New_::class,
7981
AssignOp::class,
8082
If_::class,
8183
While_::class,
@@ -88,7 +90,7 @@ public function getNodeTypes(): array
8890
}
8991

9092
/**
91-
* @param Cast|Empty_|BooleanNot|Ternary|Identical|Concat|MethodCall|StaticCall|AssignOp|If_|While_|Do_|ArrayItem|ArrayDimFetch|BinaryOp|FuncCall $node
93+
* @param Cast|Empty_|BooleanNot|Ternary|Identical|Concat|MethodCall|StaticCall|New_|AssignOp|If_|While_|Do_|ArrayItem|ArrayDimFetch|BinaryOp|FuncCall $node
9294
*/
9395
public function refactor(Node $node): ?Node
9496
{

0 commit comments

Comments
 (0)