-
-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Handle inner function Yield and Return_ on ReturnTy…
…peFromStrictReturnExprRector (#2566) * [TypeDeclaration] Handle inner function Yield and Return_ on ReturnTypeFromStrictReturnExprRector * implemented 🎉
- Loading branch information
1 parent
6845975
commit c6fe564
Showing
3 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...Method/ReturnTypeFromStrictReturnExprRector/Fixture/void_return_in_inner_function.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,45 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictReturnExprRector\Fixture; | ||
|
||
final class VoidReturnInInnerFunction | ||
{ | ||
public function run() | ||
{ | ||
return $this->first() && true; | ||
} | ||
|
||
public function first() | ||
{ | ||
function () { | ||
return; | ||
}; | ||
|
||
return true; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictReturnExprRector\Fixture; | ||
|
||
final class VoidReturnInInnerFunction | ||
{ | ||
public function run(): bool | ||
{ | ||
return $this->first() && true; | ||
} | ||
|
||
public function first(): bool | ||
{ | ||
function () { | ||
return; | ||
}; | ||
|
||
return true; | ||
} | ||
} | ||
|
||
?> |
45 changes: 45 additions & 0 deletions
45
...ssMethod/ReturnTypeFromStrictReturnExprRector/Fixture/yield_parent_inner_function.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,45 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictReturnExprRector\Fixture; | ||
|
||
final class YieldParentInnerFunction | ||
{ | ||
public function run() | ||
{ | ||
return $this->first() && true; | ||
} | ||
|
||
public function first() | ||
{ | ||
function () { | ||
yield 1; | ||
}; | ||
|
||
return true; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictReturnExprRector\Fixture; | ||
|
||
final class YieldParentInnerFunction | ||
{ | ||
public function run(): bool | ||
{ | ||
return $this->first() && true; | ||
} | ||
|
||
public function first(): bool | ||
{ | ||
function () { | ||
yield 1; | ||
}; | ||
|
||
return true; | ||
} | ||
} | ||
|
||
?> |
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