From fda9dc000f593b385895fa7b49cf25ab187838f7 Mon Sep 17 00:00:00 2001 From: JaxkDev Date: Sat, 17 Oct 2020 18:23:41 +0100 Subject: [PATCH 1/4] Torture your eyes with the composer update, moving away from hardcoded/installed dependencies users can now specify everything* they need in composer.json --- Dockerfile | 47 ++++++++++++--- default.phpstan.neon | 5 +- entry.php | 135 +++++++++++++++++++++++++++++++++---------- 3 files changed, 143 insertions(+), 44 deletions(-) diff --git a/Dockerfile b/Dockerfile index b69702e..aa1fef4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,50 @@ -FROM pmmp/pocketmine-mp:latest +FROM ubuntu:18.04 as phpBuild USER root -RUN apt-get update && apt-get install -y --no-install-recommends git + +# Prerequisites +# Default directorys: +RUN mkdir /deps +RUN mkdir /source +RUN mkdir /php + +# Dependencies: +RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates wget make autoconf automake libtool-bin m4 gzip bzip2 bison g++ git cmake pkg-config re2c +WORKDIR /php +RUN wget -q https://raw.githubusercontent.com/pmmp/php-build-scripts/stable/compile.sh +RUN bash compile.sh -t linux64 -f -u -g -l + +# New slate to lose all unwanted libs (~300mb lost here) +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates wget + +COPY --from=phpBuild /php/bin/php7 /usr/php +RUN grep -q '^extension_dir' /usr/php/bin/php.ini && \ + sed -ibak "s{^extension_dir=.*{extension_dir=\"$(find /usr/php -name *debug-zts*)\"{" /usr/php/bin/php.ini || echo "extension_dir=\"$(find /usr/php -name *debug-zts*)\"" >> /usr/php/bin/php.ini +RUN ln -s /usr/php/bin/php /usr/bin/php + RUN wget -qO - https://getcomposer.org/installer | php RUN mv composer.phar /usr/bin/composer -RUN wget -qO /usr/bin/phpstan https://github.com/phpstan/phpstan/releases/download/0.12.38/phpstan.phar -RUN chmod o+x /usr/bin/phpstan -ADD entry.php /usr/bin/entry -ADD default.phpstan.neon /pocketmine/default.phpstan.neon + RUN mkdir /deps RUN mkdir /source -RUN chown 1000:1000 /pocketmine/default.phpstan.neon /deps /source -R -USER pocketmine +# Default files: +ADD entry.php /usr/bin/entry +ADD default.phpstan.neon /source/default.phpstan.neon + +# Permissions: +RUN groupadd -g 1000 client +RUN useradd -r -m -u 1000 -g client client + +RUN chown 1000:1000 /deps /source -R + +USER client WORKDIR /source ENV PLUGIN_PATH / -ENV PHPSTAN_CONFIG /pocketmine/default.phpstan.neon +ENV DEFAULT_PHPSTAN_CONFIG /source/default.phpstan.neon + ENTRYPOINT ["entry"] CMD [] diff --git a/default.phpstan.neon b/default.phpstan.neon index d3a80d6..dacc9cd 100644 --- a/default.phpstan.neon +++ b/default.phpstan.neon @@ -2,8 +2,5 @@ parameters: level: 4 paths: - /source/src - autoload_directories: - - /source/src + scanDirectories: - /deps - autoload_files: - - phar:///pocketmine/PocketMine-MP.phar/vendor/autoload.php diff --git a/entry.php b/entry.php index 5c4505c..5db1ac5 100755 --- a/entry.php +++ b/entry.php @@ -56,8 +56,23 @@ echo "[Info] -> Starting prerequisite checks...\n"; +$DEFAULT_INSTALLED = false; +$DEFAULT_PMMP_V = "^3.0.0"; +$DEFAULT_PHPSTAN_V = "^0.12.0"; +$_ENV["PHPSTAN_CONFIG"] = $_ENV["DEFAULT_PHPSTAN_CONFIG"]; + if(is_file("/source/phpstan.neon.dist")) $_ENV["PHPSTAN_CONFIG"] = "/source/phpstan.neon.dist"; if(is_file("/source/phpstan.neon")) $_ENV["PHPSTAN_CONFIG"] = "/source/phpstan.neon"; +if(!is_file("/source/composer.json")){ + $DEFAULT_INSTALLED = true; + echo "[Info] -> Installing pocketmine/pocketmine-mp:{$DEFAULT_PMMP_V} & phpstan/phpstan:{$DEFAULT_PHPSTAN_V}\n"; + myShellExec("composer require phpstan/phpstan:{$DEFAULT_PHPSTAN_V} pocketmine/pocketmine-mp:{$DEFAULT_PMMP_V} --no-suggest --no-progress", $stdout, $null, $code); + if($code !== 0){ + // Should never happen. + fwrite(STDERR, "[Error] -> Failed to install default packages!".PHP_EOL); + exit(5); + } +} if(is_file("/source/plugin.yml")) { if(!is_dir("/source/src")) { @@ -69,41 +84,99 @@ exit(3); } -if(is_file("/source/composer.json")) { - passthru("composer install --no-suggest --no-progress -n -o", $result); - if($result !== 0) { - fwrite(STDERR, "[Error] -> Failed to install composer dependencies !\n".PHP_EOL); - exit(5); - } +if(!$DEFAULT_INSTALLED) { + passthru("composer install --no-suggest --no-progress -q", $exitCode); + if ($exitCode !== 0) { + fwrite(STDERR, "[Error] -> Failed to run initial composer install !" . PHP_EOL); + exit(5); + } +} + +function get_composer_status(){ + myShellExec("composer show --format=json", $stdout, $stderr, $exitCode); + + if($exitCode !== 0){ + fwrite(STDERR, "[Error] -> Failed to query composer packages installed.".PHP_EOL); + fwrite(STDERR, $stderr); + exit(5); + } + + $data = json_decode($stdout, true); + if($data === []) return [false, null, null]; + $phpstan = null; + $pmmp = null; + for($i = 0; $i < sizeof($data["installed"]); $i++){ + $d = $data["installed"][$i]; + if($d["name"] === "phpstan/phpstan"){ + $phpstan = $d["version"]; + } + if($d["name"] === "pocketmine/pocketmine-mp"){ + $pmmp = $d["version"]; + } + } + + return [($pmmp !== null and $phpstan !== null), $pmmp, $phpstan]; +} + +$d = get_composer_status(); + +if($d[0]){ + echo "[Info] -> Using pmmp v{$d[1]} and phpstan v{$d[2]}\n"; + goto phpstan; +} else { + if($d[1] === null){ + echo "[Info] -> Installing pmmp as it was not found.\n"; + passthru("composer require pocketmine/pocketmine-mp:{$DEFAULT_PMMP_V} --no-suggest --no-progress -q"); + } + if($d[2] === null){ + echo "[Info] -> Installing phpstan as it was not found.\n"; + passthru("composer require phpstan/phpstan:{$DEFAULT_PHPSTAN_V} --no-suggest --no-progress -q"); + } +} + +$d = get_composer_status(); +if($d[0]){ + echo "[Info] -> Using pmmp v{$d[1]} and phpstan v{$d[2]}\n"; +} else { + // This should never happen... + fwrite(STDERR, "[Error] -> Composer failed to install default requirements.\n"); + exit(5); } +phpstan: echo "[Info] -> Starting phpstan...\n"; -$proc = proc_open("phpstan analyze --error-format=json --no-progress --memory-limit=2G -c {$_ENV["PHPSTAN_CONFIG"]} > /source/phpstan-results.json", [0 => ["file", "/dev/null", "r"], 1 => ["pipe", "w"], 2 => ["pipe", "w"]], $pipes); -if(is_resource($proc)) { - $stdout = stream_get_contents($pipes[1]); - fclose($pipes[1]); - fwrite(STDOUT, $stdout); - $stderr = stream_get_contents($pipes[2]); // Go through another pipe so we can catch the data. - fclose($pipes[2]); - fwrite(STDERR, $stderr); //Pass on back to poggit. - $code = proc_close($proc); - if($code === 1){ - if($stderr !== "") exit(8); - echo "[Warning] -> Analysis failed/found problems."; - exit(6); - } - if($code === 255){ - //Phpstan unable to parse, shouldn't happen... - fwrite(STDERR, "[Error] -> PHPStan (255) - Unable to parse.".PHP_EOL); - exit(7); - } - if($code !== 0) { - fwrite(STDERR, "[Error] -> Unhandled exit status: $code.".PHP_EOL); - exit(9); - } - echo "[Info] -> No problems found !"; - exit(0); +myShellExec("php vendor/bin/phpstan.phar analyze --error-format=json --no-progress --memory-limit=2G -c {$_ENV["PHPSTAN_CONFIG"]} > /source/phpstan-results.json", $stdout, $stderr, $exitCode); +fwrite(STDOUT, $stdout); +fwrite(STDERR, $stderr); //Pass on back to poggit. +if($exitCode === 1){ + if($stderr !== "") exit(8); + echo "[Warning] -> Analysis failed/found problems."; + exit(6); +} +if($exitCode === 255){ + //Phpstan unable to parse, shouldn't happen... + fwrite(STDERR, "[Error] -> PHPStan (255) - Unable to parse.".PHP_EOL); + exit(7); +} +if($exitCode !== 0) { + fwrite(STDERR, "[Error] -> Unhandled exit status: $code.".PHP_EOL); + exit(9); +} +echo "[Info] -> No problems found !"; +exit(0); + + +function myShellExec(string $cmd, &$stdout, &$stderr = null, &$exitCode = null) { + $proc = proc_open($cmd, [ + 1 => ["pipe", "w"], + 2 => ["pipe", "w"] + ], $pipes, getcwd()); + $stdout = stream_get_contents($pipes[1]); + fclose($pipes[1]); + $stderr = stream_get_contents($pipes[2]); + fclose($pipes[2]); + $exitCode = (int) proc_close($proc); } function rrmdir($dir) { From 87912f978775d49ec0c218562ce143ede29cc803 Mon Sep 17 00:00:00 2001 From: JaxkDev Date: Sun, 18 Oct 2020 16:53:54 +0100 Subject: [PATCH 2/4] Changes pre-build, removed useless directories. --- Dockerfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index aa1fef4..29bba5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,17 +2,11 @@ FROM ubuntu:18.04 as phpBuild USER root -# Prerequisites -# Default directorys: -RUN mkdir /deps -RUN mkdir /source RUN mkdir /php - -# Dependencies: RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates wget make autoconf automake libtool-bin m4 gzip bzip2 bison g++ git cmake pkg-config re2c WORKDIR /php RUN wget -q https://raw.githubusercontent.com/pmmp/php-build-scripts/stable/compile.sh -RUN bash compile.sh -t linux64 -f -u -g -l +RUN bash compile.sh -t linux64 -f -u -g -l -j # New slate to lose all unwanted libs (~300mb lost here) FROM ubuntu:18.04 From 7c891be2687246b6166a693c93f8738b24a145cc Mon Sep 17 00:00:00 2001 From: JaxkDev Date: Mon, 15 Feb 2021 20:38:57 +0000 Subject: [PATCH 3/4] Mass amount of changes in one... - Sorry but it got messy. - Default level changed to 5 - Added composer 'properly' --- Dockerfile | 7 +- default.phpstan.neon | 9 +- entry.php | 199 ++++++++++++++++++++----------------------- 3 files changed, 100 insertions(+), 115 deletions(-) diff --git a/Dockerfile b/Dockerfile index 29bba5d..c51b917 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,8 @@ RUN ln -s /usr/php/bin/php /usr/bin/php RUN wget -qO - https://getcomposer.org/installer | php RUN mv composer.phar /usr/bin/composer -RUN mkdir /deps RUN mkdir /source +RUN mkdir /source/poggit_deps # Default files: ADD entry.php /usr/bin/entry @@ -32,13 +32,10 @@ ADD default.phpstan.neon /source/default.phpstan.neon RUN groupadd -g 1000 client RUN useradd -r -m -u 1000 -g client client -RUN chown 1000:1000 /deps /source -R +RUN chown 1000:1000 /source -R USER client WORKDIR /source -ENV PLUGIN_PATH / -ENV DEFAULT_PHPSTAN_CONFIG /source/default.phpstan.neon - ENTRYPOINT ["entry"] CMD [] diff --git a/default.phpstan.neon b/default.phpstan.neon index dacc9cd..05e1222 100644 --- a/default.phpstan.neon +++ b/default.phpstan.neon @@ -1,6 +1,7 @@ parameters: - level: 4 + level: 5 paths: - - /source/src - scanDirectories: - - /deps + - src + excludePaths: + analyse: + - poggit_deps diff --git a/entry.php b/entry.php index 5db1ac5..ba4dcb4 100755 --- a/entry.php +++ b/entry.php @@ -21,132 +21,118 @@ declare(strict_types=1); -echo "[Info] -> Extracting plugin from plugin.zip, pluginPath: {$_ENV["PLUGIN_PATH"]}...\n"; +//WorkingDir = /source/ + +echo "[Info] -> Getting ENV Variables...\n"; + +$PLUGIN_PATH = $_ENV["PLUGIN_PATH"] ?? "/"; +$PHPSTAN_CONFIG = $_ENV["PHPSTAN_CONFIG"] ?? "default.phpstan.neon"; +$DEFAULT_PHPSTAN_VERSION = $_ENV["DEFAULT_PHPSTAN_VERSION"] ?? "0.12.76"; +$DEFAULT_POCKETMINE_VERSION = $_ENV["DEFAULT_POCKETMINE_VERSION"] ?? "3.17.0"; + +echo "[Info] -> Extracting plugin from plugin.zip, pluginPath: {$PLUGIN_PATH}...\n"; try { - @mkdir("/source/tmpExtractionDir"); - $zip = new ZipArchive(); - $zip->open("/source/plugin.zip"); - $zip->extractTo("/source/tmpExtractionDir"); - $zip->close(); - @unlink("/source/plugin.zip"); - $folder = (scandir("/source/tmpExtractionDir/"))[2]; //Thanks github. - passthru("mv /source/tmpExtractionDir/${folder}{$_ENV["PLUGIN_PATH"]}* /source/"); - rrmdir("/source/tmpExtractionDir"); + @mkdir("tmpExtractionDir"); + $zip = new ZipArchive(); + $zip->open("plugin.zip"); + $zip->extractTo("tmpExtractionDir"); + $zip->close(); + @unlink("plugin.zip"); + $folder = (scandir("tmpExtractionDir/"))[2]; //Thanks github. + passthru("mv tmpExtractionDir/${folder}{$PLUGIN_PATH}* ."); + rrmdir("tmpExtractionDir"); } catch (Throwable $e){ - fwrite(STDERR,$e->getMessage().PHP_EOL); - exit(3); + fwrite(STDERR,$e->getMessage().PHP_EOL); + exit(3); } echo "[Info] -> Extracting dependency's...\n"; try { - $folder = array_slice(scandir("/deps/"), 2); - foreach($folder as $file) { - $phar = new Phar("/deps/${file}"); - $phar2 = $phar->convertToExecutable(Phar::TAR, Phar::NONE); // Create uncompressed archive - $phar2->extractTo("/deps/", null, true); - unlink("/deps/${file}"); - unlink($phar2->getPath()); - } + $folder = array_slice(scandir("poggit_deps/"), 2); + foreach($folder as $file) { + $phar = new Phar("poggit_deps/${file}"); + $phar2 = $phar->convertToExecutable(Phar::TAR, Phar::NONE); // Create uncompressed archive + $phar2->extractTo("poggit_deps/", null, true); + unlink("poggit_deps/${file}"); + unlink($phar2->getPath()); + } } catch(Throwable $e){ - fwrite(STDERR,$e->getMessage().PHP_EOL); - exit(4); + fwrite(STDERR,$e->getMessage().PHP_EOL); + exit(4); } echo "[Info] -> Starting prerequisite checks...\n"; -$DEFAULT_INSTALLED = false; -$DEFAULT_PMMP_V = "^3.0.0"; -$DEFAULT_PHPSTAN_V = "^0.12.0"; -$_ENV["PHPSTAN_CONFIG"] = $_ENV["DEFAULT_PHPSTAN_CONFIG"]; - -if(is_file("/source/phpstan.neon.dist")) $_ENV["PHPSTAN_CONFIG"] = "/source/phpstan.neon.dist"; -if(is_file("/source/phpstan.neon")) $_ENV["PHPSTAN_CONFIG"] = "/source/phpstan.neon"; -if(!is_file("/source/composer.json")){ - $DEFAULT_INSTALLED = true; - echo "[Info] -> Installing pocketmine/pocketmine-mp:{$DEFAULT_PMMP_V} & phpstan/phpstan:{$DEFAULT_PHPSTAN_V}\n"; - myShellExec("composer require phpstan/phpstan:{$DEFAULT_PHPSTAN_V} pocketmine/pocketmine-mp:{$DEFAULT_PMMP_V} --no-suggest --no-progress", $stdout, $null, $code); - if($code !== 0){ - // Should never happen. - fwrite(STDERR, "[Error] -> Failed to install default packages!".PHP_EOL); - exit(5); - } +if(!is_file("plugin.yml")) { + fwrite(STDERR, "[Error] -> plugin.yml not found. Did the container setup correctly ?".PHP_EOL); + exit(3); } - -if(is_file("/source/plugin.yml")) { - if(!is_dir("/source/src")) { - fwrite(STDERR, "[Error] -> src directory not found. Did the container setup correctly ?".PHP_EOL); - exit(3); - } -} else { - fwrite(STDERR, "[Error] -> plugin.yml not found. Did the container setup correctly ?".PHP_EOL); - exit(3); +if(!is_dir("src")) { + fwrite(STDERR, "[Error] -> src directory not found. Did the container setup correctly ?".PHP_EOL); + exit(3); } -if(!$DEFAULT_INSTALLED) { - passthru("composer install --no-suggest --no-progress -q", $exitCode); - if ($exitCode !== 0) { - fwrite(STDERR, "[Error] -> Failed to run initial composer install !" . PHP_EOL); - exit(5); - } -} +if(is_file("phpstan.neon")) $_ENV["PHPSTAN_CONFIG"] = "phpstan.neon"; +if(is_file("phpstan.neon.dist")) $_ENV["PHPSTAN_CONFIG"] = "phpstan.neon.dist"; +if(is_file("poggit.phpstan.neon")) $_ENV["PHPSTAN_CONFIG"] = "poggit.phpstan.neon"; +if(is_file("poggit.phpstan.neon.dist")) $_ENV["PHPSTAN_CONFIG"] = "poggit.phpstan.neon.dist"; -function get_composer_status(){ - myShellExec("composer show --format=json", $stdout, $stderr, $exitCode); +echo "[Info] -> Checking for composer deps...\n"; - if($exitCode !== 0){ - fwrite(STDERR, "[Error] -> Failed to query composer packages installed.".PHP_EOL); +//Priority goes to poggit.composer.json then composer.json +if(is_file("poggit.composer.json")){ + echo "[Info] -> Using 'poggit.composer.json'\n"; + if(is_file("composer.json")) unlink("composer.json"); + rename("poggit.composer.json", "composer.json"); +} +if(is_file("composer.json")){ + echo "[Info] -> Installing dependencies from plugin...\n"; + myShellExec("composer install --no-progress", $stdout, $stderr, $code); + if($code !== 0){ + fwrite(STDERR, "[Error] -> Failed to install dependencies from plugin composer file.".PHP_EOL); + fwrite(STDOUT, $stdout); fwrite(STDERR, $stderr); exit(5); } - - $data = json_decode($stdout, true); - if($data === []) return [false, null, null]; - $phpstan = null; - $pmmp = null; - for($i = 0; $i < sizeof($data["installed"]); $i++){ - $d = $data["installed"][$i]; - if($d["name"] === "phpstan/phpstan"){ - $phpstan = $d["version"]; - } - if($d["name"] === "pocketmine/pocketmine-mp"){ - $pmmp = $d["version"]; - } - } - - return [($pmmp !== null and $phpstan !== null), $pmmp, $phpstan]; +} +$pmmp = false; +$phpstan = false; +if(is_file("vendor/composer/InstalledVersions.php")){ + include "/source/vendor/composer/InstalledVersions.php"; + $pmmp = \Composer\InstalledVersions::isInstalled("pocketmine/pocketmine-mp"); + $phpstan = \Composer\InstalledVersions::isInstalled("phpstan/phpstan"); +} +if(!$pmmp){ + echo "[Info] -> Installing default pocketmine/pocketmine-mp v{$DEFAULT_POCKETMINE_VERSION}\n"; + passthru("composer require pocketmine/pocketmine-mp:{$DEFAULT_POCKETMINE_VERSION} --no-progress -q"); +} +if(!$phpstan){ + echo "[Info] -> Installing default phpstan/phpstan v{$DEFAULT_PHPSTAN_VERSION}\n"; + passthru("composer require phpstan/phpstan:{$DEFAULT_PHPSTAN_VERSION} --no-progress -q"); } -$d = get_composer_status(); +//Last check if not installed bail. +include_once "/source/vendor/composer/InstalledVersions.php"; +$data = include '/source/vendor/composer/installed.php'; +\Composer\InstalledVersions::reload($data); -if($d[0]){ - echo "[Info] -> Using pmmp v{$d[1]} and phpstan v{$d[2]}\n"; - goto phpstan; -} else { - if($d[1] === null){ - echo "[Info] -> Installing pmmp as it was not found.\n"; - passthru("composer require pocketmine/pocketmine-mp:{$DEFAULT_PMMP_V} --no-suggest --no-progress -q"); - } - if($d[2] === null){ - echo "[Info] -> Installing phpstan as it was not found.\n"; - passthru("composer require phpstan/phpstan:{$DEFAULT_PHPSTAN_V} --no-suggest --no-progress -q"); - } +if(!\Composer\InstalledVersions::isInstalled("pocketmine/pocketmine-mp")){ + echo "[Error] -> Failed to install pocketmine/pocketmine-mp\n"; + exit(5); } - -$d = get_composer_status(); -if($d[0]){ - echo "[Info] -> Using pmmp v{$d[1]} and phpstan v{$d[2]}\n"; -} else { - // This should never happen... - fwrite(STDERR, "[Error] -> Composer failed to install default requirements.\n"); - exit(5); +if(!\Composer\InstalledVersions::isInstalled("phpstan/phpstan")){ + echo "[Error] -> Failed to install phpstan/phpstan\n"; + exit(5); } -phpstan: +echo "[Info] -> Using pocketmine-mp v".\Composer\InstalledVersions::getVersion("pocketmine/pocketmine-mp")."\n"; +echo "[Info] -> Using phpstan v".\Composer\InstalledVersions::getVersion("phpstan/phpstan")."\n"; + echo "[Info] -> Starting phpstan...\n"; -myShellExec("php vendor/bin/phpstan.phar analyze --error-format=json --no-progress --memory-limit=2G -c {$_ENV["PHPSTAN_CONFIG"]} > /source/phpstan-results.json", $stdout, $stderr, $exitCode); +myShellExec("php vendor/bin/phpstan.phar analyze --error-format=json --no-progress --memory-limit=2G -c {$PHPSTAN_CONFIG} > phpstan-results.json", $stdout, $stderr, $exitCode); fwrite(STDOUT, $stdout); fwrite(STDERR, $stderr); //Pass on back to poggit. if($exitCode === 1){ @@ -155,12 +141,13 @@ function get_composer_status(){ exit(6); } if($exitCode === 255){ - //Phpstan unable to parse, shouldn't happen... + //Phpstan unable to parse fwrite(STDERR, "[Error] -> PHPStan (255) - Unable to parse.".PHP_EOL); exit(7); } if($exitCode !== 0) { - fwrite(STDERR, "[Error] -> Unhandled exit status: $code.".PHP_EOL); + //OOM Etc + fwrite(STDERR, "[Error] -> Unhandled exit status: $exitCode.".PHP_EOL); exit(9); } echo "[Info] -> No problems found !"; @@ -180,11 +167,11 @@ function myShellExec(string $cmd, &$stdout, &$stderr = null, &$exitCode = null) } function rrmdir($dir) { - if (is_dir($dir)) { - $files = scandir($dir); - foreach ($files as $file) - if ($file != "." && $file != "..") rrmdir("$dir/$file"); - rmdir($dir); - } - else if (file_exists($dir)) unlink($dir); + if (is_dir($dir)) { + $files = scandir($dir); + foreach ($files as $file) + if ($file != "." && $file != "..") rrmdir("$dir/$file"); + rmdir($dir); + } + else if (file_exists($dir)) unlink($dir); } \ No newline at end of file From dab7ad3d314740aa23d2c77a747d3ee2ff1f8f67 Mon Sep 17 00:00:00 2001 From: JaxkDev Date: Mon, 15 Feb 2021 20:50:18 +0000 Subject: [PATCH 4/4] Wrong variables... --- entry.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/entry.php b/entry.php index ba4dcb4..6b696eb 100755 --- a/entry.php +++ b/entry.php @@ -74,10 +74,10 @@ exit(3); } -if(is_file("phpstan.neon")) $_ENV["PHPSTAN_CONFIG"] = "phpstan.neon"; -if(is_file("phpstan.neon.dist")) $_ENV["PHPSTAN_CONFIG"] = "phpstan.neon.dist"; -if(is_file("poggit.phpstan.neon")) $_ENV["PHPSTAN_CONFIG"] = "poggit.phpstan.neon"; -if(is_file("poggit.phpstan.neon.dist")) $_ENV["PHPSTAN_CONFIG"] = "poggit.phpstan.neon.dist"; +if(is_file("phpstan.neon")) $PHPSTAN_CONFIG = "phpstan.neon"; +if(is_file("phpstan.neon.dist")) $PHPSTAN_CONFIG = "phpstan.neon.dist"; +if(is_file("poggit.phpstan.neon")) $PHPSTAN_CONFIG = "poggit.phpstan.neon"; +if(is_file("poggit.phpstan.neon.dist")) $PHPSTAN_CONFIG = "poggit.phpstan.neon.dist"; echo "[Info] -> Checking for composer deps...\n";