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:
parent
36b7186712
commit
c16d779bca
@ -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(
|
||||
|
@ -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";
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user