1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #4397 - allow offsetGet on inside isset

This commit is contained in:
Matt Brown 2020-10-25 22:16:43 -04:00 committed by Daniil Gentili
parent 36b7186712
commit c16d779bca
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 8 additions and 0 deletions

View File

@ -138,6 +138,7 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
&& $stmt->name instanceof PhpParser\Node\Identifier
&& $class_type->isNullable()
&& !$class_type->ignore_nullable_issues
&& !($stmt->name->name === 'offsetGet' && $context->inside_isset)
) {
if (IssueBuffer::accepts(
new PossiblyNullReference(

View File

@ -976,6 +976,13 @@ class ArrayAccessTest extends TestCase
test(["a", "b"]);
test(new ArrayObject(["a", "b"]));'
],
'nullCoalesceArrayAccess' => [
'<?php
/** @param ArrayAccess<int, string> $a */
function foo(?ArrayAccess $a) : void {
echo $a[0] ?? "default";
}'
],
];
}