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:
Nikita Popov 2020-08-31 11:22:16 +02:00
parent 42b6b8a3ae
commit 8f7c529720

43
Zend/tests/bug80039.phpt Normal file
View 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