Last active
March 31, 2021 21:02
-
-
Save zonuexe/7e0e25f1341186065adbe4bac96f6288 to your computer and use it in GitHub Desktop.
PhpStormでPHPStanに無駄なファイルを解析させないラッパースクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
/** @license WTFPL http://www.wtfpl.net/ 2020 tadsan */ | |
$base_dir = dirname(__DIR__) . '/'; | |
$new_argv = [__DIR__ . '/phpstan']; | |
array_shift($argv); | |
file_put_contents(__DIR__ . '/../phpstan.log', json_encode($argv, JSON_UNESCAPED_SLASHES) . PHP_EOL, FILE_APPEND); | |
foreach ($argv as $arg) { | |
$new_argv[] = strtr($arg, ['/opt/PHPStantemp_folder/' => $base_dir]); | |
} | |
if (PHP_VERSION_ID < 70400) { | |
$new_argv = implode(' ', array_map('escapeshellarg', $new_argv)); | |
} | |
file_put_contents(__DIR__ . '/../phpstan.log', json_encode($new_argv, JSON_UNESCAPED_SLASHES) . PHP_EOL, FILE_APPEND); | |
$descriptor = [STDIN, STDOUT, STDERR]; | |
$proc = proc_open($new_argv, $descriptor, $pipes); | |
exit(proc_close($proc)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
/** @license WTFPL http://www.wtfpl.net/ 2020 tadsan */ | |
$new_argv = [__DIR__ . '/path-to-your-phpstan/vendor/bin/phpstan']; | |
array_shift($argv); | |
foreach ($argv as $arg) { | |
if (strpos($arg, $_SERVER['HOME']) !== 0) { | |
$new_argv[] = $arg; | |
} | |
} | |
$descriptor = [STDIN, STDOUT, STDERR]; | |
$proc = proc_open($new_argv, $descriptor, $pipes); | |
proc_close($proc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment