mirror of
https://github.com/danog/psalm.git
synced 2024-11-29 20:28:59 +01:00
Fix #5097 - memoise more things during null coalesce
This commit is contained in:
parent
5a0e9d0965
commit
051169f9f2
@ -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