diff --git a/conf/bleedingEdge.neon b/conf/bleedingEdge.neon index 291b495940..ad5ae07a04 100644 --- a/conf/bleedingEdge.neon +++ b/conf/bleedingEdge.neon @@ -3,5 +3,4 @@ parameters: bleedingEdge: true skipCheckGenericClasses!: [] stricterFunctionMap: true - - reportPossiblyNonexistentStringOffset: true + reportPossiblyNonexistentStringOffset: true diff --git a/conf/config.neon b/conf/config.neon index 0459cadd97..5d32651064 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -24,6 +24,7 @@ parameters: bleedingEdge: false skipCheckGenericClasses: [] stricterFunctionMap: false + reportPossiblyNonexistentStringOffset: false fileExtensions: - php checkAdvancedIsset: false @@ -60,7 +61,6 @@ parameters: reportAnyTypeWideningInVarTag: false reportPossiblyNonexistentGeneralArrayOffset: false reportPossiblyNonexistentConstantArrayOffset: false - reportPossiblyNonexistentStringOffset: false checkMissingOverrideMethodAttribute: false mixinExcludeClasses: [] scanFiles: [] @@ -835,7 +835,7 @@ services: reportMaybes: %reportMaybes% reportPossiblyNonexistentGeneralArrayOffset: %reportPossiblyNonexistentGeneralArrayOffset% reportPossiblyNonexistentConstantArrayOffset: %reportPossiblyNonexistentConstantArrayOffset% - reportPossiblyNonexistentStringOffset: %reportPossiblyNonexistentStringOffset% + reportPossiblyNonexistentStringOffset: %featureToggles.reportPossiblyNonexistentStringOffset% - class: PHPStan\Rules\ClassNameCheck diff --git a/conf/parametersSchema.neon b/conf/parametersSchema.neon index 699b3db0d5..0cf40775a0 100644 --- a/conf/parametersSchema.neon +++ b/conf/parametersSchema.neon @@ -30,6 +30,7 @@ parametersSchema: bleedingEdge: bool(), skipCheckGenericClasses: listOf(string()), stricterFunctionMap: bool() + reportPossiblyNonexistentStringOffset: bool() ]) fileExtensions: listOf(string()) checkAdvancedIsset: bool() @@ -71,7 +72,6 @@ parametersSchema: reportAnyTypeWideningInVarTag: bool() reportPossiblyNonexistentGeneralArrayOffset: bool() reportPossiblyNonexistentConstantArrayOffset: bool() - reportPossiblyNonexistentStringOffset: bool() checkMissingOverrideMethodAttribute: bool() parallel: structure([ jobSize: int(), diff --git a/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php b/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php index 8ddc1f215b..c840062d37 100644 --- a/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php +++ b/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php @@ -806,7 +806,7 @@ public function testBug11946(): void 53, ], [ - "Offset int<-5, 5> might not exist on 'hi'.", + "Offset int<-5, 5> might not exist on 'hia'.", 56, ], ]); diff --git a/tests/PHPStan/Rules/Arrays/data/bug-11946.php b/tests/PHPStan/Rules/Arrays/data/bug-11946.php index b890512b1b..e0479377d2 100644 --- a/tests/PHPStan/Rules/Arrays/data/bug-11946.php +++ b/tests/PHPStan/Rules/Arrays/data/bug-11946.php @@ -43,7 +43,7 @@ public function maybeNonExistentStringOffset( string $nonEmpty, string $nonFalsy, string $lowerCase, - int $maybeWrong + int $maybeWrong, int $oneToTwo ) { echo $s[$maybeWrong]; @@ -52,7 +52,10 @@ public function maybeNonExistentStringOffset( echo $nonFalsy[$maybeWrong]; echo $lowerCase[$maybeWrong]; - $s = 'hi'; + $s = 'hia'; echo $s[$maybeWrong]; + if ($maybeWrong >= 1 && $maybeWrong < 3) { + echo $s[$maybeWrong]; + } } }