diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php index 1f1db0be7..e6938e3d0 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php @@ -891,7 +891,7 @@ class ArrayFetchAnalyzer $array_access_type = clone $type->previous_value_type; } else { - if ($type->sealed) { + if ($type->sealed || !$context->inside_isset) { $object_like_keys = array_keys($type->properties); if (count($object_like_keys) === 1) { diff --git a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php index d6ec1f0c6..0a5b036c5 100644 --- a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php @@ -1405,7 +1405,7 @@ class TypeAnalyzer || $container_type_part instanceof THtmlEscapedString) ) { if ($input_type_part instanceof TLiteralString) { - return is_numeric($input_type_part->value); + return \is_numeric($input_type_part->value); } if ($atomic_comparison_result) { $atomic_comparison_result->type_coerced = true; diff --git a/src/Psalm/Internal/Visitor/OffsetShifterVisitor.php b/src/Psalm/Internal/Visitor/OffsetShifterVisitor.php index 8b711812e..573a4b81e 100644 --- a/src/Psalm/Internal/Visitor/OffsetShifterVisitor.php +++ b/src/Psalm/Internal/Visitor/OffsetShifterVisitor.php @@ -27,7 +27,7 @@ class OffsetShifterVisitor extends PhpParser\NodeVisitorAbstract implements PhpP */ public function enterNode(PhpParser\Node $node) { - /** @var array{startFilePos: int, endFilePos: int} */ + /** @var array{startFilePos: int, endFilePos: int, startLine: int} */ $attrs = $node->getAttributes(); if ($cs = $node->getComments()) { diff --git a/src/Psalm/Internal/Visitor/PartialParserVisitor.php b/src/Psalm/Internal/Visitor/PartialParserVisitor.php index 3898cb088..f61176330 100644 --- a/src/Psalm/Internal/Visitor/PartialParserVisitor.php +++ b/src/Psalm/Internal/Visitor/PartialParserVisitor.php @@ -66,7 +66,7 @@ class PartialParserVisitor extends PhpParser\NodeVisitorAbstract implements PhpP */ public function enterNode(PhpParser\Node $node, &$traverseChildren = true) { - /** @var array{startFilePos: int, endFilePos: int} */ + /** @var array{startFilePos: int, endFilePos: int, startLine: int} */ $attrs = $node->getAttributes(); if ($cs = $node->getComments()) { diff --git a/tests/ArrayAccessTest.php b/tests/ArrayAccessTest.php index 218e5bcdd..9da527a5b 100644 --- a/tests/ArrayAccessTest.php +++ b/tests/ArrayAccessTest.php @@ -1144,6 +1144,18 @@ class ArrayAccessTest extends TestCase }', 'error_message' => 'TypeDoesNotContainType', ], + 'undefinedObjectLikeArrayOffset' => [ + ' 'InvalidArrayOffset' + ], ]; } }