xref: /PHP-7.3/Zend/tests/return_types/030.phpt (revision 782352c5)
1--TEST--
2Nullable return value
3--FILE--
4<?php
5function foo($x) : ?array {
6	return $x;
7}
8
9foo([]);
10echo "ok\n";
11foo(null);
12echo "ok\n";
13foo(0);
14?>
15--EXPECTF--
16ok
17ok
18
19Fatal error: Uncaught TypeError: Return value of foo() must be of the type array or null, int returned in %s030.php:3
20Stack trace:
21#0 %s030.php(10): foo(0)
22#1 {main}
23  thrown in %s030.php on line 3
24