File tree Expand file tree Collapse file tree 3 files changed +72
-2
lines changed Expand file tree Collapse file tree 3 files changed +72
-2
lines changed Original file line number Diff line number Diff line change @@ -696,7 +696,7 @@ public function getIterableKeyType(): Type
696696}
697697}
698698
699- if  ($ this isInstanceOf (Traversable::class)->yes ()) {
699+ if  ($ this isInstanceOf (Traversable::class)->yes () && ! $ this -> isExtraOffsetAccessibleClass ()-> yes () ) {
700700$ isTraversabletrue ;
701701$ tKeygetType ($ this 'TKey ' );
702702if  ($ tKeynull ) {
@@ -732,7 +732,7 @@ public function getIterableValueType(): Type
732732}
733733}
734734
735- if  ($ this isInstanceOf (Traversable::class)->yes ()) {
735+ if  ($ this isInstanceOf (Traversable::class)->yes () && ! $ this -> isExtraOffsetAccessibleClass ()-> yes () ) {
736736$ isTraversabletrue ;
737737$ tValuegetType ($ this 'TValue ' );
738738if  ($ tValuenull ) {
Original file line number Diff line number Diff line change @@ -821,6 +821,7 @@ public function dataFileAsserts(): iterable
821821yield  from  $ this gatherAssertTypes (__DIR__  . '/data/array-search-type-specifying.php ' );
822822yield  from  $ this gatherAssertTypes (__DIR__  . '/data/array-replace.php ' );
823823yield  from  $ this gatherAssertTypes (__DIR__  . '/data/bug-6889.php ' );
824+ yield  from  $ this gatherAssertTypes (__DIR__  . '/data/simplexml.php ' );
824825}
825826
826827/** 
Original file line number Diff line number Diff line change 1+ <?php 
2+ 
3+ namespace  SimpleXMLIteratorBug ;
4+ 
5+ use  SimpleXMLElement ;
6+ use  function  PHPStan \Testing \assertType ;
7+ 
8+ class  Foo
9+ {
10+ 
11+ public  function  getAddressByGps ()
12+ {
13+ /** @var SimpleXMLElement|null $data */ 
14+ $ datadoFoo ();
15+ 
16+ if  ($ datanull ) {
17+ return ;
18+ }
19+ 
20+ assertType ('(SimpleXMLElement|null) ' , $ dataitem );
21+ foreach  ($ dataitem  as  $ item
22+ assertType ('SimpleXMLElement ' , $ item
23+ assertType ('SimpleXMLElement|null ' , $ item'name ' ]);
24+ }
25+ }
26+ 
27+ }
28+ 
29+ class  Bar extends  SimpleXMLElement
30+ {
31+ 
32+ public  function  getAddressByGps ()
33+ {
34+ /** @var self|null $data */ 
35+ $ datadoFoo ();
36+ 
37+ if  ($ datanull ) {
38+ return ;
39+ }
40+ 
41+ assertType ('(SimpleXMLIteratorBug\Bar|null) ' , $ dataitem );
42+ foreach  ($ dataitem  as  $ item
43+ assertType (self ::class, $ item
44+ assertType ('SimpleXMLIteratorBug\Bar|null ' , $ item'name ' ]);
45+ }
46+ }
47+ 
48+ }
49+ 
50+ class  Baz
51+ {
52+ 
53+ public  function  getAddressByGps ()
54+ {
55+ /** @var Bar|null $data */ 
56+ $ datadoFoo ();
57+ 
58+ if  ($ datanull ) {
59+ return ;
60+ }
61+ 
62+ assertType ('(SimpleXMLIteratorBug\Bar|null) ' , $ dataitem );
63+ foreach  ($ dataitem  as  $ item
64+ assertType (Bar::class, $ item
65+ assertType ('SimpleXMLIteratorBug\Bar|null ' , $ item'name ' ]);
66+ }
67+ }
68+ 
69+ }
                         You can’t perform that action at this time. 
           
                  
0 commit comments