Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Handle crash on intersection in Union type on AddMe…
…thodCallBasedStrictParamTypeRector (#2704) * [TypeDeclaration] Skip intersection in Union type on AddMethodCallBasedStrictParamTypeRector * Fixed 🎉 * [ci-review] Rector Rectify * cs fix * fix * [ci-review] Rector Rectify * reduce complexity * final touch: eol * final touch: comment rollback Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
a018130
commit fe0551e
Showing
2 changed files
with
38 additions
and
1 deletion.
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
30 changes: 30 additions & 0 deletions
30
...thodCallBasedStrictParamTypeRector/FixtureIntersection/skip_intersection_in_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,30 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector\FixtureIntersection; | ||
|
||
abstract class SkipIntersectionInUnion | ||
{ | ||
public function prepareParameters(): array | ||
{ | ||
$parameters = array_merge($this->getRequestParameters(), [ | ||
'request' => $this->getRequestName(), | ||
]); | ||
|
||
$this->removeEmptyValues($parameters); | ||
|
||
return []; | ||
} | ||
|
||
private function removeEmptyValues($input): array | ||
{ | ||
foreach ($input as &$value) { | ||
if (! is_array($value)) { | ||
continue; | ||
} | ||
|
||
$value = $this->removeEmptyValues($value); | ||
} | ||
|
||
return []; | ||
} | ||
} |