mirror of
https://github.com/php/php-src.git
synced 2024-12-18 06:21:41 +08:00
7ce531f2c2
This means we get an Error exception and a much better error message indicating the root cause (e.g. accessing a private class constant).
28 lines
500 B
PHP
28 lines
500 B
PHP
--TEST--
|
|
Class private constant visibility
|
|
--FILE--
|
|
<?php
|
|
class A {
|
|
private const privateConst = 'privateConst';
|
|
static function staticConstDump() {
|
|
var_dump(self::privateConst);
|
|
}
|
|
function constDump() {
|
|
var_dump(self::privateConst);
|
|
}
|
|
}
|
|
|
|
A::staticConstDump();
|
|
(new A())->constDump();
|
|
try {
|
|
constant('A::privateConst');
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(12) "privateConst"
|
|
string(12) "privateConst"
|
|
Cannot access private const A::privateConst
|