xref: /PHP-8.0/Zend/tests/dereference_014.phpt (revision d30cd7d7)
1--TEST--
2Trying to create an object from dereferencing uninitialized variable
3--FILE--
4<?php
5
6error_reporting(E_ALL);
7
8class foo {
9    public $x;
10    static public $y;
11
12    public function a() {
13        return $this->x;
14    }
15
16    static public function b() {
17        return self::$y;
18    }
19}
20
21$foo = new foo;
22$h = $foo->a()[0]->a;
23var_dump($h);
24
25$h = foo::b()[1]->b;
26var_dump($h);
27
28?>
29--EXPECTF--
30Warning: Trying to access array offset on value of type null in %s on line %d
31
32Warning: Attempt to read property "a" on null in %s on line %d
33NULL
34
35Warning: Trying to access array offset on value of type null in %s on line %d
36
37Warning: Attempt to read property "b" on null in %s on line %d
38NULL
39