Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Keep constant false return type from strict native …
…call (#5223)
- Loading branch information
Showing
6 changed files
with
142 additions
and
4 deletions.
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
35 changes: 35 additions & 0 deletions
35
...trictNativeCallRector/Fixture/native_method_call_returning_boolean_or_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,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector\Fixture; | ||
|
||
final class NativeMethodCallReturningBooleanUnionFalse | ||
{ | ||
public function run(string $needle, array $haystack) | ||
{ | ||
if (rand(0,1)) { | ||
return in_array($needle, $haystack, true); | ||
} | ||
|
||
return ob_get_clean(); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector\Fixture; | ||
|
||
final class NativeMethodCallReturningBooleanUnionFalse | ||
{ | ||
public function run(string $needle, array $haystack): bool|string | ||
{ | ||
if (rand(0,1)) { | ||
return in_array($needle, $haystack, true); | ||
} | ||
|
||
return ob_get_clean(); | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
...d/ReturnTypeFromStrictNativeCallRector/Fixture/native_method_call_returning_union.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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector\Fixture; | ||
|
||
final class NativeMethodCallReturningUnion | ||
{ | ||
public function run() | ||
{ | ||
return time_nanosleep(100, 100); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector\Fixture; | ||
|
||
final class NativeMethodCallReturningUnion | ||
{ | ||
public function run(): array|bool | ||
{ | ||
return time_nanosleep(100, 100); | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
...rnTypeFromStrictNativeCallRector/Fixture/native_method_call_returning_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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector\Fixture; | ||
|
||
final class NativeMethodCallReturningUnionFalse | ||
{ | ||
public function run() | ||
{ | ||
return ob_get_clean(); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector\Fixture; | ||
|
||
final class NativeMethodCallReturningUnionFalse | ||
{ | ||
public function run(): string|false | ||
{ | ||
return ob_get_clean(); | ||
} | ||
} | ||
|
||
?> |
35 changes: 35 additions & 0 deletions
35
...trictNativeCallRector/Fixture/native_method_call_returning_union_false_or_boolean.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\ReturnTypeFromStrictNativeCallRector\Fixture; | ||
|
||
final class NativeMethodCallReturningMergedUnionFalseOrBoolean | ||
{ | ||
public function run(string $needle, array $haystack) | ||
{ | ||
if (rand(0,1)) { | ||
return ob_get_clean(); | ||
} | ||
|
||
return in_array($needle, $haystack, true); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector\Fixture; | ||
|
||
final class NativeMethodCallReturningMergedUnionFalseOrBoolean | ||
{ | ||
public function run(string $needle, array $haystack): string|bool | ||
{ | ||
if (rand(0,1)) { | ||
return ob_get_clean(); | ||
} | ||
|
||
return in_array($needle, $haystack, true); | ||
} | ||
} | ||
|
||
?> |
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