diff options
Diffstat (limited to 'tests/classes/constants_visibility_002.phpt')
-rw-r--r-- | tests/classes/constants_visibility_002.phpt | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/classes/constants_visibility_002.phpt b/tests/classes/constants_visibility_002.phpt new file mode 100644 index 0000000000..82bdd6df1f --- /dev/null +++ b/tests/classes/constants_visibility_002.phpt @@ -0,0 +1,30 @@ +--TEST-- +Class protected constant visibility +--FILE-- +<?php +class A { + protected const protectedConst = 'protectedConst'; + static function staticConstDump() { + var_dump(self::protectedConst); + } + function constDump() { + var_dump(self::protectedConst); + } +} + +A::staticConstDump(); +(new A())->constDump(); +constant('A::protectedConst'); + +?> +--EXPECTF-- +string(14) "protectedConst" +string(14) "protectedConst" + +Warning: constant(): Couldn't find constant A::protectedConst in %s on line 14 + +Fatal error: Uncaught Error: Cannot access protected const A::protectedConst in %s:14 +Stack trace: +#0 %s(14): constant('A::protectedCon...') +#1 {main} + thrown in %s on line 14 |