-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Transform] Add type matching to MethodCallToPropertyFetchRector (#1905)
- Loading branch information
1 parent
460e0b4
commit 00e857f
Showing
7 changed files
with
74 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
12 changes: 12 additions & 0 deletions
12
...s/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector/Source/RenameToProperty.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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector\Source; | ||
|
||
final class RenameToProperty | ||
{ | ||
public function getEntityManager() | ||
{ | ||
} | ||
} |
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
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
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,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Transform\ValueObject; | ||
|
||
use PHPStan\Type\ObjectType; | ||
use Rector\Core\Validation\RectorAssert; | ||
|
||
final class MethodCallToPropertyFetch | ||
{ | ||
public function __construct( | ||
private readonly string $oldType, | ||
private readonly string $oldMethod, | ||
private readonly string $newProperty, | ||
) { | ||
RectorAssert::className($oldType); | ||
} | ||
|
||
public function getOldObjectType(): ObjectType | ||
{ | ||
return new ObjectType($this->oldType); | ||
} | ||
|
||
public function getNewProperty(): string | ||
{ | ||
return $this->newProperty; | ||
} | ||
|
||
public function getOldMethod(): string | ||
{ | ||
return $this->oldMethod; | ||
} | ||
} |