xref: /PHP-8.0/tests/lang/type_hints_001.phpt (revision 960318ed)
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: type_hint_foo(): Argument #1 ($a) must be of type Foo, 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