Skip to content

Commit df78547

Browse files
authored
[TypeDeclarationDocblocks] Skip mixed[] array from getter on ClassMethodArrayDocblockParamFromLocalCallsRector (#7340)
* [TypeDeclarationDocblocks] Skip mixed[] array from getter on ClassMethodArrayDocblockParamFromLocalCallsRector * Fix
1 parent e43c2d4 commit df78547

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\Class_\ClassMethodArrayDocblockParamFromLocalCallsRector\Fixture;
4+
5+
final class SkipMixedArrayFromGetter
6+
{
7+
public function getter(): ?array
8+
{
9+
}
10+
11+
public function fromGetter()
12+
{
13+
$this->run($this->getter());
14+
}
15+
16+
private function run(array $p)
17+
{
18+
}
19+
}

rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ private function isEmptyArray(Expr $expr): bool
228228
private function isArrayMixedMixedType(Type $type): bool
229229
{
230230
if (! $type instanceof ArrayType) {
231+
if ($type instanceof UnionType) {
232+
foreach ($type->getTypes() as $subType) {
233+
if ($subType instanceof ArrayType && $this->isArrayMixedMixedType($subType)) {
234+
return true;
235+
}
236+
}
237+
}
238+
231239
return false;
232240
}
233241

0 commit comments

Comments
 (0)