-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php81] Skip ReadOnlyPropertyRector on Clone $this (#1599)
* add failing test for cloned properties Signed-off-by: Gary Lockett <[email protected]> * [Php81] Skip ReadOnlyPropertyRector on Clone $this * final touch: ensure name is equal * final touch: ensure use TypeWithClassName with check class name is equal * phpstan * flip if to reduce deep if * final touch: early check name not equals, then check type * comment * comment * comment * comment * final touch: re-use found Class_ Co-authored-by: Gary Lockett <[email protected]>
- Loading branch information
1 parent
bc09bdc
commit 311ffc6
Showing
2 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_write_also_cloned_property.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,26 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php81\Rector\Property\ReadOnlyPropertyRector\Fixture; | ||
|
||
final class SkipWriteAlsoClonedProperty | ||
{ | ||
private string $name; | ||
|
||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function withName(string $name): self | ||
{ | ||
$clone = clone $this; | ||
$clone->name = $name; | ||
|
||
return $clone; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
} |
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