Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Commit 32100de

Browse files
committed
Delete temporary unzipped directory
1 parent 9167a33 commit 32100de

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

phar-source/download-phpstan

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ echo " " . 'https://github.com/phpstan/phpstan-phar-composer-source'
2222
echo "\n";
2323
echo "\n";
2424

25+
function deleteDirectoryWithContents(string $path): void {
26+
$iterator = new RecursiveDirectoryIterator($path);
27+
$iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
28+
$files = new RecursiveIteratorIterator($iterator);
29+
foreach ($files as $file) {
30+
@unlink($file->getPathname());
31+
}
32+
33+
@rmdir($path . '/conf');
34+
@rmdir($path);
35+
}
36+
2537
$pharRunning = \Phar::running(false);
2638
if ($pharRunning === '') {
2739
$root = __DIR__ . '/..';
@@ -59,7 +71,7 @@ $getVersion = function () use ($vendorDir) {
5971
break;
6072
}
6173

62-
return '2.1.28';
74+
return '2.1.27';
6375
};
6476

6577
$downloadPhpstan = function (string $version) use ($root, $phpstanPharPath) {
@@ -104,9 +116,11 @@ $downloadPhpstan = function (string $version) use ($root, $phpstanPharPath) {
104116
$autoloader->unregister();
105117

106118
$resCopy = copy($root . '/' . $phpstanDirPath . '/phpstan.phar', $root . '/phpstan-downloaded.phar');
119+
@unlink($tempPath);
120+
deleteDirectoryWithContents($root . '/' . $phpstanDirPath);
121+
107122
if ($resCopy === false) {
108123
echo "Could not find copy phpstan.phar\n";
109-
@unlink($tempPath);
110124
exit(1);
111125
}
112126
};

phpstan.phar

849 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)