mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #5097 - memoise more things during null coalesce
This commit is contained in:
parent
76269658ca
commit
3c58220f3a
@ -32,6 +32,8 @@ class CoalesceAnalyzer
|
||||
|| $root_expr instanceof PhpParser\Node\Expr\MethodCall
|
||||
|| $root_expr instanceof PhpParser\Node\Expr\StaticCall
|
||||
|| $root_expr instanceof PhpParser\Node\Expr\Cast
|
||||
|| $root_expr instanceof PhpParser\Node\Expr\NullsafePropertyFetch
|
||||
|| $root_expr instanceof PhpParser\Node\Expr\NullsafeMethodCall
|
||||
) {
|
||||
$left_var_id = '$<tmp coalesce var>' . (int) $left_expr->getAttribute('startFilePos');
|
||||
|
||||
|
@ -2395,6 +2395,19 @@ class PropertyTypeTest extends TestCase
|
||||
echo $foo->{$b} ?? null;
|
||||
}'
|
||||
],
|
||||
'nullCoalesceWithNullablePropertyAccess' => [
|
||||
'<?php
|
||||
class Bar {
|
||||
public ?string $a = null;
|
||||
}
|
||||
|
||||
function takesBar(?Bar $bar) : string {
|
||||
return $bar?->a ?? "default";
|
||||
}',
|
||||
[],
|
||||
[],
|
||||
'8.0'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user