/
function.php
51 lines (39 loc) · 1.2 KB
/
function.php
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
<?php /** @noinspection ALL */ declare(strict_types=1);
require __DIR__ . '/../../../vendor/autoload.php';
return function (array $event) {
if ($event['extensions'] ?? false) {
return get_loaded_extensions();
}
if ($event['php-config'] ?? false) {
return ini_get_all(null, false);
}
if ($event['env'] ?? false) {
return [
'$_ENV' => $_ENV['FOO'] ?? null,
'$_SERVER' => $_SERVER['FOO'] ?? null,
'getenv' => getenv('FOO'),
];
}
if ($event['stdout'] ?? false) {
echo 'This is a test log by writing to stdout';
}
if ($event['stderr'] ?? false) {
echo 'This is a test log by writing to stderr';
}
if ($event['error_log'] ?? false) {
error_log('This is a test log from error_log');
}
if ($event['exception'] ?? false) {
throw new Exception('This is an uncaught exception');
}
if ($event['error'] ?? false) {
strlen();
}
if ($event['fatal_error'] ?? false) {
require 'foo';
}
if ($event['warning'] ?? false) {
trigger_error('This is a test warning', E_USER_WARNING);
}
return 'Hello ' . ($event['name'] ?? 'world');
};