-
-
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.
[Php74] Handle conflict with alias on TypedPropertyRector (#899)
* [Php74] Handle conflict with alias on TypedPropertyRector * update * more conflict example * update * update * Fixed 🎉 * added failing fixture alias never used * Fixed 🎉 * clean up * clean up * union failign test * Fixed 🎉 * cs fix * Fixed 🎉 * Fixed 🎉 * skip nullable var union * more fixtures on use alias only * final touch: more fixture
- Loading branch information
1 parent
a8a79d0
commit e78fadd
Showing
14 changed files
with
527 additions
and
19 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
.../Rector/Property/TypedPropertyRector/FixtureClassLikeTypeOnly/conflict_with_alias.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,40 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias | ||
{ | ||
/** | ||
* @var Alias | ||
*/ | ||
private $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias | ||
{ | ||
private Alias $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> |
40 changes: 40 additions & 0 deletions
40
...Rector/Property/TypedPropertyRector/FixtureClassLikeTypeOnly/conflict_with_alias2.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,40 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias2 | ||
{ | ||
/** | ||
* @var AnotherClass | ||
*/ | ||
private $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias2 | ||
{ | ||
private \Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> |
50 changes: 50 additions & 0 deletions
50
...Rector/Property/TypedPropertyRector/FixtureClassLikeTypeOnly/conflict_with_alias3.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,50 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias3 | ||
{ | ||
/** | ||
* @var AnotherClass|\stdClass | ||
*/ | ||
private $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
|
||
public function setStdClass() | ||
{ | ||
$this->anotherClass = new \stdClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias3 | ||
{ | ||
private \Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass|\stdClass $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
|
||
public function setStdClass() | ||
{ | ||
$this->anotherClass = new \stdClass; | ||
} | ||
} | ||
|
||
?> |
50 changes: 50 additions & 0 deletions
50
...Rector/Property/TypedPropertyRector/FixtureClassLikeTypeOnly/conflict_with_alias4.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,50 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias4 | ||
{ | ||
/** | ||
* @var Alias|\stdClass | ||
*/ | ||
private $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
|
||
public function setStdClass() | ||
{ | ||
$this->anotherClass = new \stdClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias4 | ||
{ | ||
private Alias|\stdClass $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
|
||
public function setStdClass() | ||
{ | ||
$this->anotherClass = new \stdClass; | ||
} | ||
} | ||
|
||
?> |
26 changes: 26 additions & 0 deletions
26
...r/Property/TypedPropertyRector/FixtureClassLikeTypeOnly/skip_invalid_var_nullable.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\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class SkipInvalidvarNullable | ||
{ | ||
/** | ||
* @var ?AnotherClass|\stdClass | ||
*/ | ||
private $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
|
||
public function setStdClass() | ||
{ | ||
$this->anotherClass = new \stdClass; | ||
} | ||
} | ||
|
||
?> |
38 changes: 38 additions & 0 deletions
38
...Php74/Rector/Property/TypedPropertyRector/FixtureClassLikeTypeOnly/use_alias_only.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,38 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class UseAliasOnly | ||
{ | ||
/** | ||
* @var Alias | ||
*/ | ||
private $anotherClass; | ||
|
||
public function __construct(Alias $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class UseAliasOnly | ||
{ | ||
private Alias $anotherClass; | ||
|
||
public function __construct(Alias $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> |
48 changes: 48 additions & 0 deletions
48
...hp74/Rector/Property/TypedPropertyRector/FixtureClassLikeTypeOnly/use_alias_only2.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,48 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class UseAliasOnly2 | ||
{ | ||
/** | ||
* @var Alias|\stdClass | ||
*/ | ||
private $anotherClass; | ||
|
||
public function __construct(Alias $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
|
||
public function setStdClass() | ||
{ | ||
$this->anotherClass = new \stdClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class UseAliasOnly2 | ||
{ | ||
private Alias|\stdClass $anotherClass; | ||
|
||
public function __construct(Alias $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
|
||
public function setStdClass() | ||
{ | ||
$this->anotherClass = new \stdClass; | ||
} | ||
} | ||
|
||
?> |
35 changes: 35 additions & 0 deletions
35
...hp74/Rector/Property/TypedPropertyRector/FixtureClassLikeTypeOnly/use_alias_only3.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,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class UseAliasOnly3 | ||
{ | ||
private $anotherClass; | ||
|
||
public function __construct(Alias $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureClassLikeTypeOnly; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class UseAliasOnly3 | ||
{ | ||
private Alias $anotherClass; | ||
|
||
public function __construct(Alias $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> |
40 changes: 40 additions & 0 deletions
40
...sts/Php74/Rector/Property/TypedPropertyRector/FixtureImported/conflict_with_alias.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,40 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureImported; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias | ||
{ | ||
/** | ||
* @var Alias | ||
*/ | ||
private $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureImported; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass as Alias; | ||
|
||
final class ConflictWithAlias | ||
{ | ||
private Alias $anotherClass; | ||
|
||
public function __construct(AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
} | ||
|
||
?> |
Oops, something went wrong.