Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Rector\Tests\TypeDeclarationDocblocks\Rector\Class_\ClassMethodArrayDocblockParamFromLocalCallsRector\Fixture;

class SkipUnionMixedArray
{
public function run()
{
$this->exec($_SERVER['argv'] ?? []);
}

private function exec(array $argv)
{
}
}
9 changes: 9 additions & 0 deletions rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ private function unionToSingleType(array $staticTypesByArgumentPosition, bool $r
if ($staticTypeByArgumentPosition[$position]->isNull()->yes()) {
$staticTypeByArgumentPosition[$position] = new MixedType();
}

if ($staticTypeByArgumentPosition[$position] instanceof UnionType) {
foreach ($staticTypeByArgumentPosition[$position]->getTypes() as $subType) {
if ($subType instanceof MixedType) {
$staticTypeByArgumentPosition[$position] = new MixedType();
continue 2;
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool approach 👏


return $staticTypeByArgumentPosition;
Expand Down
Loading