Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Return new static from different object on ReturnTy…
…peFromStrictTypedCallRector (#5357) * [TypeDeclaration] Return new static from different object on ReturnTypeFromStrictTypedCallRector * Fix
- Loading branch information
1 parent
fea5d6c
commit 0817980
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...Method/ReturnTypeFromStrictTypedCallRector/Fixture/return_static_different_object.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\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Source\SomeNamedConstructorClass; | ||
|
||
final class ReturnStaticDifferentObject | ||
{ | ||
public function getData() | ||
{ | ||
return SomeNamedConstructorClass::from(); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Source\SomeNamedConstructorClass; | ||
|
||
final class ReturnStaticDifferentObject | ||
{ | ||
public function getData(): \Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Source\SomeNamedConstructorClass | ||
{ | ||
return SomeNamedConstructorClass::from(); | ||
} | ||
} | ||
|
||
?> |
12 changes: 12 additions & 0 deletions
12
...ctor/ClassMethod/ReturnTypeFromStrictTypedCallRector/Source/SomeNamedConstructorClass.php
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Source; | ||
|
||
class SomeNamedConstructorClass { | ||
public static function from(): static | ||
{ | ||
return new static(); | ||
} | ||
} |
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