summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-08-31 11:22:16 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-08-31 11:22:16 +0200
commit8f7c52972089ad7ca6349a036a9cef6da5c4146e (patch)
treef5f672460e5816e03f83fbac954c25523fe7be08
parent42b6b8a3ae327b86d4316dcb88999d123a20a7e3 (diff)
downloadphp-git-8f7c52972089ad7ca6349a036a9cef6da5c4146e.tar.gz
Add test for bug #80039
This has already been fixed by 247105ae1ae2a04608078f7fcfe88dacab9f55a4, but let's add the additional test case.
-rw-r--r--Zend/tests/bug80039.phpt43
1 files changed, 43 insertions, 0 deletions
diff --git a/Zend/tests/bug80039.phpt b/Zend/tests/bug80039.phpt
new file mode 100644
index 0000000000..e04732f43c
--- /dev/null
+++ b/Zend/tests/bug80039.phpt
@@ -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