@@ -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 }
@@ -756,6 +758,8 @@ public function testBug2634(): void
756758
757759 public function testBug11946 (): void
758760 {
761+ $ this ->reportPossiblyNonexistentStringOffset = true ;
762+
759763 $ this ->analyse ([__DIR__ . '/data/bug-11946.php ' ], [
760764 [
761765 'Offset -1 does not exist on string. ' ,
@@ -779,23 +783,23 @@ public function testBug11946(): void
779783 ],
780784 [
781785 'Offset int<-5, 5> might not exist on string. ' ,
782- 45
786+ 45 ,
783787 ],
784788 [
785789 'Offset int<-5, 5> might not exist on numeric-string. ' ,
786- 46
790+ 46 ,
787791 ],
788792 [
789793 'Offset int<-5, 5> might not exist on non-empty-string. ' ,
790- 47
794+ 47 ,
791795 ],
792796 [
793797 'Offset int<-5, 5> might not exist on non-falsy-string. ' ,
794- 48
798+ 48 ,
795799 ],
796800 [
797801 'Offset int<-5, 5> might not exist on string. ' ,
798- 49
802+ 49 ,
799803 ],
800804 ]);
801805 }
0 commit comments