-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·58 lines (49 loc) · 1.77 KB
/
test
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
#!/usr/bin/env php
<?php
use Mfonte\PHP82DynProps\Command;
// check we're using at least PHP 8.2
if (version_compare(PHP_VERSION, '8.2.0', '<')) {
echo "\033[01;31mPHP 8.2 or higher is required. You are using " . PHP_VERSION . "\033[0m" . PHP_EOL;
exit(1);
}
define('DS', DIRECTORY_SEPARATOR);
define('TD', rtrim(__DIR__, DS) . DS);
define('VD', TD . 'vendor' . DS);
// set the error reporting to ALL
error_reporting(E_ALL);
// check if composer has been run
if (!is_file(VD . 'autoload.php')) {
echo "\033[01;31mPlease run composer install first\033[0m" . PHP_EOL;
exit(1);
}
require VD . 'autoload.php';
// register a custom error handler that does not display the stack trace.
// this is to avoid extra clutter on the CLI output.
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
// transform the errno into a string
$errno = match ($errno) {
E_ERROR => 'E_ERROR',
E_WARNING => 'E_WARNING',
E_PARSE => 'E_PARSE',
E_NOTICE => 'E_NOTICE',
E_CORE_ERROR => 'E_CORE_ERROR',
E_CORE_WARNING => 'E_CORE_WARNING',
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
E_USER_ERROR => 'E_USER_ERROR',
E_USER_WARNING => 'E_USER_WARNING',
E_USER_NOTICE => 'E_USER_NOTICE',
E_STRICT => 'E_STRICT',
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
E_DEPRECATED => 'E_DEPRECATED',
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
default => 'E_UNKNOWN',
};
// get only the filename of $errfile
$errfile = basename($errfile);
// display the error
echo chr(9) . "\033[01;30m{$errno}: {$errstr} in {$errfile} on line {$errline}\033[0m" . PHP_EOL;
});
// execute the Command
$cli = new Command();
$cli->run();