1--TEST-- 2Typed properties in internal classes 3--EXTENSIONS-- 4zend_test 5--FILE-- 6<?php 7 8// Internal typed properties 9 10$obj = new _ZendTestClass; 11var_dump($obj->intProp); 12try { 13 $obj->intProp = "foobar"; 14} catch (TypeError $e) { 15 echo $e->getMessage(), "\n"; 16} 17$obj->intProp = 456; 18 19try { 20 $obj->classProp = $obj; 21} catch (TypeError $e) { 22 echo $e->getMessage(), "\n"; 23} 24$obj->classProp = new stdClass; 25var_dump($obj); 26 27// Inherit from internal class 28 29class Test extends _ZendTestClass { 30} 31 32$obj = new Test; 33var_dump($obj->intProp); 34try { 35 $obj->intProp = "foobar"; 36} catch (TypeError $e) { 37 echo $e->getMessage(), "\n"; 38} 39$obj->intProp = 456; 40 41try { 42 $obj->classProp = $obj; 43} catch (TypeError $e) { 44 echo $e->getMessage(), "\n"; 45} 46$obj->classProp = new stdClass; 47var_dump($obj); 48 49// Static internal typed properties 50 51var_dump(_ZendTestClass::$staticIntProp); 52try { 53 _ZendTestClass::$staticIntProp = "foobar"; 54} catch (TypeError $e) { 55 echo $e->getMessage(), "\n"; 56} 57_ZendTestClass::$staticIntProp = 456; 58var_dump(_ZendTestClass::$staticIntProp); 59 60?> 61--EXPECT-- 62int(123) 63Cannot assign string to property _ZendTestClass::$intProp of type int 64Cannot assign _ZendTestClass to property _ZendTestClass::$classProp of type ?stdClass 65object(_ZendTestClass)#1 (3) { 66 ["intProp"]=> 67 int(456) 68 ["classProp"]=> 69 object(stdClass)#2 (0) { 70 } 71 ["classUnionProp"]=> 72 NULL 73 ["readonlyProp"]=> 74 uninitialized(int) 75} 76int(123) 77Cannot assign string to property _ZendTestClass::$intProp of type int 78Cannot assign Test to property _ZendTestClass::$classProp of type ?stdClass 79object(Test)#4 (3) { 80 ["intProp"]=> 81 int(456) 82 ["classProp"]=> 83 object(stdClass)#1 (0) { 84 } 85 ["classUnionProp"]=> 86 NULL 87 ["readonlyProp"]=> 88 uninitialized(int) 89} 90int(123) 91Cannot assign string to property _ZendTestClass::$staticIntProp of type int 92int(456) 93