xref: /PHP-7.4/Zend/tests/exception_017.phpt (revision 21148679)
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 "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n";
16}
17
18try {
19	foo("C::foo");
20} catch (Error $e) {
21	echo "\n";
22	do {
23		echo "Exception: " . $e->getMessage() . "\n";
24		$e = $e->getPrevious();
25	} while ($e instanceof Error);
26}
27
28C::foo();
29?>
30--EXPECTF--
31Exception: Cannot call abstract method C::foo() in %sexception_017.php on line %d
32
33Exception: Argument 1 passed to foo() must be callable, string given, called in %s on line %d
34
35Fatal error: Uncaught Error: Cannot call abstract method C::foo() in %sexception_017.php:%d
36Stack trace:
37#0 {main}
38  thrown in %sexception_017.php on line %d
39