File tree 2 files changed +47
-0
lines changed
tests/PHPStan/Rules/Properties
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -779,4 +779,10 @@ public function testPropertyHooks(): void
779
779
]);
780
780
}
781
781
782
+ public function testBug11171 (): void
783
+ {
784
+ $ this ->checkExplicitMixed = true ;
785
+ $ this ->analyse ([__DIR__ . '/data/bug-11171.php ' ], []);
786
+ }
787
+
782
788
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug11171 ;
4
+
5
+ class TypeExpression
6
+ {
7
+ public string $ value ;
8
+
9
+ /**
10
+ * @var list<array{start_index: int, expression: self}>
11
+ */
12
+ public array $ innerTypeExpressions = [];
13
+
14
+ /**
15
+ * @param \Closure(self): void $callback
16
+ */
17
+ public function walkTypes (\Closure $ callback ): void
18
+ {
19
+ $ startIndexOffset = 0 ;
20
+
21
+ foreach ($ this ->innerTypeExpressions as $ k => ['start_index ' => $ startIndexOrig ,
22
+ 'expression ' => $ inner ,]) {
23
+ $ this ->innerTypeExpressions [$ k ]['start_index ' ] += $ startIndexOffset ;
24
+
25
+ $ innerLengthOrig = \strlen ($ inner ->value );
26
+
27
+ $ inner ->walkTypes ($ callback );
28
+
29
+ $ this ->value = substr_replace (
30
+ $ this ->value ,
31
+ $ inner ->value ,
32
+ $ startIndexOrig + $ startIndexOffset ,
33
+ $ innerLengthOrig
34
+ );
35
+
36
+ $ startIndexOffset += \strlen ($ inner ->value ) - $ innerLengthOrig ;
37
+ }
38
+
39
+ $ callback ($ this );
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments