|
| 1 | +--TEST-- |
| 2 | +get_exception_handler() |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | + |
| 6 | +class C { |
| 7 | + function handle() {} |
| 8 | + static function handleStatic() {} |
| 9 | +} |
| 10 | + |
| 11 | +class Invokable { |
| 12 | + public function __invoke() { |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +function foo() {} |
| 17 | + |
| 18 | +echo "No exception handler\n"; |
| 19 | +var_dump(get_exception_handler() === null); |
| 20 | + |
| 21 | +echo "\nFunction string\n"; |
| 22 | +set_exception_handler('foo'); |
| 23 | +var_dump(get_exception_handler() === 'foo'); |
| 24 | + |
| 25 | +echo "\nNULL\n"; |
| 26 | +set_exception_handler(null); |
| 27 | +var_dump(get_exception_handler() === null); |
| 28 | + |
| 29 | +echo "\nStatic method array\n"; |
| 30 | +set_exception_handler([C::class, 'handleStatic']); |
| 31 | +var_dump(get_exception_handler() === [C::class, 'handleStatic']); |
| 32 | + |
| 33 | +echo "\nStatic method string\n"; |
| 34 | +set_exception_handler('C::handleStatic'); |
| 35 | +var_dump(get_exception_handler() === 'C::handleStatic'); |
| 36 | + |
| 37 | +echo "\nInstance method array\n"; |
| 38 | +set_exception_handler([$c = new C(), 'handle']); |
| 39 | +var_dump(get_exception_handler() === [$c, 'handle']); |
| 40 | + |
| 41 | +echo "\nFirst class callable method\n"; |
| 42 | +set_exception_handler($f = (new C())->handle(...)); |
| 43 | +var_dump(get_exception_handler() === $f); |
| 44 | + |
| 45 | +echo "\nClosure\n"; |
| 46 | +set_exception_handler($f = function () {}); |
| 47 | +var_dump(get_exception_handler() === $f); |
| 48 | + |
| 49 | +echo "\nInvokable\n"; |
| 50 | +set_exception_handler($object = new Invokable()); |
| 51 | +var_dump(get_exception_handler() === $object); |
| 52 | + |
| 53 | +echo "\nStable return value\n"; |
| 54 | +var_dump(get_exception_handler() === get_exception_handler()); |
| 55 | + |
| 56 | +?>==DONE== |
| 57 | +--EXPECT-- |
| 58 | +No exception handler |
| 59 | +bool(true) |
| 60 | + |
| 61 | +Function string |
| 62 | +bool(true) |
| 63 | + |
| 64 | +NULL |
| 65 | +bool(true) |
| 66 | + |
| 67 | +Static method array |
| 68 | +bool(true) |
| 69 | + |
| 70 | +Static method string |
| 71 | +bool(true) |
| 72 | + |
| 73 | +Instance method array |
| 74 | +bool(true) |
| 75 | + |
| 76 | +First class callable method |
| 77 | +bool(true) |
| 78 | + |
| 79 | +Closure |
| 80 | +bool(true) |
| 81 | + |
| 82 | +Invokable |
| 83 | +bool(true) |
| 84 | + |
| 85 | +Stable return value |
| 86 | +bool(true) |
| 87 | +==DONE== |
0 commit comments