mirror of
https://github.com/php/php-src.git
synced 2024-11-30 21:35:36 +08:00
Add test for bug #80039
This has already been fixed by 247105ae1a
,
but let's add the additional test case.
This commit is contained in:
parent
42b6b8a3ae
commit
8f7c529720
43
Zend/tests/bug80039.phpt
Normal file
43
Zend/tests/bug80039.phpt
Normal file
@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
Bug #80039: Illegal string offset and Cannot create references to/from string offsets
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
final class A
|
||||
{
|
||||
public string $a;
|
||||
|
||||
public static function fromArray(array $props): self
|
||||
{
|
||||
$me = new static;
|
||||
foreach ($props as $k => &$v) {
|
||||
$me->{$k} = &$v;
|
||||
}
|
||||
return $me;
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
throw new \LogicException("Property '$name' is not defined.");
|
||||
}
|
||||
}
|
||||
|
||||
class ObjectHelpers
|
||||
{
|
||||
public static function hasProperty(string $class, string $name)
|
||||
{
|
||||
static $cache = [];
|
||||
$prop = &$cache[$class][$name]; # <-- emits error
|
||||
var_dump($prop);
|
||||
}
|
||||
}
|
||||
|
||||
set_exception_handler(function ($e) {
|
||||
ObjectHelpers::hasProperty(A::class, 'a');
|
||||
});
|
||||
|
||||
A::fromArray(['a' => 'foo']);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
NULL
|
Loading…
Reference in New Issue
Block a user