2015-04-01 21:48:15 +08:00
|
|
|
--TEST--
|
|
|
|
Exceptions on improper usage of $this
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
abstract class C {
|
2020-02-04 05:52:20 +08:00
|
|
|
abstract static function foo();
|
2015-04-01 21:48:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function foo(callable $x) {
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2020-02-04 05:52:20 +08:00
|
|
|
C::foo();
|
2015-05-18 06:31:43 +08:00
|
|
|
} catch (Error $e) {
|
2019-01-29 23:03:24 +08:00
|
|
|
echo $e, "\n\n";
|
2015-04-01 21:48:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2020-02-04 05:52:20 +08:00
|
|
|
foo("C::foo");
|
2015-05-18 06:31:43 +08:00
|
|
|
} catch (Error $e) {
|
2019-01-29 23:03:24 +08:00
|
|
|
echo $e, "\n\n";
|
2015-04-01 21:48:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
C::foo();
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
2019-01-29 23:03:24 +08:00
|
|
|
Error: Cannot call abstract method C::foo() in %s:%d
|
|
|
|
Stack trace:
|
|
|
|
#0 {main}
|
|
|
|
|
2020-02-26 03:58:33 +08:00
|
|
|
TypeError: foo(): Argument #1 ($x) must be of type callable, string given, called in %s:%d
|
2019-01-29 23:03:24 +08:00
|
|
|
Stack trace:
|
|
|
|
#0 %s(%d): foo('C::foo')
|
|
|
|
#1 {main}
|
2015-04-01 21:48:15 +08:00
|
|
|
|
|
|
|
|
2019-01-29 23:03:24 +08:00
|
|
|
Fatal error: Uncaught Error: Cannot call abstract method C::foo() in %s:%d
|
2015-05-16 03:04:07 +08:00
|
|
|
Stack trace:
|
|
|
|
#0 {main}
|
2019-01-29 23:03:24 +08:00
|
|
|
thrown in %s on line %d
|