1--TEST-- 2Only public and protected class constants should be inherited 3--FILE-- 4<?php 5class A { 6 public const X = 1; 7 protected const Y = 2; 8 private const Z = 3; 9} 10class B extends A { 11 static public function checkConstants() { 12 var_dump(self::X); 13 var_dump(self::Y); 14 var_dump(self::Z); 15 } 16} 17 18B::checkConstants(); 19?> 20--EXPECTF-- 21int(1) 22int(2) 23 24Fatal error: Uncaught Error: Undefined class constant 'Z' in %s:11 25Stack trace: 26#0 %s(15): B::checkConstants() 27#1 {main} 28 thrown in %s on line 11 29