From 1a9f1f7a3d97814db10bd80cd5eaefc0c2713e21 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 1 Feb 2019 14:12:29 +0100 Subject: [PATCH] Use Collection class rather than collect() helper --- src/Install/Prerequisite/Composite.php | 2 +- src/Install/Prerequisite/PhpExtensions.php | 2 +- src/Install/Prerequisite/PhpVersion.php | 6 ++++-- src/Install/Prerequisite/WritablePaths.php | 4 ++-- src/Install/Steps/EnableBundledExtensions.php | 3 ++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Install/Prerequisite/Composite.php b/src/Install/Prerequisite/Composite.php index ed3a36e07..dcf380f1c 100644 --- a/src/Install/Prerequisite/Composite.php +++ b/src/Install/Prerequisite/Composite.php @@ -34,7 +34,7 @@ class Composite implements PrerequisiteInterface function (Collection $errors, PrerequisiteInterface $condition) { return $errors->concat($condition->problems()); }, - collect() + new Collection ); } } diff --git a/src/Install/Prerequisite/PhpExtensions.php b/src/Install/Prerequisite/PhpExtensions.php index bac5f0d47..89ed4ac7b 100644 --- a/src/Install/Prerequisite/PhpExtensions.php +++ b/src/Install/Prerequisite/PhpExtensions.php @@ -24,7 +24,7 @@ class PhpExtensions implements PrerequisiteInterface public function problems(): Collection { - return collect($this->extensions) + return (new Collection($this->extensions)) ->reject(function ($extension) { return extension_loaded($extension); })->map(function ($extension) { diff --git a/src/Install/Prerequisite/PhpVersion.php b/src/Install/Prerequisite/PhpVersion.php index fca994735..3257b27c9 100644 --- a/src/Install/Prerequisite/PhpVersion.php +++ b/src/Install/Prerequisite/PhpVersion.php @@ -24,13 +24,15 @@ class PhpVersion implements PrerequisiteInterface public function problems(): Collection { + $collection = new Collection; + if (version_compare(PHP_VERSION, $this->minVersion, '<')) { - return collect()->push([ + $collection->push([ 'message' => "PHP $this->minVersion is required.", 'detail' => 'You are running version '.PHP_VERSION.'. You might want to talk to your system administrator about upgrading to the latest PHP version.', ]); } - return collect(); + return $collection; } } diff --git a/src/Install/Prerequisite/WritablePaths.php b/src/Install/Prerequisite/WritablePaths.php index 99beb2a3d..0d5e8e7c5 100644 --- a/src/Install/Prerequisite/WritablePaths.php +++ b/src/Install/Prerequisite/WritablePaths.php @@ -30,7 +30,7 @@ class WritablePaths implements PrerequisiteInterface private function getMissingPaths(): Collection { - return collect($this->paths) + return (new Collection($this->paths)) ->reject(function ($path) { return file_exists($path); })->map(function ($path) { @@ -43,7 +43,7 @@ class WritablePaths implements PrerequisiteInterface private function getNonWritablePaths(): Collection { - return collect($this->paths) + return (new Collection($this->paths)) ->filter(function ($path) { return file_exists($path) && ! is_writable($path); })->map(function ($path) { diff --git a/src/Install/Steps/EnableBundledExtensions.php b/src/Install/Steps/EnableBundledExtensions.php index 235da2eb6..b887339e5 100644 --- a/src/Install/Steps/EnableBundledExtensions.php +++ b/src/Install/Steps/EnableBundledExtensions.php @@ -18,6 +18,7 @@ use Flarum\Install\Step; use Flarum\Settings\DatabaseSettingsRepository; use Illuminate\Database\ConnectionInterface; use Illuminate\Support\Arr; +use Illuminate\Support\Collection; use League\Flysystem\Adapter\Local; use League\Flysystem\Filesystem; @@ -91,7 +92,7 @@ class EnableBundledExtensions implements Step { $json = file_get_contents("$this->basePath/vendor/composer/installed.json"); - return collect(json_decode($json, true)) + return (new Collection(json_decode($json, true))) ->filter(function ($package) { return Arr::get($package, 'type') == 'flarum-extension'; })->filter(function ($package) {