@@ -21,13 +21,15 @@ class NonexistentOffsetInArrayDimFetchRuleTest extends RuleTestCase
2121
2222 private bool $ reportPossiblyNonexistentConstantArrayOffset = false ;
2323
24+ private bool $ reportPossiblyNonexistentStringOffset = false ;
25+
2426 protected function getRule (): Rule
2527 {
2628 $ ruleLevelHelper = new RuleLevelHelper ($ this ->createReflectionProvider (), true , false , true , $ this ->checkExplicitMixed , $ this ->checkImplicitMixed , false );
2729
2830 return new NonexistentOffsetInArrayDimFetchRule (
2931 $ ruleLevelHelper ,
30- new NonexistentOffsetInArrayDimFetchCheck ($ ruleLevelHelper , true , $ this ->reportPossiblyNonexistentGeneralArrayOffset , $ this ->reportPossiblyNonexistentConstantArrayOffset ),
32+ new NonexistentOffsetInArrayDimFetchCheck ($ ruleLevelHelper , true , $ this ->reportPossiblyNonexistentGeneralArrayOffset , $ this ->reportPossiblyNonexistentConstantArrayOffset , $ this -> reportPossiblyNonexistentStringOffset ),
3133 true ,
3234 );
3335 }
@@ -782,6 +784,8 @@ public function testInternalClassesWithOverloadedOffsetAccessInvalid84(): void
782784
783785 public function testBug11946 (): void
784786 {
787+ $ this ->reportPossiblyNonexistentStringOffset = true ;
788+
785789 $ this ->analyse ([__DIR__ . '/data/bug-11946.php ' ], [
786790 [
787791 'Offset -1 does not exist on string. ' ,
@@ -805,23 +809,23 @@ public function testBug11946(): void
805809 ],
806810 [
807811 'Offset int<-5, 5> might not exist on string. ' ,
808- 45
812+ 45 ,
809813 ],
810814 [
811815 'Offset int<-5, 5> might not exist on numeric-string. ' ,
812- 46
816+ 46 ,
813817 ],
814818 [
815819 'Offset int<-5, 5> might not exist on non-empty-string. ' ,
816- 47
820+ 47 ,
817821 ],
818822 [
819823 'Offset int<-5, 5> might not exist on non-falsy-string. ' ,
820- 48
824+ 48 ,
821825 ],
822826 [
823827 'Offset int<-5, 5> might not exist on string. ' ,
824- 49
828+ 49 ,
825829 ],
826830 ]);
827831 }
0 commit comments