source: src/router/php7/Zend/tests/function_arguments/argument_count_incorrect_userland_strict.phpt @ 31874

Last change on this file since 31874 was 31874, checked in by brainslayer, 4 months ago

update php

File size: 1.2 KB
Line 
1--TEST--
2Call userland function with incorrect number of arguments with strict types
3--FILE--
4<?php
5declare(strict_types=1);
6try {
7        function foo($bar) { }
8        foo();
9} catch (\Error $e) {
10        echo get_class($e) . PHP_EOL;
11        echo $e->getMessage() . PHP_EOL;
12}
13
14try {
15        function bar($foo, $bar) { }
16        bar(1);
17} catch (\Error $e) {
18        echo get_class($e) . PHP_EOL;
19        echo $e->getMessage() . PHP_EOL;
20}
21
22function bat(int $foo, string $bar) { }
23
24try {
25        bat(123);
26} catch (\Error $e) {
27        echo get_class($e) . PHP_EOL;
28        echo $e->getMessage() . PHP_EOL;
29}
30
31try {
32        bat("123");
33} catch (\Error $e) {
34        echo get_class($e) . PHP_EOL;
35        echo $e->getMessage() . PHP_EOL;
36}
37
38try {
39        bat(123, 456);
40} catch (\Error $e) {
41        echo get_class($e) . PHP_EOL;
42        echo $e->getMessage() . PHP_EOL;
43}
44--EXPECTF--
45ArgumentCountError
46Too few arguments to function foo(), 0 passed in %s and exactly 1 expected
47ArgumentCountError
48Too few arguments to function bar(), 1 passed in %s and exactly 2 expected
49ArgumentCountError
50Too few arguments to function bat(), 1 passed in %s and exactly 2 expected
51TypeError
52Argument 1 passed to bat() must be of the type integer, string given, called in %s
53TypeError
54Argument 2 passed to bat() must be of the type string, integer given, called in %s
Note: See TracBrowser for help on using the repository browser.