-
-
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 nullable callable on TypedPropertyFromAssignsR…
…ector (#6308) * [TypeDeclaration] Skip nullable callable on TypedPropertyFromAssignsRector * [TypeDeclaration] Skip nullable callable on TypedPropertyFromAssignsRector * Fix
- Loading branch information
1 parent
5c30f24
commit db5688c
Showing
3 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...eclaration/Rector/ClassMethod/ReturnUnionTypeRector/Fixture/union_callable_return.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\ReturnUnionTypeRector\Fixture; | ||
|
||
final class UnionCallableReturn | ||
{ | ||
public function run(callable $a) | ||
{ | ||
if (rand(0, 1)) { | ||
return $a; | ||
} | ||
|
||
return []; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector\Fixture; | ||
|
||
final class UnionCallableReturn | ||
{ | ||
public function run(callable $a): callable|array | ||
{ | ||
if (rand(0, 1)) { | ||
return $a; | ||
} | ||
|
||
return []; | ||
} | ||
} | ||
|
||
?> |
18 changes: 18 additions & 0 deletions
18
...ion/Rector/Property/TypedPropertyFromAssignsRector/Fixture/skip_nullable_callable.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,18 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class SkipNullableCallable | ||
{ | ||
private $prop; | ||
|
||
public function set(callable $prop): void | ||
{ | ||
$this->prop = $prop; | ||
} | ||
|
||
public function reset(): void | ||
{ | ||
$this->prop = null; | ||
} | ||
} |
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