xref: /PHP-8.3/Zend/tests/bug50383.phpt (revision f8d79582)
1--TEST--
2Bug #50383 (Exceptions thrown in __call / __callStatic do not include file and line in trace)
3--FILE--
4<?php
5
6class myClass {
7    public static function __callStatic($method, $args) {
8        throw new Exception("Missing static method '$method'\n");
9    }
10    public function __call($method, $args) {
11        throw new Exception("Missing method '$method'\n");
12    }
13}
14
15function thrower() {
16    myClass::ThrowException();
17}
18function thrower2() {
19    $x = new myClass;
20    $x->foo();
21}
22
23try {
24    thrower();
25} catch(Exception $e) {
26    print $e->getMessage();
27    print_r($e->getTrace());
28}
29
30try {
31    thrower2();
32} catch (Exception $e) {
33    print $e->getMessage();
34    print_r($e->getTrace());
35}
36
37?>
38--EXPECTF--
39Missing static method 'ThrowException'
40Array
41(
42    [0] => Array
43        (
44            [file] => %s
45            [line] => 13
46            [function] => __callStatic
47            [class] => myClass
48            [type] => ::
49            [args] => Array
50                (
51                    [0] => ThrowException
52                    [1] => Array
53                        (
54                        )
55
56                )
57
58        )
59
60    [1] => Array
61        (
62            [file] => %s
63            [line] => 21
64            [function] => thrower
65            [args] => Array
66                (
67                )
68
69        )
70
71)
72Missing method 'foo'
73Array
74(
75    [0] => Array
76        (
77            [file] => %s
78            [line] => 17
79            [function] => __call
80            [class] => myClass
81            [type] => ->
82            [args] => Array
83                (
84                    [0] => foo
85                    [1] => Array
86                        (
87                        )
88
89                )
90
91        )
92
93    [1] => Array
94        (
95            [file] => %s
96            [line] => 28
97            [function] => thrower2
98            [args] => Array
99                (
100                )
101
102        )
103
104)
105