-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Skip union false on NumericReturnTypeFromStrictScal…
…arReturnsRector (#5204) * [TypeDeclaration] Skip union false on NumericReturnTypeFromStrictScalarReturnsRector * Fix * int and float fixture * skip int|float * fix
- Loading branch information
1 parent
be0cc77
commit 89b3e62
Showing
4 changed files
with
75 additions
and
99 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...Rector/ClassMethod/NumericReturnTypeFromStrictScalarReturnsRector/Fixture/int_int.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,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector\Fixture; | ||
|
||
final class IntInt | ||
{ | ||
public function resolve($param, int $first, int $second) | ||
{ | ||
if (! $param) { | ||
return $first - $second; | ||
} | ||
|
||
return 1 + (int) $param; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector\Fixture; | ||
|
||
final class IntInt | ||
{ | ||
public function resolve($param, int $first, int $second): int | ||
{ | ||
if (! $param) { | ||
return $first - $second; | ||
} | ||
|
||
return 1 + (int) $param; | ||
} | ||
} | ||
|
||
?> |
15 changes: 15 additions & 0 deletions
15
...ClassMethod/NumericReturnTypeFromStrictScalarReturnsRector/Fixture/skip_int_float.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,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector\Fixture; | ||
|
||
final class SkipIntFloat | ||
{ | ||
public function resolve($param, float $first, float $second) | ||
{ | ||
if (! $param) { | ||
return $first - $second; | ||
} | ||
|
||
return 1 + (int) $param; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...assMethod/NumericReturnTypeFromStrictScalarReturnsRector/Fixture/skip_union_false.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,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector\Fixture; | ||
|
||
final class SkipUnionFalse | ||
{ | ||
public function resolve($param) | ||
{ | ||
if (! $param) { | ||
return false; | ||
} | ||
|
||
return 1 + (int) $param; | ||
} | ||
} |
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