-
-
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.
[TypeDeclaration] Skip unitialized property on EmptyOnNullableObjectT…
…oInstanceOfRector (#5889) * [TypeDeclaration] Skip unitialized property on EmptyOnNullableObjectToInstanceOfRector * fixture update * fixture update * fixture update
- Loading branch information
1 parent
2deccac
commit 1986376
Showing
3 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
.../Empty_/EmptyOnNullableObjectToInstanceOfRector/Fixture/skip_unitialized_property.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,21 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector\Source\AnotherObject; | ||
|
||
final class SkipUnitializedProperty | ||
{ | ||
private AnotherObject $id; | ||
|
||
public function setId(AnotherObject $id): self | ||
{ | ||
if (!empty($this->id) && !$id->equals($this->id)) { | ||
throw new \InvalidArgumentException('The ID is already set.'); | ||
} | ||
|
||
$this->id = $id; | ||
|
||
return $this; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,5 +4,8 @@ | |
|
||
final class AnotherObject | ||
{ | ||
|
||
public function equals(AnotherObject $anotherObject) | ||
{ | ||
return (bool) rand(0, 1); | ||
} | ||
} |
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