From d6a82e5c56e8df9794e71efe5bbe7d36f68e47f6 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 27 Nov 2020 14:49:47 +0200 Subject: [PATCH] Fixed minor installer issues --- system/src/Grav/Installer/Install.php | 41 ++++++++++++++------ system/src/Grav/Installer/VersionUpdater.php | 6 ++- system/src/Grav/Installer/Versions.php | 4 +- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/system/src/Grav/Installer/Install.php b/system/src/Grav/Installer/Install.php index b7ef53eef..9be16160b 100644 --- a/system/src/Grav/Installer/Install.php +++ b/system/src/Grav/Installer/Install.php @@ -10,11 +10,15 @@ namespace Grav\Installer; use Composer\Autoload\ClassLoader; +use Exception; use Grav\Common\Cache; use Grav\Common\GPM\Installer; use Grav\Common\Grav; use Grav\Common\Plugins; +use RuntimeException; +use function class_exists; use function dirname; +use function function_exists; use function is_string; /** @@ -132,6 +136,10 @@ final class Install { } + /** + * @param string|null $zip + * @return $this + */ public function setZip(?string $zip) { $this->zip = $zip; @@ -139,6 +147,10 @@ final class Install return $this; } + /** + * @param string|null $zip + * @return void + */ public function __invoke(?string $zip) { $this->zip = $zip; @@ -163,7 +175,7 @@ rm grav-update.zip ERR; } - throw new \RuntimeException($errors); + throw new RuntimeException($errors); } $this->prepare(); @@ -188,7 +200,8 @@ ERR; } /** - * @throws \RuntimeException + * @return void + * @throws RuntimeException */ public function prepare(): void { @@ -197,18 +210,18 @@ ERR; $target = realpath(GRAV_ROOT . '/index.php'); if (!$location) { - throw new \RuntimeException('Internal Error', 500); + throw new RuntimeException('Internal Error', 500); } if ($target && dirname($location, 4) === dirname($target)) { // We cannot copy files into themselves, abort! - throw new \RuntimeException('Grav has already been installed here!', 400); + throw new RuntimeException('Grav has already been installed here!', 400); } // Make sure that none of the Grav\Installer classes have been loaded, otherwise installation may fail! foreach ($this->classMap as $class_name => $path) { - if (\class_exists($class_name, false)) { - throw new \RuntimeException(sprintf('Cannot update Grav, class %s has already been loaded!', $class_name), 500); + if (class_exists($class_name, false)) { + throw new RuntimeException(sprintf('Cannot update Grav, class %s has already been loaded!', $class_name), 500); } } @@ -231,12 +244,13 @@ ERR; } /** - * @throws \RuntimeException + * @return void + * @throws RuntimeException */ public function install(): void { if (!$this->location) { - throw new \RuntimeException('Oops, installer was run without prepare()!', 500); + throw new RuntimeException('Oops, installer was run without prepare()!', 500); } try { @@ -250,7 +264,7 @@ ERR; $this->location, !($this->zip && is_file($this->zip)) ); - } catch (\Exception $e) { + } catch (Exception $e) { Installer::setError($e->getMessage()); } @@ -259,12 +273,13 @@ ERR; $success = !(is_string($errorCode) || ($errorCode & (Installer::ZIP_OPEN_ERROR | Installer::ZIP_EXTRACT_ERROR))); if (!$success) { - throw new \RuntimeException(Installer::lastErrorMsg()); + throw new RuntimeException(Installer::lastErrorMsg()); } } /** - * @throws \RuntimeException + * @return void + * @throws RuntimeException */ public function finalize(): void { @@ -284,6 +299,7 @@ ERR; * @param string $name * @param array $check * @param string|null $version + * @return void */ protected function checkVersion(array &$results, $type, $name, array $check, $version): void { @@ -328,10 +344,11 @@ ERR; /** * @param array $results * @param array $plugins + * @return void */ protected function checkPlugins(array &$results, array $plugins): void { - if (!\class_exists('Plugins')) { + if (!class_exists('Plugins')) { return; } diff --git a/system/src/Grav/Installer/VersionUpdater.php b/system/src/Grav/Installer/VersionUpdater.php index 6b71f5eb7..5cc621daa 100644 --- a/system/src/Grav/Installer/VersionUpdater.php +++ b/system/src/Grav/Installer/VersionUpdater.php @@ -5,8 +5,8 @@ namespace Grav\Installer; use DirectoryIterator; /** - * Class Update_1_7_0_20201120_1 - * @package Grav\Installer\updates + * Class VersionUpdater + * @package Grav\Installer */ final class VersionUpdater { @@ -14,6 +14,8 @@ final class VersionUpdater private $name; /** @var string */ private $path; + /** @var string */ + private $version; /** @var Versions */ private $versions; /** @var VersionUpdate[] */ diff --git a/system/src/Grav/Installer/Versions.php b/system/src/Grav/Installer/Versions.php index a85203fdf..9b663b5ab 100644 --- a/system/src/Grav/Installer/Versions.php +++ b/system/src/Grav/Installer/Versions.php @@ -32,7 +32,7 @@ final class Versions /** * @param string|null $filename - * @return static + * @return self */ public static function instance(string $filename = null): self { @@ -215,7 +215,7 @@ final class Versions /** * Clears extension history. Useful when creating skeletons. * - * @param string|null $extension + * @param string $extension */ public function removeHistory(string $extension): void {