xref: /PHP-7.2/Zend/tests/return_types/013.phpt (revision f1d7e3ca)
1--TEST--
2Closure inside method returned null, expected array
3--FILE--
4<?php
5class foo {
6    public function bar() : callable {
7        $test = "one";
8        return function() use($test) : array {
9            return null;
10        };
11    }
12}
13
14$baz = new foo();
15var_dump($func=$baz->bar(), $func());
16--EXPECTF--
17Fatal error: Uncaught TypeError: Return value of foo::{closure}() must be of the type array, null returned in %s:%d
18Stack trace:
19#0 %s(%d): foo->{closure}()
20#1 {main}
21  thrown in %s on line %d
22