1--TEST-- 2GH-10709: Recursive class constant evaluation with outer call failing 3--FILE-- 4<?php 5 6class S { 7 public function __toString() { 8 static $i = 0; 9 $i++; 10 if ($i === 1) { 11 return 'S'; 12 } else { 13 throw new \Exception('Thrown from S'); 14 } 15 } 16} 17 18const S = new S(); 19 20class B { 21 public $prop = A::C . S; 22} 23 24spl_autoload_register(function ($class) { 25 class A { const C = "A"; } 26 var_dump(new B()); 27}); 28 29var_dump(new B()); 30 31?> 32--EXPECTF-- 33object(B)#3 (1) { 34 ["prop"]=> 35 string(2) "AS" 36} 37 38Fatal error: Uncaught Exception: Thrown from S in %s:%d 39Stack trace: 40#0 %s(%d): [constant expression]() 41#1 %s(%d): S->__toString() 42#2 {main} 43 thrown in %s on line %d 44