Created
February 13, 2026 22:30
-
-
Save theodorejb/26416d7a79af7b0081747288f7c9ecbb to your computer and use it in GitHub Desktop.
Extract Phar dependency source code
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
| <?php | |
| $vendorDir = __DIR__ . '/vendor'; | |
| $pharPath = "{$vendorDir}/phpstan/phpstan/phpstan.phar"; | |
| $extractPath = "{$vendorDir}/phpstan/phpstan-src"; | |
| if (is_file($pharPath)) { | |
| require "{$vendorDir}/autoload.php"; | |
| if (is_dir($extractPath)) { | |
| rmdir_recursive($extractPath); | |
| } | |
| $phar = new Phar($pharPath); | |
| $phar->extractTo($extractPath); | |
| } else { | |
| echo $pharPath . ' is not a file'; | |
| } | |
| function rmdir_recursive(string $dir): void | |
| { | |
| $cmd = PHP_OS_FAMILY === 'Windows' ? 'rmdir /s /q' : 'rm -rf'; | |
| exec($cmd . ' ' . escapeshellarg($dir), $execOutput, $execRetval); | |
| if ($execRetval !== 0) { | |
| throw new Exception("Failed to remove directory: " . var_export($execOutput, true)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment