Skip to content

Commit 863202f

Browse files
committed
Intersection of array&hasOffset is accepted by non-empty-array
1 parent 58c418b commit 863202f

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/Type/Accessory/NonEmptyArrayType.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ public function getConstantStrings(): array
7676

7777
public function accepts(Type $type, bool $strictTypes): AcceptsResult
7878
{
79-
if ($type instanceof CompoundType) {
80-
return $type->isAcceptedBy($this, $strictTypes);
81-
}
82-
8379
$isArray = $type->isArray();
8480
$isIterableAtLeastOnce = $type->isIterableAtLeastOnce();
8581

tests/PHPStan/Rules/Functions/ClosureReturnTypeRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,10 @@ public function testBugFunctionMethodConstants(): void
133133
$this->analyse([__DIR__ . '/data/bug-anonymous-function-method-constant.php'], []);
134134
}
135135

136+
public function testBug13964(): void
137+
{
138+
$this->analyse([__DIR__ . '/data/bug-13964.php'], []);
139+
}
140+
141+
136142
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Bug13964;
4+
5+
/** @var array<string, array<mixed>> $state */
6+
$state = (fn()=>[])();
7+
8+
$state = array_map(function (array $item): array {
9+
if (array_key_exists('type', $item) && array_key_exists('data', $item)) {
10+
return $item;
11+
}
12+
13+
return [
14+
'type' => 'hello',
15+
'data' => [],
16+
];
17+
}, $state);

0 commit comments

Comments
 (0)