xref: /PHP-7.2/Zend/tests/exception_013.phpt (revision e97d5fab)
1--TEST--
2Exceptions on improper access to static class properties
3--FILE--
4<?php
5class C {
6	static private $p = 0;
7}
8
9try {
10	var_dump(C::$a);
11} catch (Error $e) {
12	echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n";
13}
14
15try {
16	var_dump(C::$p);
17} catch (Error $e) {
18	echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n";
19}
20
21try {
22	unset(C::$a);
23} catch (Error $e) {
24	echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n";
25}
26
27var_dump(C::$a);
28?>
29--EXPECTF--
30Exception: Access to undeclared static property: C::$a in %sexception_013.php on line 7
31
32Exception: Cannot access private property C::$p in %sexception_013.php on line 13
33
34Exception: Attempt to unset static property C::$a in %sexception_013.php on line 19
35
36Fatal error: Uncaught Error: Access to undeclared static property: C::$a in %sexception_013.php:24
37Stack trace:
38#0 {main}
39  thrown in %sexception_013.php on line 24
40