-
Notifications
You must be signed in to change notification settings - Fork 8k
Expand file tree
/
Copy pathget_exception_handler.phpt
More file actions
87 lines (64 loc) · 1.66 KB
/
get_exception_handler.phpt
File metadata and controls
87 lines (64 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
--TEST--
get_exception_handler()
--FILE--
<?php
class C {
function handle() {}
static function handleStatic() {}
}
class InvokableHandler {
public function __invoke() {
}
}
function foo() {}
echo "No exception handler\n";
var_dump(get_exception_handler() === null);
echo "\nFunction string\n";
set_exception_handler('foo');
var_dump(get_exception_handler() === 'foo');
echo "\nNULL\n";
set_exception_handler(null);
var_dump(get_exception_handler() === null);
echo "\nStatic method array\n";
set_exception_handler([C::class, 'handleStatic']);
var_dump(get_exception_handler() === [C::class, 'handleStatic']);
echo "\nStatic method string\n";
set_exception_handler('C::handleStatic');
var_dump(get_exception_handler() === 'C::handleStatic');
echo "\nInstance method array\n";
set_exception_handler([$c = new C(), 'handle']);
var_dump(get_exception_handler() === [$c, 'handle']);
echo "\nFirst class callable method\n";
set_exception_handler($f = (new C())->handle(...));
var_dump(get_exception_handler() === $f);
echo "\nClosure\n";
set_exception_handler($f = function () {});
var_dump(get_exception_handler() === $f);
echo "\nInvokableHandler\n";
set_exception_handler($object = new InvokableHandler());
var_dump(get_exception_handler() === $object);
echo "\nStable return value\n";
var_dump(get_exception_handler() === get_exception_handler());
?>==DONE==
--EXPECT--
No exception handler
bool(true)
Function string
bool(true)
NULL
bool(true)
Static method array
bool(true)
Static method string
bool(true)
Instance method array
bool(true)
First class callable method
bool(true)
Closure
bool(true)
InvokableHandler
bool(true)
Stable return value
bool(true)
==DONE==