1--TEST-- 2Constants in default values of properties 3--FILE-- 4<?php 5declare(strict_types=1); 6 7define("FOO", 5); 8 9class A { 10 public int $foo = FOO; 11} 12 13class B { 14 public string $foo = FOO; 15} 16 17$o = new A(); 18var_dump($o->foo); 19 20for ($i = 0; $i < 2; $i++) { 21 try { 22 $o = new B(); 23 var_dump($o->foo); 24 } catch (Throwable $e) { 25 echo $e->getMessage() . "\n"; 26 } 27} 28?> 29--EXPECT-- 30int(5) 31Cannot assign int to property B::$foo of type string 32Cannot assign int to property B::$foo of type string 33