-
-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Skip once typed and else return array_map() on Retu…
…rnTypeFromStrictTypedCallRector (#4312) * Add missing test case for native call When using a native call and returning first, here `array_map`, the `ReturnTypeFromStrictTypedCallRector` uses it directly and doesn't check that later `return` might return another type. * [TypeDeclaration] Skip once typed and else return array_map() on ReturnTypeFromStrictTypedCallRector --------- Co-authored-by: SelrahcD <[email protected]>
- Loading branch information
1 parent
df459e7
commit 1179698
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
.../ReturnTypeFromStrictTypedCallRector/Fixture/skip_once_type_and_native_call_first.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,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
final class SkipOnceTypeAndNativeCallFirst | ||
{ | ||
public function getData() | ||
{ | ||
if (false) { | ||
return array_map(function ($i) { | ||
return $i; | ||
}, []); | ||
} | ||
|
||
return $this->getString(); | ||
} | ||
|
||
private function getString() | ||
{ | ||
return '...'; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ReturnTypeFromStrictTypedCallRector/Fixture/skip_once_type_and_native_call_second.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,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector\Fixture; | ||
|
||
final class SkipOnceTypeAndNativeCallSecond | ||
{ | ||
public function getData() | ||
{ | ||
if (false) { | ||
return $this->getString(); | ||
} | ||
|
||
return array_map(function ($i) { | ||
return $i; | ||
}, []); | ||
} | ||
|
||
private function getString() | ||
{ | ||
return '...'; | ||
} | ||
} |
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