Skip to content

Commit 7d4102f

Browse files
committed
Fix PHP 7.4 and 8.0 CI
1 parent 5840e4f commit 7d4102f

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

‎src/Analyser/NodeScopeResolver.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2516,7 +2516,7 @@ private function getStructuralArgType(MutatingScope $scope, Expr $expr): ?Type
25162516
private function getStructuralItemType(MutatingScope $scope, Expr $expr): Type
25172517
{
25182518
if ($expr instanceof Expr\Closure || $expr instanceof Expr\ArrowFunction) {
2519-
return $this->container->getByType(ClosureTypeResolver::class)->getClosureType($scope, $expr, shallow: true);
2519+
return $this->container->getByType(ClosureTypeResolver::class)->getClosureType($scope, $expr, true);
25202520
}
25212521

25222522
if (!$this->argConsumesResolvedParameterType($expr)) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php // lint >= 8.1
2+
3+
declare(strict_types = 1);
4+
5+
namespace ClosurePassedToTypeNestedUnpack;
6+
7+
use function PHPStan\Testing\assertType;
8+
9+
/**
10+
* @template T
11+
* @param array<T, \Closure(T): void> $callbacks
12+
*/
13+
function acceptKeyedGenericWithUnpack(array $callbacks): void {}
14+
15+
/** @param array<'z', \Closure('z'): void> $more */
16+
function withUnpack(array $more): void {
17+
acceptKeyedGenericWithUnpack([
18+
...$more,
19+
'foo' => function ($value): void {
20+
assertType("'foo'|'z'", $value);
21+
},
22+
]);
23+
};

‎tests/PHPStan/Analyser/nsrt/closure-passed-to-type-nested.php‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,3 @@ function acceptNestedGeneric(array $callbacks): void {}
149149
assertType("'x'", $value);
150150
}],
151151
]);
152-
153-
/**
154-
* @template T
155-
* @param array<T, \Closure(T): void> $callbacks
156-
*/
157-
function acceptKeyedGenericWithUnpack(array $callbacks): void {}
158-
159-
/** @param array<'z', \Closure('z'): void> $more */
160-
function withUnpack(array $more): void {
161-
acceptKeyedGenericWithUnpack([
162-
...$more,
163-
'foo' => function ($value): void {
164-
assertType("'foo'|'z'", $value);
165-
},
166-
]);
167-
};

0 commit comments

Comments
 (0)