1--TEST-- 2Typed properties do not invoke the autoloader 3--FILE-- 4<?php 5 6class Test { 7 public X $propX; 8 public ?Y $propY; 9} 10 11spl_autoload_register(function($class) { 12 echo "Loading $class\n"; 13}); 14 15$test = new Test; 16try { 17 $test->propX = new stdClass; 18} catch (TypeError $e) { 19 echo $e->getMessage(), "\n"; 20} 21 22if (true) { 23 class X {} 24} 25 26$test->propX = new X; 27var_dump($test->propX); 28 29$test->propY = null; 30$r =& $test->propY; 31try { 32 $test->propY = new stdClass; 33} catch (TypeError $e) { 34 echo $e->getMessage(), "\n"; 35} 36 37if (true) { 38 class Y {} 39} 40 41$r = new Y; 42var_dump($test->propY); 43 44?> 45--EXPECT-- 46Cannot assign stdClass to property Test::$propX of type X 47object(X)#3 (0) { 48} 49Cannot assign stdClass to property Test::$propY of type ?Y 50object(Y)#4 (0) { 51} 52