mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 15:03:44 +08:00
Use Collection class rather than collect() helper
This commit is contained in:
parent
fd7610ffee
commit
638f934ec4
|
@ -34,7 +34,7 @@ class Composite implements PrerequisiteInterface
|
|||
function (Collection $errors, PrerequisiteInterface $condition) {
|
||||
return $errors->concat($condition->problems());
|
||||
},
|
||||
collect()
|
||||
new Collection
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user