Skip to content

Commit 8ea2917

Browse files
authored
keep args in RemoveNullsafeOnCollectionRector (#426)
1 parent 56fe7ba commit 8ea2917

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Rector\Doctrine\Tests\TypedCollections\Rector\NullsafeMethodCall\RemoveNullsafeOnCollectionRector\Fixture;
4+
5+
use Doctrine\Common\Collections\ArrayCollection;
6+
use Doctrine\Common\Collections\Collection;
7+
8+
final class KeepArgs
9+
{
10+
public Collection $items;
11+
12+
public function someMethod()
13+
{
14+
$values = $this->items?->contains(1);
15+
}
16+
}
17+
18+
?>
19+
-----
20+
<?php
21+
22+
namespace Rector\Doctrine\Tests\TypedCollections\Rector\NullsafeMethodCall\RemoveNullsafeOnCollectionRector\Fixture;
23+
24+
use Doctrine\Common\Collections\ArrayCollection;
25+
use Doctrine\Common\Collections\Collection;
26+
27+
final class KeepArgs
28+
{
29+
public Collection $items;
30+
31+
public function someMethod()
32+
{
33+
$values = $this->items->contains(1);
34+
}
35+
}
36+
37+
?>

rules/TypedCollections/Rector/NullsafeMethodCall/RemoveNullsafeOnCollectionRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ public function refactor(Node $node): ?MethodCall
7171
return null;
7272
}
7373

74-
return new MethodCall($node->var, $node->name);
74+
return new MethodCall($node->var, $node->name, $node->args);
7575
}
7676
}

0 commit comments

Comments
 (0)