-
-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Skip nullable generic typed on ReturnTypeDeclaratio…
…nRector (#985) Co-authored-by: GitHub Action <[email protected]>
- Loading branch information
1 parent
3c0cb22
commit f6d0037
Showing
3 changed files
with
179 additions
and
1 deletion.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
...unctionLike/ReturnTypeDeclarationRector/Fixture/nullable_generic_return_not_typed.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,109 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector\Fixture; | ||
|
||
/** @return array<array<mixed>>|null */ | ||
function foo1(int $a, float $b) | ||
{ | ||
$bar = null; | ||
|
||
if ($a > 0) { | ||
for ($i = 0; $i < $a; $i++) { | ||
$bar[] = [ | ||
'a' => $a, | ||
'b' => $b, | ||
]; | ||
} | ||
} | ||
|
||
return $bar; | ||
} | ||
|
||
/** @return array{a: int, b: float}|null */ | ||
function foo2(int $a, float $b) | ||
{ | ||
$bar = null; | ||
|
||
if ($a > 0) { | ||
$bar = [ | ||
'a' => $a, | ||
'b' => $b, | ||
]; | ||
} | ||
|
||
return $bar; | ||
} | ||
|
||
/** @return array<array{a: int, b: float}>|null */ | ||
function foo3(int $a, float $b) | ||
{ | ||
$bar = null; | ||
|
||
if ($a > 0) { | ||
for ($i = 0; $i < $a; $i++) { | ||
$bar[] = [ | ||
'a' => $a, | ||
'b' => $b, | ||
]; | ||
} | ||
} | ||
|
||
return $bar; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector\Fixture; | ||
|
||
/** @return array<array<mixed>>|null */ | ||
function foo1(int $a, float $b): ?array | ||
{ | ||
$bar = null; | ||
|
||
if ($a > 0) { | ||
for ($i = 0; $i < $a; $i++) { | ||
$bar[] = [ | ||
'a' => $a, | ||
'b' => $b, | ||
]; | ||
} | ||
} | ||
|
||
return $bar; | ||
} | ||
|
||
/** @return array{a: int, b: float}|null */ | ||
function foo2(int $a, float $b): ?array | ||
{ | ||
$bar = null; | ||
|
||
if ($a > 0) { | ||
$bar = [ | ||
'a' => $a, | ||
'b' => $b, | ||
]; | ||
} | ||
|
||
return $bar; | ||
} | ||
|
||
/** @return array<array{a: int, b: float}>|null */ | ||
function foo3(int $a, float $b): ?array | ||
{ | ||
$bar = null; | ||
|
||
if ($a > 0) { | ||
for ($i = 0; $i < $a; $i++) { | ||
$bar[] = [ | ||
'a' => $a, | ||
'b' => $b, | ||
]; | ||
} | ||
} | ||
|
||
return $bar; | ||
} | ||
|
||
?> |
52 changes: 52 additions & 0 deletions
52
...nctionLike/ReturnTypeDeclarationRector/Fixture/skip_nullable_generic_return_typed.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,52 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector\Fixture; | ||
|
||
/** @return array<array<mixed>>|null */ | ||
function foo1(int $a, float $b): ?array | ||
{ | ||
$bar = null; | ||
|
||
if ($a > 0) { | ||
for ($i = 0; $i < $a; $i++) { | ||
$bar[] = [ | ||
'a' => $a, | ||
'b' => $b, | ||
]; | ||
} | ||
} | ||
|
||
return $bar; | ||
} | ||
|
||
/** @return array{a: int, b: float}|null */ | ||
function foo2(int $a, float $b): ?array | ||
{ | ||
$bar = null; | ||
|
||
if ($a > 0) { | ||
$bar = [ | ||
'a' => $a, | ||
'b' => $b, | ||
]; | ||
} | ||
|
||
return $bar; | ||
} | ||
|
||
/** @return array<array{a: int, b: float}>|null */ | ||
function foo3(int $a, float $b): ?array | ||
{ | ||
$bar = null; | ||
|
||
if ($a > 0) { | ||
for ($i = 0; $i < $a; $i++) { | ||
$bar[] = [ | ||
'a' => $a, | ||
'b' => $b, | ||
]; | ||
} | ||
} | ||
|
||
return $bar; | ||
} |
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