Skip to content

Commit 01aa254

Browse files
committed
skip getter
1 parent 3340413 commit 01aa254

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\Unambiguous\Rector\Expression\FluentSettersToStandaloneCallMethodRector\Fixture;
6+
7+
use Rector\Tests\Unambiguous\Rector\Expression\FluentSettersToStandaloneCallMethodRector\Source\GetterSetterClass;
8+
9+
final class SkipGetterSetter
10+
{
11+
public function setup()
12+
{
13+
return (new GetterSetterClass())
14+
->getter()
15+
->setName('John')
16+
->setSurname('Doe');
17+
}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Rector\Tests\Unambiguous\Rector\Expression\FluentSettersToStandaloneCallMethodRector\Source;
4+
5+
final class GetterSetterClass
6+
{
7+
public function getter()
8+
{
9+
return new SomeSetterClass();
10+
}
11+
}

rules/Unambiguous/Rector/Expression/FluentSettersToStandaloneCallMethodRector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ public function refactor(Node $node): ?array
9898

9999
$currentMethodCall = $firstMethodCall;
100100
while ($currentMethodCall instanceof MethodCall) {
101+
// must be exactly one argument
102+
if (count($currentMethodCall->getArgs()) !== 1) {
103+
return null;
104+
}
105+
101106
$methodCalls[] = $currentMethodCall;
102107
$currentMethodCall = $currentMethodCall->var;
103108
}

0 commit comments

Comments
 (0)