xref: /PHP-7.4/Zend/tests/bug80037.phpt (revision dfaa4768)
1--TEST--
2Bug #80037: Typed property must not be accessed before initialization when __get() declared
3--FILE--
4<?php
5
6final 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;  # try to remove &
15		}
16		return $me;
17	}
18
19	public function __get($name)
20	{
21		throw new \LogicException("Property '$name' is not defined.");
22	}
23}
24
25var_dump(A::fromArray(['a' => 'foo']));
26
27?>
28--EXPECT--
29object(A)#1 (1) {
30  ["a"]=>
31  string(3) "foo"
32}
33