1--TEST--
2Scalar type missing parameters
3--FILE--
4<?php
5
6$errnames = [
7    E_NOTICE => 'E_NOTICE',
8    E_WARNING => 'E_WARNING',
9    E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR'
10];
11set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) {
12    echo "$errnames[$errno]: $errmsg on line $line\n";
13    return true;
14});
15
16$functions = [
17    'int' => function (int $i) { return $i; },
18    'float' => function (float $f) { return $f; },
19    'string' => function (string $s) { return $s; },
20    'bool' => function (bool $b) { return $b; },
21    'int nullable' => function (int $i = NULL) { return $i; },
22    'float nullable' => function (float $f = NULL) { return $f; },
23    'string nullable' => function (string $s = NULL) { return $s; },
24    'bool nullable' => function (bool $b = NULL) { return $b; }
25];
26
27foreach ($functions as $type => $function) {
28    echo "Testing $type:", PHP_EOL;
29    try {
30        var_dump($function());
31    } catch (TypeError $e) {
32        echo "*** Caught " . $e->getMessage() . PHP_EOL;
33    }
34}
35echo PHP_EOL . "Done";
36--EXPECTF--
37Testing int:
38*** Caught Argument 1 passed to {closure}() must be of the type integer, none given, called in %s on line %d
39Testing float:
40*** Caught Argument 1 passed to {closure}() must be of the type float, none given, called in %s on line %d
41Testing string:
42*** Caught Argument 1 passed to {closure}() must be of the type string, none given, called in %s on line %d
43Testing bool:
44*** Caught Argument 1 passed to {closure}() must be of the type boolean, none given, called in %s on line %d
45Testing int nullable:
46NULL
47Testing float nullable:
48NULL
49Testing string nullable:
50NULL
51Testing bool nullable:
52NULL
53
54Done
55