File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #80039: Illegal string offset and Cannot create references to/from string offsets
3
+ --FILE--
4
+ <?php
5
+
6
+ final class A
7
+ {
8
+ public string $ a ;
9
+
10
+ public static function fromArray (array $ props ): self
11
+ {
12
+ $ me = new static ;
13
+ foreach ($ props as $ k => &$ v ) {
14
+ $ me ->{$ k } = &$ v ;
15
+ }
16
+ return $ me ;
17
+ }
18
+
19
+ public function __get ($ name )
20
+ {
21
+ throw new \LogicException ("Property ' $ name' is not defined. " );
22
+ }
23
+ }
24
+
25
+ class ObjectHelpers
26
+ {
27
+ public static function hasProperty (string $ class , string $ name )
28
+ {
29
+ static $ cache = [];
30
+ $ prop = &$ cache [$ class ][$ name ]; # <-- emits error
31
+ var_dump ($ prop );
32
+ }
33
+ }
34
+
35
+ set_exception_handler (function ($ e ) {
36
+ ObjectHelpers::hasProperty (A::class, 'a ' );
37
+ });
38
+
39
+ A::fromArray (['a ' => 'foo ' ]);
40
+
41
+ ?>
42
+ --EXPECT--
43
+ NULL
You can’t perform that action at this time.
0 commit comments