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