File tree 1 file changed +26
-4
lines changed
1 file changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -4,18 +4,40 @@ GH-7922 (print_r should not produce a fatal error)
4
4
<?php
5
5
class A
6
6
{
7
- public function __debugInfo (): array
7
+ public function __debugInfo ()
8
8
{
9
9
throw new \Error ('x ' );
10
10
}
11
11
}
12
12
13
13
try {
14
14
$ a = new A ();
15
+ print_r ($ a );
16
+ } catch (\Throwable $ e ) {
17
+ echo (string ) $ e . "\n" ;
18
+ }
19
+
20
+ try {
21
+ $ a = new class () extends A {
22
+ public function __debugInfo (): array
23
+ {
24
+ throw new \Exception ('y ' );
25
+ }
26
+ };
15
27
print_r ($ a , true );
16
28
} catch (\Throwable $ e ) {
17
- echo $ e -> getMessage () ;
29
+ echo ( string ) $ e . "\n" ;
18
30
}
19
31
?>
20
- --EXPECT--
21
- __debuginfo() must return an array
32
+ --EXPECTF--
33
+ Error: x in %s:6
34
+ Stack trace:
35
+ #0 [internal function]: A->__debugInfo()
36
+ #1 %s(12): print_r(Object(A))
37
+ #2 {main}
38
+
39
+ Exception: y in %s:21
40
+ Stack trace:
41
+ #0 [internal function]: A@anonymous->__debugInfo()
42
+ #1 %s(24): print_r(Object(A@anonymous), true)
43
+ #2 {main}
You can’t perform that action at this time.
0 commit comments