-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PHPStanStaticTypeMapper] Handle Nullable Type on UnionType on UnionT…
…ypeMapper when possible (#3173)
- Loading branch information
1 parent
bbd9d4f
commit 863fee3
Showing
7 changed files
with
129 additions
and
50 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
39 changes: 39 additions & 0 deletions
39
.../Property/AddFalseDefaultToBoolPropertyRector/Fixture/assigned_in_construct_trait.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\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector\Fixture; | ||
|
||
// __construct can be overridden by class that consume it, @see https://3v4l.org/MZFmT#v7.0.28 | ||
trait AssignInConstructTrait | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $property; | ||
|
||
public function __construct(bool $property) | ||
{ | ||
$this->property = $property; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector\Fixture; | ||
|
||
// __construct can be overridden by class that consume it, @see https://3v4l.org/MZFmT#v7.0.28 | ||
trait AssignInConstructTrait | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $property = false; | ||
|
||
public function __construct(bool $property) | ||
{ | ||
$this->property = $property; | ||
} | ||
} | ||
|
||
?> |
16 changes: 0 additions & 16 deletions
16
.../Property/AddFalseDefaultToBoolPropertyRector/Fixture/skip_assigned_in_construct2.php.inc
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
.../TypedPropertyFromAssignsRector/Fixture/anonymous_extends_existing_class_in_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,39 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class AnonymousExtendsExistingClassInUnion | ||
{ | ||
private $x; | ||
|
||
public function __construct() | ||
{ | ||
if (rand(0,1)) { | ||
$this->x = new \DateTime('now'); | ||
} else { | ||
$this->x = new class extends \DateTime {}; | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class AnonymousExtendsExistingClassInUnion | ||
{ | ||
private ?\DateTime $x = null; | ||
|
||
public function __construct() | ||
{ | ||
if (rand(0,1)) { | ||
$this->x = new \DateTime('now'); | ||
} else { | ||
$this->x = new class extends \DateTime {}; | ||
} | ||
} | ||
} | ||
|
||
?> |
17 changes: 0 additions & 17 deletions
17
...dPropertyFromAssignsRector/Fixture/skip_anonymous_extends_existing_class_in_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
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