Skip to content

Commit 8f7c529

Browse files
committed
Add test for bug #80039
This has already been fixed by 247105a, but let's add the additional test case.
1 parent 42b6b8a commit 8f7c529

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Zend/tests/bug80039.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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

0 commit comments

Comments
 (0)