-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php74] Handle Multiple types with NullType on TypedPropertyRector wh…
…en PHP 8.0 Feature enabled (#1803) Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com> Co-authored-by: Jordan Gillet <jordan.gillet51@gmail.com> Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
2d94075
commit 03ce06d
Showing
5 changed files
with
98 additions
and
29 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
31 changes: 31 additions & 0 deletions
31
.../Rector/Property/TypedPropertyRector/FixtureUnionIntersectionTypes/multiple_types.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,31 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureUnionIntersectionTypes; | ||
|
||
final class MultipleTypes | ||
{ | ||
/** | ||
* @var string|int|float | ||
*/ | ||
private $nonNullableVariable; | ||
|
||
/** | ||
* @var string|int|float|null | ||
*/ | ||
private $nullableVariable; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixtureUnionIntersectionTypes; | ||
|
||
final class MultipleTypes | ||
{ | ||
private float|int|string $nonNullableVariable; | ||
|
||
private float|int|string|null $nullableVariable = null; | ||
} | ||
|
||
?> |
48 changes: 48 additions & 0 deletions
48
...tor/Property/TypedPropertyRector/FixtureUnionIntersectionTypes/nullable_var_union.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\FixtureUnionIntersectionTypes; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
|
||
final class NullableVarUnionClassLike | ||
{ | ||
/** | ||
* @var null|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\FixtureUnionIntersectionTypes; | ||
|
||
use Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass; | ||
|
||
final class NullableVarUnionClassLike | ||
{ | ||
private \Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Source\AnotherClass|\stdClass|null $anotherClass; | ||
|
||
public function __construct(?AnotherClass $anotherClass) | ||
{ | ||
$this->anotherClass = $anotherClass; | ||
} | ||
|
||
public function setStdClass() | ||
{ | ||
$this->anotherClass = new \stdClass; | ||
} | ||
} | ||
|
||
?> |
25 changes: 0 additions & 25 deletions
25
...roperty/TypedPropertyRector/FixtureUnionIntersectionTypes/skip_nullable_var_union.php.inc
This file was deleted.
Oops, something went wrong.
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