summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/union_types/inheritance_internal.phpt
blob: 84d0f8821105721b912015ad0fc978d4b9487220 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--TEST--
Inheritance of union type from internal class
--SKIPIF--
<?php
if (!extension_loaded('zend_test')) die('skip requires zend_test extension');
?>
--FILE--
<?php

class C extends _ZendTestClass {}

$obj = new _ZendTestChildClass;
$obj->classUnionProp = new stdClass;
$obj->classUnionProp = new ArrayIterator;
try {
    $obj->classUnionProp = new DateTime;
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}

$obj = new C;
$obj->classUnionProp = new stdClass;
$obj->classUnionProp = new ArrayIterator;
try {
    $obj->classUnionProp = new DateTime;
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}

?>
--EXPECT--
Cannot assign DateTime to property _ZendTestClass::$classUnionProp of type stdClass|Iterator|null
Cannot assign DateTime to property _ZendTestClass::$classUnionProp of type stdClass|Iterator|null