diff --git a/system/Publisher/Publisher.php b/system/Publisher/Publisher.php index b2e9de8d577b..38d86dbb4c2a 100644 --- a/system/Publisher/Publisher.php +++ b/system/Publisher/Publisher.php @@ -43,8 +43,7 @@ class Publisher private static $discovered = []; /** - * Directory to use for methods - * that need temporary storage. + * Directory to use for methods that need temporary storage. * Created on-the-fly as needed. * * @var string|null @@ -59,8 +58,7 @@ class Publisher private $files = []; /** - * Exceptions for specific files - * from the last write operation. + * Exceptions for specific files from the last write operation. * * @var array */ @@ -81,8 +79,7 @@ class Publisher protected $destination = FCPATH; /** - * Discovers and returns all Publishers - * in the specified namespace directory. + * Discovers and returns all Publishers in the specified namespace directory. * * @param string $directory * @@ -115,16 +112,14 @@ public static function discover(string $directory = 'Publishers'): array self::$discovered[$directory][] = new $className(); } } + sort(self::$discovered[$directory]); return self::$discovered[$directory]; } - //-------------------------------------------------------------------- - /** - * Resolves a full path and verifies - * it is an actual directory. + * Resolves a full path and verifies it is an actual directory. * * @param string $directory * @@ -159,14 +154,12 @@ private static function resolveFile(string $file): string return $file; } - //-------------------------------------------------------------------- /** - * Filters an array of files, removing files not - * part of the given directory (recursive). + * Removes files that are not part of the given directory (recursive). * * @param string[] $files - * @param string $directory + * @param string $directory * * @return string[] */ @@ -205,17 +198,13 @@ private static function matchFiles(array $files, string $pattern) }); } - //-------------------------------------------------------------------- - - /** - * Removes a directory and all its files - * and subdirectories. + * Removes a directory and all its files and subdirectories. * * @param string $directory * * @return void */ - private static function wipeDirectory(string $directory) + private static function wipeDirectory(string $directory): void { if (is_dir($directory)) { @@ -267,8 +256,7 @@ private static function safeCopyFile(string $from, string $to, bool $replace): v } // Make sure the directory exists - $directory = pathinfo($to, PATHINFO_DIRNAME); - if (! is_dir($directory)) + if (! is_dir($directory = pathinfo($to, PATHINFO_DIRNAME))) { mkdir($directory, 0775, true); } diff --git a/tests/_support/Publishers/TestPublisher.php b/tests/_support/Publishers/TestPublisher.php index 8ef30ca90024..fdb3547478d1 100644 --- a/tests/_support/Publishers/TestPublisher.php +++ b/tests/_support/Publishers/TestPublisher.php @@ -9,7 +9,7 @@ class TestPublisher extends Publisher /** * Runs the defined Operations. */ - public function publish() + public function publish(): bool { $this->downloadFromUrls($urls)->mergeToDirectory(FCPATH . 'assets'); }