1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Add psalm bin folder

This commit is contained in:
Matthew Brown 2016-07-26 15:12:44 -04:00
parent 4a13f669d8
commit 2a2b5f7efc
2 changed files with 71 additions and 0 deletions

70
bin/psalm Executable file
View File

@ -0,0 +1,70 @@
#!/usr/bin/env php
<?php
foreach ([__DIR__ . '/../../../autoload.php', __DIR__ . '/../vendor/autoload.php'] as $file) {
if (file_exists($file)) {
require $file;
break;
}
}
use Psalm\FileChecker;
use Psalm\ProjectChecker;
use Psalm\IssueBuffer;
// show all errors
error_reporting(E_ALL & ~E_STRICT);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('memory_limit', '2048M');
// get options from command line
$options = getopt('f:m:', ['debug', 'skip-scripts', 'config:', 'monochrome']);
// get vars from options
$debug = array_key_exists('debug', $options);
$path_to_check = isset($options['f']) ? realpath($options['f']) : null;
$path_to_config = isset($options['config']) ? realpath($options['config']) : null;
$skip_scripts = array_key_exists('skip-scripts', $options);
$use_color = !array_key_exists('monochrome', $options);
// set the cache directory for the file checker
FileChecker::setCacheDir('/var/tmp/php-parser');
// initialise custom config, if passed
if ($path_to_config) {
ProjectChecker::setConfigXML($path_to_config);
}
ProjectChecker::$use_color = $use_color;
$time = microtime(true);
if ($path_to_check === null) {
ProjectChecker::check($debug);
if (!$skip_scripts) {
ProjectChecker::checkDir(realpath('scripts'), $debug);
ProjectChecker::checkDir(realpath('cron'), $debug);
}
}
elseif ($path_to_check) {
if (is_dir($path_to_check)) {
ProjectChecker::checkDir($path_to_check, $debug);
}
else {
if ($path_to_check === __FILE__) {
exit(0);
}
ProjectChecker::checkFile($path_to_check, $debug);
}
}
else {
die('Cannot locate ' . $options['f'] . PHP_EOL);
}
if ($debug) {
echo('Checks took ' . (microtime(true) - $time));
echo(' and used ' . memory_get_peak_usage() . PHP_EOL);
}

View File

@ -13,6 +13,7 @@
"php": ">=5.4",
"nikic/PHP-Parser": "2.1.0"
},
"bin": ["bin/psalm"],
"autoload": {
"psr-4": {
"Psalm\\": "src/Psalm"