-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Skip ExplicitMethodCallOverMagicGetSetRector on method …
…no param + variadic (#1768) * [CodeQuality] Skip ExplicitMethodCallOverMagicGetSetRector on method no param * [CodeQuality] Skip ExplicitMethodCallOverMagicGetSetRector on method no param * also check variadic * phpstan
- Loading branch information
1 parent
f374b9f
commit fd7667b
Showing
5 changed files
with
108 additions
and
10 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...ExplicitMethodCallOverMagicGetSetRector/Fixture/skip_no_method_no_param_on_assign.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector\Fixture; | ||
|
||
use Rector\Tests\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector\Source\ObjectWithMagicCallsNoParam; | ||
|
||
final class SkipNoMethodNoParamOnAssign | ||
{ | ||
public function run(ObjectWithMagicCallsNoParam $obj) | ||
{ | ||
$obj->name = 20; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...itMethodCallOverMagicGetSetRector/Fixture/skip_no_method_variadic_param_on_assign.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector\Fixture; | ||
|
||
use Rector\Tests\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector\Source\ObjectWithMagicCallsVariadicParam; | ||
|
||
final class SkipNoMethodVariadicParamOnAssign | ||
{ | ||
public function run(ObjectWithMagicCallsVariadicParam $obj) | ||
{ | ||
$obj->name = 20; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...pertyFetch/ExplicitMethodCallOverMagicGetSetRector/Source/ObjectWithMagicCallsNoParam.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector\Source; | ||
|
||
use Nette\SmartObject; | ||
|
||
final class ObjectWithMagicCallsNoParam | ||
{ | ||
// adds magic __get() and __set() methods | ||
use SmartObject; | ||
|
||
private $name; | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName() | ||
{ | ||
$this->name = 'test'; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...etch/ExplicitMethodCallOverMagicGetSetRector/Source/ObjectWithMagicCallsVariadicParam.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector\Source; | ||
|
||
use Nette\SmartObject; | ||
|
||
final class ObjectWithMagicCallsVariadicParam | ||
{ | ||
// adds magic __get() and __set() methods | ||
use SmartObject; | ||
|
||
private $name; | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(...$params) | ||
{ | ||
if (isset($params[1])) { | ||
$this->name = $params[0] . $params[1]; | ||
return; | ||
} | ||
|
||
$this->name = current($params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters