xref: /PHP-8.3/Zend/tests/exception_017.phpt (revision 960318ed)
1--TEST--
2Exceptions on improper usage of $this
3--FILE--
4<?php
5abstract class C {
6    abstract static function foo();
7}
8
9function foo(callable $x) {
10}
11
12try {
13    C::foo();
14} catch (Error $e) {
15    echo $e, "\n\n";
16}
17
18try {
19    foo("C::foo");
20} catch (Error $e) {
21    echo $e, "\n\n";
22}
23
24C::foo();
25?>
26--EXPECTF--
27Error: Cannot call abstract method C::foo() in %s:%d
28Stack trace:
29#0 {main}
30
31TypeError: foo(): Argument #1 ($x) must be of type callable, string given, called in %s:%d
32Stack trace:
33#0 %s(%d): foo('C::foo')
34#1 {main}
35
36
37Fatal error: Uncaught Error: Cannot call abstract method C::foo() in %s:%d
38Stack trace:
39#0 {main}
40  thrown in %s on line %d
41