-
-
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] Handle Parent ClassMethod has no Return_ stmt on Re…
…turnTypeDeclarationRector (#2980) * [TypeDeclaration] Handle Parent ClassMethod has no Return_ stmt on ReturnTypeDeclarationRector * [ci-review] Rector Rectify * check child return type * handle both parent and child void * final touch: eol * better comment Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
0c2b4f7
commit 1d88337
Showing
3 changed files
with
127 additions
and
1 deletion.
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
53 changes: 53 additions & 0 deletions
53
.../FunctionLike/ReturnTypeDeclarationRector/Fixture/parent_and_child_no_return_stmt.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,53 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector\Fixture; | ||
|
||
/** | ||
* Both class parent and child need to be in same fixture file | ||
* as demonstrate the changed parts are both | ||
*/ | ||
class ParentNoReturnStmt2 | ||
{ | ||
public function run() | ||
{ | ||
// this method is optional, not marked as abstract | ||
// and leave the child to implements or not | ||
} | ||
} | ||
|
||
final class SomeChildOverrideParentMethod2 extends ParentNoReturnStmt2 | ||
{ | ||
public function run() | ||
{ | ||
echo 'test'; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector\Fixture; | ||
|
||
/** | ||
* Both class parent and child need to be in same fixture file | ||
* as demonstrate the changed parts are both | ||
*/ | ||
class ParentNoReturnStmt2 | ||
{ | ||
public function run(): void | ||
{ | ||
// this method is optional, not marked as abstract | ||
// and leave the child to implements or not | ||
} | ||
} | ||
|
||
final class SomeChildOverrideParentMethod2 extends ParentNoReturnStmt2 | ||
{ | ||
public function run(): void | ||
{ | ||
echo 'test'; | ||
} | ||
} | ||
|
||
?> |
63 changes: 63 additions & 0 deletions
63
...ion/Rector/FunctionLike/ReturnTypeDeclarationRector/Fixture/parent_no_return_stmt.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,63 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector\Fixture; | ||
|
||
use stdClass; | ||
|
||
/** | ||
* Both class parent and child need to be in same fixture file | ||
* as demonstrate the changed parts are both, which should only child | ||
*/ | ||
class ParentNoReturnStmt | ||
{ | ||
/** | ||
* @return stdClass | ||
*/ | ||
public function run() | ||
{ | ||
// this method is optional, not marked as abstract | ||
// and leave the child to implements or not | ||
} | ||
} | ||
|
||
final class SomeChildOverrideParentMethod extends ParentNoReturnStmt | ||
{ | ||
public function run() | ||
{ | ||
return new stdClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector\Fixture; | ||
|
||
use stdClass; | ||
|
||
/** | ||
* Both class parent and child need to be in same fixture file | ||
* as demonstrate the changed parts are both, which should only child | ||
*/ | ||
class ParentNoReturnStmt | ||
{ | ||
/** | ||
* @return stdClass | ||
*/ | ||
public function run() | ||
{ | ||
// this method is optional, not marked as abstract | ||
// and leave the child to implements or not | ||
} | ||
} | ||
|
||
final class SomeChildOverrideParentMethod extends ParentNoReturnStmt | ||
{ | ||
public function run(): \stdClass | ||
{ | ||
return new stdClass; | ||
} | ||
} | ||
|
||
?> |