forked from JakubOnderka/PHP-Var-Dump-Check
-
Notifications
You must be signed in to change notification settings - Fork 0
/
var-dump-check.php
91 lines (80 loc) · 2.67 KB
/
var-dump-check.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
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
88
89
90
91
<?php
use JakubOnderka\PhpVarDumpCheck;
const VERSION = '0.3';
const SUCCESS = 0,
WITH_ERRORS = 1,
FAILED = 254; // 255 code is reserved to PHP itself
if (PHP_VERSION < '5.4.0') {
fwrite(STDERR,"PHP Var Dump Check require PHP 5.4.0 and newer");
die(FAILED);
}
function showOptions() {
?>
Options:
--tracy Enable support for Tracy (Debugger::dump)
--zend Enable support for Zend (Zend_Debug::dump and \Zend\Debug\Debug::dump)
--ladybug Enable support for Ladybug (ladybug_dump, ladybug_dump_die, ld, ldd)
--symfony Enable support for Symfony2 (dump, VarDumper::dump, VarDumper::setHandler, Vardumper::dd())
--doctrine Enable support for Doctrine (Doctrine::dump, \Doctrine\Common\Util\Debug::dump)
--laravel Enable support for Laravel (dd, dump)
--roadrunner Enable support for Roadrunner (dumprr)
--extensions Check only files with selected extensions separated by comma
(default: php, php3, php4, php5, phtml)
--exclude Exclude directory. If you want exclude multiple directory, use
multiple exclude parameters.
--no-colors Disable colors in console output.
-V, --version Show version.
-h, --help Print this help.
<?php
}
// Help
if (!isset($_SERVER['argv'][1]) || in_array('-h', $_SERVER['argv']) || in_array('--help', $_SERVER['argv'])) { ?>
PHP Var Dump check version <?= VERSION ?>
---------------------------
Usage:
var-dump-check [files or directories]
<?php
showOptions();
exit;
}
// Version
if (in_array('-V', $_SERVER['argv']) || in_array('--version', $_SERVER['argv'])) {
echo VERSION . PHP_EOL;
exit;
}
$files = array(
__DIR__ . '/../../autoload.php',
__DIR__ . '/vendor/autoload.php'
);
$autoloadFileFound = false;
foreach ($files as $file) {
if (file_exists($file)) {
require $file;
$autoloadFileFound = true;
break;
}
}
if (!$autoloadFileFound) {
fwrite(STDERR,
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
'php composer.phar install' . PHP_EOL
);
die(FAILED);
}
try {
$settings = PhpVarDumpCheck\Settings::parseArguments($_SERVER['argv']);
} catch (PhpVarDumpCheck\Exception\InvalidArgument $e) {
fwrite(STDERR, "Invalid option {$e->getArgument()}" . PHP_EOL);
echo PHP_EOL;
showOptions();
die(FAILED);
}
try {
$check = new PhpVarDumpCheck\Manager();
$status = $check->check($settings);
die($status ? SUCCESS : WITH_ERRORS);
} catch (PhpVarDumpCheck\Exception\Exception $e) {
fwrite(STDERR, $e->getMessage() . PHP_EOL);
die(FAILED);
}