-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Allow union with closure type on property on TypedP…
…ropertyFromAssignsRector (#6717)
- Loading branch information
1 parent
7f91068
commit a4c489e
Showing
5 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...r/Property/TypedPropertyFromAssignsRector/FixtureComplexTypes/skip_union_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,17 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\FixtureComplexTypes; | ||
|
||
class SkipUnionCallable | ||
{ | ||
private $property; | ||
|
||
public function run(callable $prop): void | ||
{ | ||
if (rand(0, 1)) { | ||
$this->property = $prop; | ||
} else { | ||
$this->property = false; | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
.../Rector/Property/TypedPropertyFromAssignsRector/FixtureComplexTypes/union_closure.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,41 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\FixtureComplexTypes; | ||
|
||
class UnionClosure | ||
{ | ||
private $property; | ||
|
||
public function run(): void | ||
{ | ||
if (rand(0, 1)) { | ||
$this->property = function (): void { | ||
}; | ||
} else { | ||
$this->property = false; | ||
} | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\FixtureComplexTypes; | ||
|
||
class UnionClosure | ||
{ | ||
private \Closure|bool|null $property = null; | ||
|
||
public function run(): void | ||
{ | ||
if (rand(0, 1)) { | ||
$this->property = function (): void { | ||
}; | ||
} else { | ||
$this->property = false; | ||
} | ||
} | ||
} | ||
|
||
?> |
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
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
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