Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Add If else assign support on TypedPropertyFromAssi…
…gnsRector (#5314) Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
368075b
commit be924be
Showing
8 changed files
with
145 additions
and
6 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
39 changes: 39 additions & 0 deletions
39
...Declaration/Rector/Property/TypedPropertyFromAssignsRector/Fixture/if_else_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,39 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class IfElseAssign | ||
{ | ||
private $apiUrl; | ||
|
||
public function __construct() | ||
{ | ||
if (rand(0,1)) { | ||
$this->apiUrl = 'https://example.com/'; | ||
} else { | ||
$this->apiUrl = 'https://another.example.com/'; | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class IfElseAssign | ||
{ | ||
private string $apiUrl; | ||
|
||
public function __construct() | ||
{ | ||
if (rand(0,1)) { | ||
$this->apiUrl = 'https://example.com/'; | ||
} else { | ||
$this->apiUrl = 'https://another.example.com/'; | ||
} | ||
} | ||
} | ||
|
||
?> |
43 changes: 43 additions & 0 deletions
43
...ion/Rector/Property/TypedPropertyFromAssignsRector/Fixture/if_else_assign_complex.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,43 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class IfElseAssignComplex | ||
{ | ||
private $apiUrl; | ||
|
||
public function __construct() | ||
{ | ||
if (rand(0,1)) { | ||
if (rand(0, 1)) { | ||
$this->apiUrl = 'https://example.com/'; | ||
} | ||
} else { | ||
$this->apiUrl = 'https://another.example.com/'; | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class IfElseAssignComplex | ||
{ | ||
private ?string $apiUrl = null; | ||
|
||
public function __construct() | ||
{ | ||
if (rand(0,1)) { | ||
if (rand(0, 1)) { | ||
$this->apiUrl = 'https://example.com/'; | ||
} | ||
} else { | ||
$this->apiUrl = 'https://another.example.com/'; | ||
} | ||
} | ||
} | ||
|
||
?> |
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
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