Skip to content

Commit 25b2572

Browse files
Native type does not know about purity
1 parent b57bcad commit 25b2572

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/Analyser/MutatingScope.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
13421342
TemplateTypeVarianceMap::createEmpty(),
13431343
[],
13441344
$cachedClosureData['throwPoints'],
1345-
$cachedClosureData['impurePoints'],
1345+
$this->nativeTypesPromoted ? null : $cachedClosureData['impurePoints'],
13461346
$cachedClosureData['invalidateExpressions'],
13471347
$cachedClosureData['usedVariables'],
13481348
true,
@@ -1557,7 +1557,7 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
15571557
TemplateTypeVarianceMap::createEmpty(),
15581558
[],
15591559
$throwPointsForClosureType,
1560-
$impurePointsForClosureType,
1560+
$this->nativeTypesPromoted ? null : $impurePointsForClosureType,
15611561
$invalidateExpressions,
15621562
$usedVariables,
15631563
true,
@@ -2552,7 +2552,7 @@ private function createFirstClassCallable(
25522552
$variant instanceof ParametersAcceptorWithPhpDocs ? $variant->getCallSiteVarianceMap() : TemplateTypeVarianceMap::createEmpty(),
25532553
$templateTags,
25542554
$throwPoints,
2555-
$impurePoints,
2555+
$this->nativeTypesPromoted ? null : $impurePoints,
25562556
[],
25572557
[],
25582558
$acceptsNamedArguments,

tests/PHPStan/Rules/PhpDoc/WrongVariableNameInVarTagRuleTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ public function testBug4505(): void
182182
$this->analyse([__DIR__ . '/data/bug-4505.php'], []);
183183
}
184184

185+
public function testBug12458(): void
186+
{
187+
$this->analyse([__DIR__ . '/data/bug-12458.php'], []);
188+
}
189+
185190
public function testEnums(): void
186191
{
187192
if (PHP_VERSION_ID < 80100) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php declare(strict_types = 1);
2+
3+
Namespace Bug12458;
4+
5+
class HelloWorld
6+
{
7+
/**
8+
* @param list<HelloWorld> $a
9+
*/
10+
public function test(array $a): void
11+
{
12+
/** @var \Closure(): list<HelloWorld> $c */
13+
$c = function () use ($a): array {
14+
return $a;
15+
};
16+
}
17+
}

0 commit comments

Comments
 (0)