From 071558ec83c4764f3727d7909fade7d8bf3eb93e Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 11 May 2018 23:21:53 -0400 Subject: [PATCH] Fix #733 - DomNodeList implements ArrayAccess --- src/Psalm/Codebase/ClassLikes.php | 4 ++++ tests/ArrayAccessTest.php | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/Psalm/Codebase/ClassLikes.php b/src/Psalm/Codebase/ClassLikes.php index 573530496..da2d710a0 100644 --- a/src/Psalm/Codebase/ClassLikes.php +++ b/src/Psalm/Codebase/ClassLikes.php @@ -454,6 +454,10 @@ class ClassLikes return true; } + if ($interface_id === 'arrayaccess' && $fq_class_name === 'domnodelist') { + return true; + } + if (isset(ClassLikeChecker::$SPECIAL_TYPES[$interface_id]) || isset(ClassLikeChecker::$SPECIAL_TYPES[$fq_class_name]) ) { diff --git a/tests/ArrayAccessTest.php b/tests/ArrayAccessTest.php index 8e4fb2abe..fdbaaff50 100644 --- a/tests/ArrayAccessTest.php +++ b/tests/ArrayAccessTest.php @@ -135,6 +135,12 @@ class ArrayAccessTest extends TestCase $x[] = 5; takesInt($x[0]);', ], + 'domNodeListAccessible' => [ + 'loadXML(""); + $doc->getElementsByTagName("node")[0];' + ], ]; }