-
-
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 infinite loop on type recursive itself on Re…
…turnTypeFromStrictTypedCallRector (#3487) * [TypeDeclaration] Handle infinite loop on type recursive itself on ReturnTypeFromStrictTypedCallRector * eol
- Loading branch information
1 parent
e1dd98d
commit 4225ebf
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...lassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/skip_type_recursive_itself.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,29 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Source\SomeNode; | ||
|
||
class SkipTypeRecursiveCallItself | ||
{ | ||
public function run(SomeNode $node) | ||
{ | ||
return $this->oddLevel($node); | ||
} | ||
|
||
protected function oddLevel(SomeNode $node) | ||
{ | ||
if ($node->next) { | ||
return $this->evenLevel($node->next); | ||
} | ||
return $node->value; | ||
} | ||
|
||
protected function evenLevel(SomeNode $node) | ||
{ | ||
if ($node->next) { | ||
return $this->oddLevel($node->next); | ||
} | ||
return $node->value; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Source/SomeNode.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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Source; | ||
|
||
final class SomeNode | ||
{ | ||
public ?SomeNode $next; | ||
public string $value; | ||
} |
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