Skip to content

Commit 35a3372

Browse files
authored
Merge branch refs/heads/1.10.x into 1.11.x
2 parents b3e71e3 + b973be4 commit 35a3372

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,9 +1591,7 @@ private function resolveType(string $exprString, Expr $node): Type
15911591
return TypeCombinator::removeNull($leftType);
15921592
}
15931593

1594-
$rightType = $this->filterByFalseyValue(
1595-
new BinaryOp\NotIdentical($node->left, new ConstFetch(new Name('null'))),
1596-
)->getType($node->right);
1594+
$rightType = $this->filterByFalseyValue(new Expr\Isset_([$node->left]))->getType($node->right);
15971595

15981596
if ($result === null) {
15991597
return TypeCombinator::union(

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,7 @@ public function dataFileAsserts(): iterable
14091409
yield from $this->gatherAssertTypes(__DIR__ . '/data/conditional-vars.php');
14101410
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-5961.php');
14111411
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-10189.php');
1412+
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-10317.php');
14121413
}
14131414

14141415
/**
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug10317;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
/**
8+
* @param array{'foo': string, 'bar'?: string} $array
9+
*/
10+
function myfunction(array $array): void
11+
{
12+
$string = $array['bar'] ?? $array['foo'];
13+
assertType('string', $string);
14+
}

0 commit comments

Comments
 (0)