1--TEST-- 2Make sure various ASSIGN_OBJ exceptions are not optimized away 3--FILE-- 4<?php 5 6class Test { 7 public stdClass $x; 8} 9 10function test_invalid_prop_type() { 11 $test = new Test; 12 $test->x = ""; 13} 14function test_invalid_prop_name(string $name) { 15 $test = new stdClass; 16 $test->$name = null; 17} 18function test_invalid_obj_type($c) { 19 if ($c) { 20 $test = new stdClass; 21 } else { 22 $test = null; 23 } 24 $test->x = ""; 25} 26 27try { 28 test_invalid_prop_type(); 29} catch (TypeError $e) { 30 echo $e->getMessage(), "\n"; 31} 32try { 33 test_invalid_prop_name("\0"); 34} catch (Error $e) { 35 echo $e->getMessage(), "\n"; 36} 37try { 38 test_invalid_obj_type(false); 39} catch (Error $e) { 40 echo $e->getMessage(), "\n"; 41} 42 43?> 44--EXPECT-- 45Cannot assign string to property Test::$x of type stdClass 46Cannot access property starting with "\0" 47Attempt to assign property "x" on null 48