Skip to content

Commit e49f085

Browse files
authored
[TypeDeclaration] Allow empty array to native array on AddMethodCallBasedStrictParamTypeRector (#7342)
* [TypeDeclaration] Allow empty array to native array on AddMethodCallBasedStrictParamTypeRector * Fix
1 parent 9bf14f9 commit e49f085

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector\Fixture;
6+
7+
final class WithEmptyArray
8+
{
9+
public function runFirst()
10+
{
11+
$this->process([]);
12+
}
13+
14+
private function process($data)
15+
{
16+
}
17+
}
18+
19+
?>
20+
-----
21+
<?php
22+
23+
declare(strict_types=1);
24+
25+
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector\Fixture;
26+
27+
final class WithEmptyArray
28+
{
29+
public function runFirst()
30+
{
31+
$this->process([]);
32+
}
33+
34+
private function process(array $data)
35+
{
36+
}
37+
}
38+
39+
?>

rules/TypeDeclaration/NodeAnalyzer/CallTypesResolver.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ public function resolveStrictTypesFromCalls(array $calls): array
4646
}
4747

4848
/** @var Arg $arg */
49-
if ($this->isEmptyArray($arg->value)) {
50-
// skip empty array, as it doesn't add any value
51-
continue;
52-
}
53-
5449
$staticTypesByArgumentPosition[$position][] = $this->resolveStrictArgValueType($arg);
5550
}
5651
}

0 commit comments

Comments
 (0)