xref: /PHP-7.0/Zend/tests/exception_017.phpt (revision e97d5fab)
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 %sexception_017.php on line %d
34Exception: Cannot call abstract method C::foo()
35
36Fatal error: Uncaught Error: Cannot call abstract method C::foo() in %sexception_017.php:%d
37Stack trace:
38#0 {main}
39  thrown in %sexception_017.php on line %d
40