-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Handle initialized on getter on ReturnTypeFromStric…
…tTypedPropertyRector (#5784) * Added failling test * update fixture * Fixes #5775 --------- Co-authored-by: Markus Staab <[email protected]>
- Loading branch information
1 parent
93e0259
commit 4c40eb6
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...ClassMethod/ReturnTypeFromStrictTypedPropertyRector/Fixture/initialized_in_getter.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\ClassMethod\ReturnTypeFromStrictTypedPropertyRector\Fixture; | ||
|
||
use stdClass; | ||
|
||
final class InitializedInGetter | ||
{ | ||
private ?stdClass $demo = null; | ||
|
||
public function getDemo() { | ||
if ($this->demo === null) { | ||
$this->demo = new stdClass(); | ||
} | ||
return $this->demo; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector\Fixture; | ||
|
||
use stdClass; | ||
|
||
final class InitializedInGetter | ||
{ | ||
private ?stdClass $demo = null; | ||
|
||
public function getDemo(): \stdClass { | ||
if ($this->demo === null) { | ||
$this->demo = new stdClass(); | ||
} | ||
return $this->demo; | ||
} | ||
} | ||
|
||
?> |
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