xref: /PHP-8.3/Zend/tests/bug78531.phpt (revision d30cd7d7)
1--TEST--
2Bug #78531 (Crash when using undefined variable as object)
3--FILE--
4<?php
5try {
6    $u1->a += 5;
7} catch (Error $e) {
8    echo $e->getMessage(), "\n";
9}
10try {
11    $x = ++$u2->a;
12} catch (Error $e) {
13    echo $e->getMessage(), "\n";
14}
15try {
16    $x = $u3->a++;
17} catch (Error $e) {
18    echo $e->getMessage(), "\n";
19}
20try {
21    $u4->a->a += 5;
22} catch (Error $e) {
23    echo $e->getMessage(), "\n";
24}
25?>
26--EXPECTF--
27Warning: Undefined variable $u1 in %s on line %d
28Attempt to assign property "a" on null
29
30Warning: Undefined variable $u2 in %s on line %d
31Attempt to increment/decrement property "a" on null
32
33Warning: Undefined variable $u3 in %s on line %d
34Attempt to increment/decrement property "a" on null
35
36Warning: Undefined variable $u4 in %s on line %d
37Attempt to modify property "a" on null
38