Use Collection class rather than collect() helper

This commit is contained in:
Franz Liedke 2019-02-01 14:12:29 +01:00
parent fd7610ffee
commit 638f934ec4
5 changed files with 10 additions and 7 deletions

View File

@ -34,7 +34,7 @@ class Composite implements PrerequisiteInterface
function (Collection $errors, PrerequisiteInterface $condition) {
return $errors->concat($condition->problems());
},
collect()
new Collection
);
}
}

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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) {

View File

@ -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) {