1--TEST-- 2Closure in property initializer may not access unrelated private variables 3--FILE-- 4<?php 5 6class C { 7 public Closure $d = static function (E $e) { 8 echo $e->secret, PHP_EOL; 9 }; 10 11 12} 13 14class E { 15 public function __construct( 16 private string $secret, 17 ) {} 18} 19 20$c = new C(); 21($c->d)(new E('secret')); 22 23 24?> 25--EXPECTF-- 26Fatal error: Uncaught Error: Cannot access private property E::$secret in %s:%d 27Stack trace: 28#0 %s(%d): C::{closure:%s:%d}(Object(E)) 29#1 {main} 30 thrown in %s on line %d 31