Skip to content

Commit 903d7a6

Browse files
authored
[TypeDeclarationDocblocks] Skip union mixed|mixed on ClassMethodArrayDocblockParamFromLocalCallsRector (#7337)
* [TypeDeclarationDocblocks] Skip union mixed|mixed on ClassMethodArrayDocblockParamFromLocalCallsRector * Fix
1 parent dd30700 commit 903d7a6

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\Class_\ClassMethodArrayDocblockParamFromLocalCallsRector\Fixture;
4+
5+
class SkipUnionMixed
6+
{
7+
public function run(string $content, string $contentNew)
8+
{
9+
$orig = json_decode($content, true);
10+
$new = json_decode($contentNew, true);
11+
12+
$this->compareArrays($orig, $new);
13+
}
14+
15+
private function compareArrays(array $array1, array $array2): void
16+
{
17+
foreach ($array1 as $key => $value1) {
18+
$value2 = $array2[$key];
19+
20+
if (is_array($value1)) {
21+
$this->compareArrays($array1[$key], $array2[$key]);
22+
return;
23+
}
24+
25+
if ($value1 !== $value2) {
26+
$this->diff[$key] = [
27+
'existing' => $value1,
28+
'new' => $value2,
29+
];
30+
}
31+
}
32+
}
33+
}

src/NodeTypeResolver/PHPStan/Type/TypeFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public function uniquateTypes(array $types, bool $keepConstant = false): array
6464
$hasFalse = false;
6565
$hasTrue = false;
6666
foreach ($types as $type) {
67+
if ($type instanceof MixedType) {
68+
$type = new MixedType();
69+
}
70+
6771
$type = $this->normalizeObjectType($totalTypes, $type);
6872
$type = $this->normalizeBooleanType($hasFalse, $hasTrue, $type);
6973

0 commit comments

Comments
 (0)