-
-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1432b7b
commit eeaf369
Showing
12 changed files
with
114 additions
and
108 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
43 changes: 0 additions & 43 deletions
43
rules-tests/Php74/Rector/Property/TypedPropertyRector/Fixture/json_body_trait.php.inc
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
rules-tests/Php74/Rector/Property/TypedPropertyRector/Fixture/skip_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,19 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Fixture; | ||
|
||
trait SkipTrait | ||
{ | ||
private $body; | ||
|
||
public function setJsonBody(array $body): self | ||
{ | ||
$this->body = $body; | ||
return $this; | ||
} | ||
|
||
public function getJsonBody(): ?array | ||
{ | ||
return $this->body; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Php74\TypeAnalyzer; | ||
|
||
use PhpParser\Node\Name; | ||
use PhpParser\Node\NullableType; | ||
use PHPStan\Type\NullType; | ||
use PHPStan\Type\Type; | ||
use PHPStan\Type\UnionType; | ||
|
||
final class PropertyUnionTypeResolver | ||
{ | ||
public function resolve(Name|NullableType|\PhpParser\Node\UnionType $phpUnionType, Type $possibleUnionType): Type | ||
{ | ||
if (! $phpUnionType instanceof NullableType) { | ||
return $possibleUnionType; | ||
} | ||
|
||
if (! $possibleUnionType instanceof UnionType) { | ||
return $possibleUnionType; | ||
} | ||
|
||
$types = $possibleUnionType->getTypes(); | ||
foreach ($types as $type) { | ||
if (! $type instanceof NullType) { | ||
return $type; | ||
} | ||
} | ||
|
||
return $possibleUnionType; | ||
} | ||
} |
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
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