xref: /PHP-7.2/tests/lang/type_hints_001.phpt (revision f1d7e3ca)
1--TEST--
2ZE2 type hinting
3--FILE--
4<?php
5
6class Foo {
7}
8
9class Bar {
10}
11
12function type_hint_foo(Foo $a) {
13}
14
15$foo = new Foo;
16$bar = new Bar;
17
18type_hint_foo($foo);
19type_hint_foo($bar);
20
21?>
22--EXPECTF--
23Fatal error: Uncaught TypeError: Argument 1 passed to type_hint_foo() must be an instance of Foo, instance of Bar given, called in %s on line 16 and defined in %s:9
24Stack trace:
25#0 %s(%d): type_hint_foo(Object(Bar))
26#1 {main}
27  thrown in %s on line 9
28