Skip to content

Commit 7fdcb6c

Browse files
committed
Print exception class
1 parent e7c35a8 commit 7fdcb6c

File tree

6 files changed

+51
-38
lines changed

6 files changed

+51
-38
lines changed

Zend/tests/partial_application/errors_002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function foo($a) {
99
try {
1010
foo(?, a: 1);
1111
} catch (Error $ex) {
12-
printf("%s\n", $ex->getMessage());
12+
printf("%s: %s\n", $ex::class, $ex->getMessage());
1313
}
1414
?>
1515
--EXPECT--
16-
Named parameter $a overwrites previous placeholder
16+
Error: Named parameter $a overwrites previous placeholder

Zend/tests/partial_application/errors_003.phpt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ $foo = foo(?);
1313
try {
1414
$foo();
1515
} catch (Error $ex) {
16-
printf("%s\n", $ex->getMessage());
16+
printf("%s: %s\n", $ex::class, $ex->getMessage());
1717
}
1818

1919
$foo = foo(?, ?);
2020

2121
try {
2222
$foo(1);
2323
} catch (Error $ex) {
24-
printf("%s\n", $ex->getMessage());
24+
printf("%s: %s\n", $ex::class, $ex->getMessage());
2525
}
2626

2727
$bar = bar(?, ?, ...);
2828

2929
try {
3030
$bar(1);
3131
} catch (Error $ex) {
32-
printf("%s\n", $ex->getMessage());
32+
printf("%s: %s\n", $ex::class, $ex->getMessage());
3333
}
3434

3535
class Foo {
@@ -43,35 +43,35 @@ $bar = $foo->bar(?);
4343
try {
4444
$bar();
4545
} catch (Error $ex) {
46-
printf("%s\n", $ex->getMessage());
46+
printf("%s: %s\n", $ex::class, $ex->getMessage());
4747
}
4848

4949
$repeat = str_repeat('a', ...);
5050

5151
try {
5252
$repeat();
5353
} catch (Error $ex) {
54-
printf("%s\n", $ex->getMessage());
54+
printf("%s: %s\n", $ex::class, $ex->getMessage());
5555
}
5656

5757
$usleep = usleep(?);
5858

5959
try {
6060
$usleep();
6161
} catch (Error $ex) {
62-
printf("%s\n", $ex->getMessage());
62+
printf("%s: %s\n", $ex::class, $ex->getMessage());
6363
}
6464

6565
try {
6666
$usleep(1, 2);
6767
} catch (Error $ex) {
68-
printf("%s\n", $ex->getMessage());
68+
printf("%s: %s\n", $ex::class, $ex->getMessage());
6969
}
7070
?>
7171
--EXPECTF--
72-
Too few arguments to function {closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
73-
Too few arguments to function {closure:%s:%d}(), 1 passed in %s on line %d and exactly 2 expected
74-
Too few arguments to function {closure:%s:%d}(), 1 passed in %s on line %d and exactly 3 expected
75-
Too few arguments to function Foo::{closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
76-
Too few arguments to function {closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
77-
Too few arguments to function {closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
72+
ArgumentCountError: Too few arguments to function {closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
73+
ArgumentCountError: Too few arguments to function {closure:%s:%d}(), 1 passed in %s on line %d and exactly 2 expected
74+
ArgumentCountError: Too few arguments to function {closure:%s:%d}(), 1 passed in %s on line %d and exactly 3 expected
75+
ArgumentCountError: Too few arguments to function Foo::{closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
76+
ArgumentCountError: Too few arguments to function {closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
77+
ArgumentCountError: Too few arguments to function {closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected

Zend/tests/partial_application/export_001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ assert.exception=1
77
try {
88
assert(0 && foo(?) && foo(new stdClass, ...));
99
} catch (Error $ex) {
10-
printf("%s\n", $ex->getMessage());
10+
printf("%s: %s\n", $ex::class, $ex->getMessage());
1111
}
1212
?>
1313
--EXPECT--
14-
assert(0 && foo(?) && foo(new stdClass(), ...))
14+
AssertionError: assert(0 && foo(?) && foo(new stdClass(), ...))

Zend/tests/partial_application/magic_001.phpt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ echo (string) new ReflectionFunction($bar);
2121
try {
2222
$bar();
2323
} catch (Error $ex) {
24-
printf("%s\n", $ex->getMessage());
24+
printf("%s: %s\n", $ex::class, $ex->getMessage());
2525
}
2626

2727
try {
2828
$bar(1, 2);
2929
} catch (Error $ex) {
30-
printf("%s\n", $ex->getMessage());
30+
printf("%s: %s\n", $ex::class, $ex->getMessage());
3131
}
3232

3333
$bar(1);
@@ -45,30 +45,35 @@ echo (string) new ReflectionFunction($bar);
4545
$bar(100);
4646
?>
4747
--EXPECTF--
48-
Closure [ <user, prototype Foo> public method {closure:%s} ] {
48+
Closure [ <user> public method {closure:%s:%d} ] {
4949
@@ %s 12 - 12
5050

5151
- Parameters [1] {
52-
Parameter #0 [ <required> $ ]
52+
Parameter #0 [ <required> $args0 ]
5353
}
5454
}
55-
not enough arguments for application of Foo::method, 0 given and exactly 1 expected, declared in %s on line 12
56-
too many arguments for application of Foo::method, 2 given and a maximum of 1 expected, declared in %s on line 12
55+
ArgumentCountError: Too few arguments to function Foo::{closure:%s:%d}(), 0 passed in %s on line %d and exactly 1 expected
5756
Foo::method
5857
int(1)
59-
Closure [ <user, prototype Foo> public method {closure:%s} ] {
58+
Foo::method
59+
int(1)
60+
Closure [ <user> public method {closure:%s:%d} ] {
6061
@@ %s 30 - 30
6162

6263
- Parameters [2] {
63-
Parameter #0 [ <required> $ ]
64+
Parameter #0 [ <required> $args0 ]
6465
Parameter #1 [ <optional> ...$args ]
6566
}
6667
}
6768
Foo::method
6869
int(10)
69-
Closure [ <user, prototype Foo> public method {closure:%s} ] {
70+
Closure [ <user> public method {closure:%s:%d} ] {
7071
@@ %s 36 - 36
7172

73+
- Bound Variables [1] {
74+
Variable #0 [ $args0 ]
75+
}
76+
7277
- Parameters [1] {
7378
Parameter #0 [ <optional> ...$args ]
7479
}

Zend/tests/partial_application/variation_strict_001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ $foo = foo(?);
1313
try {
1414
$foo("42");
1515
} catch (TypeError $ex) {
16-
printf("%s\n", $ex->getMessage());
16+
printf("%s: %s\n", $ex::class, $ex->getMessage());
1717
}
1818
?>
1919
--EXPECTF--
20-
{closure:%s:%d}(): Argument #1 ($int) must be of type int, string given, called in %s on line %d
20+
TypeError: {closure:%s:%d}(): Argument #1 ($int) must be of type int, string given, called in %s on line %d

Zend/tests/partial_application/variation_variadics_003.phpt

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ $foo = foo(?, ?);
1313
try {
1414
$foo(1, 2, 3); // FAIL, 2 expected, 3 given
1515
} catch (Error $ex) {
16-
printf("%s\n", $ex->getMessage());
16+
printf("%s: %s\n", $ex::class, $ex->getMessage());
1717
}
1818

1919
try {
2020
$foo = foo(?, ?, ?); // FAIL 2 expected, 3 given
2121
} catch (Error $ex) {
22-
printf("%s\n", $ex->getMessage());
22+
printf("%s: %s\n", $ex::class, $ex->getMessage());
2323
}
2424

2525
function bar($a, $b, ...$c) {
@@ -31,22 +31,30 @@ $bar = bar(?, ?);
3131
try {
3232
$bar(1, 2, 3); // FAIL 3 given, maximum 2 expected
3333
} catch (Error $ex) {
34-
printf("%s\n", $ex->getMessage());
34+
printf("%s: %s\n", $ex::class, $ex->getMessage());
3535
}
3636

3737
$foo = foo(?, ?, ...);
3838

3939
$foo(1, 2, 3); // OK
4040
?>
41-
--EXPECTF--
42-
too many arguments for application of foo, 3 given and a maximum of 2 expected
43-
too many arguments or placeholders for application of foo, 3 given and a maximum of 2 expected
44-
too many arguments for application of bar, 3 given and a maximum of 2 expected
45-
array(3) {
41+
--EXPECT--
42+
array(2) {
43+
[0]=>
44+
int(1)
45+
[1]=>
46+
int(2)
47+
}
48+
Error: too many arguments or placeholders for application of foo, 3 given and a maximum of 2 expected
49+
array(2) {
50+
[0]=>
51+
int(1)
52+
[1]=>
53+
int(2)
54+
}
55+
array(2) {
4656
[0]=>
4757
int(1)
4858
[1]=>
4959
int(2)
50-
[2]=>
51-
int(3)
5260
}

0 commit comments

Comments
 (0)