1
0
mirror of https://github.com/flarum/core.git synced 2025-08-09 18:07:02 +02:00

Apply fixes from StyleCI

[ci skip] [skip ci]
This commit is contained in:
luceos
2021-05-30 09:53:09 +00:00
committed by StyleCI Bot
parent 979a471214
commit 0727f3d6d4
3 changed files with 16 additions and 8 deletions

View File

@@ -1,11 +1,17 @@
<?php <?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Database; namespace Flarum\Database;
use Flarum\Extension\Extension; use Flarum\Extension\Extension;
use Flarum\Foundation\Application; use Flarum\Foundation\Application;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
use Illuminate\Support\Collection;
class MigrationSourceRepository class MigrationSourceRepository
{ {
@@ -27,7 +33,9 @@ class MigrationSourceRepository
public function extension(Extension $extension): ?array public function extension(Extension $extension): ?array
{ {
if (! $extension->hasMigrations()) return []; if (! $extension->hasMigrations()) {
return [];
}
return $extension->getMigrations(); return $extension->getMigrations();
} }
@@ -36,12 +44,12 @@ class MigrationSourceRepository
{ {
// We read every file from the latest major/minor version migrations directory. // We read every file from the latest major/minor version migrations directory.
// Including the create_<table>_table statements. // Including the create_<table>_table statements.
$files = glob(__DIR__ . '/../../migrations/' . $this->installedVersion(true) . '/[0-9_]{15}_*.php'); $files = glob(__DIR__.'/../../migrations/'.$this->installedVersion(true).'/[0-9_]{15}_*.php');
// Sort by timestamp. // Sort by timestamp.
sort($files); sort($files);
$create = glob(__DIR__ . '/../../migrations/' . $this->installedVersion(true) . '/create_*.php'); $create = glob(__DIR__.'/../../migrations/'.$this->installedVersion(true).'/create_*.php');
return array_merge($create, $files); return array_merge($create, $files);
} }
@@ -51,7 +59,7 @@ class MigrationSourceRepository
$files = []; $files = [];
$add = false; $add = false;
$directories = glob(__DIR__ . '/../../migrations/', GLOB_ONLYDIR); $directories = glob(__DIR__.'/../../migrations/', GLOB_ONLYDIR);
sort($directories, SORT_NATURAL); sort($directories, SORT_NATURAL);
// Upgrade // Upgrade
@@ -65,7 +73,7 @@ class MigrationSourceRepository
if ($add) { if ($add) {
// Selectively add files, but only include those matching the format YYYY_MM_DD_HHIISS_<something>.php // Selectively add files, but only include those matching the format YYYY_MM_DD_HHIISS_<something>.php
// This excludes the create_<table>_table. // This excludes the create_<table>_table.
$files = array_merge($files, glob(__DIR__ . "/../../migrations/$directory/[0-9_]{15}_*.php")); $files = array_merge($files, glob(__DIR__."/../../migrations/$directory/[0-9_]{15}_*.php"));
} }
// Once we found the version that is installed, we can quit. // Once we found the version that is installed, we can quit.

View File

@@ -212,7 +212,8 @@ class Migrator
public function getMigrationFiles(string $path, Extension $extension = null): array public function getMigrationFiles(string $path, Extension $extension = null): array
{ {
$files = $extension ? $this->source->extension($extension) : $this->source->flarum(); $files = $extension ? $this->source->extension($extension) : $this->source->flarum();
dd($files); dd($files);
return array_map(function ($file) { return array_map(function ($file) {
return str_replace('.php', '', basename($file)); return str_replace('.php', '', basename($file));
}, $files); }, $files);

View File

@@ -9,7 +9,6 @@
namespace Flarum\Extension; namespace Flarum\Extension;
use Flarum\Database\Migrator;
use Flarum\Extend\LifecycleInterface; use Flarum\Extend\LifecycleInterface;
use Flarum\Extension\Exception\ExtensionBootError; use Flarum\Extension\Exception\ExtensionBootError;
use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Container\Container;