diff --git a/src/database/src/Commands/Seeders/GenSeederCommand.php b/src/database/src/Commands/Seeders/GenSeederCommand.php index 6438c1581..3cfcb0586 100644 --- a/src/database/src/Commands/Seeders/GenSeederCommand.php +++ b/src/database/src/Commands/Seeders/GenSeederCommand.php @@ -88,4 +88,4 @@ class GenSeederCommand extends BaseCommand ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided seeder file paths are pre-resolved absolute paths'], ]; } -} \ No newline at end of file +} diff --git a/src/database/src/Commands/Seeders/SeedCommand.php b/src/database/src/Commands/Seeders/SeedCommand.php index b8271af3a..2ddfec98e 100644 --- a/src/database/src/Commands/Seeders/SeedCommand.php +++ b/src/database/src/Commands/Seeders/SeedCommand.php @@ -85,4 +85,4 @@ class SeedCommand extends BaseCommand ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'], ]; } -} \ No newline at end of file +} diff --git a/src/database/src/Seeders/Seed.php b/src/database/src/Seeders/Seed.php index 5f758d136..cec0429d3 100644 --- a/src/database/src/Seeders/Seed.php +++ b/src/database/src/Seeders/Seed.php @@ -182,13 +182,13 @@ class Seed /** * Get all of the seeder files in a given path. * - * @param string|array $paths + * @param array|string $paths * @return array */ public function getSeederFiles($paths) { return Collection::make($paths)->flatMap(function ($path) { - return Str::endsWith($path, '.php') ? [$path] : $this->files->glob($path.'/*.php'); + return Str::endsWith($path, '.php') ? [$path] : $this->files->glob($path . '/*.php'); })->filter()->sortBy(function ($file) { return $this->getSeederName($file); })->values()->keyBy(function ($file) { @@ -253,8 +253,7 @@ class Seed /** * Write a note to the console's output. * - * @param string $message - * @return void + * @param string $message */ protected function note($message) { @@ -262,4 +261,4 @@ class Seed $this->output->writeln($message); } } -} \ No newline at end of file +} diff --git a/src/database/src/Seeders/Seeder.php b/src/database/src/Seeders/Seeder.php index 98c6a27b3..7b7764353 100644 --- a/src/database/src/Seeders/Seeder.php +++ b/src/database/src/Seeders/Seeder.php @@ -12,17 +12,8 @@ declare(strict_types=1); namespace Hyperf\Database\Seeders; -use InvalidArgumentException; - abstract class Seeder { - /** - * The name of the database connection to use. - * - * @var string|null - */ - protected $connection = 'default'; - /** * Enables, if supported, wrapping the seeder within a transaction. * @@ -30,13 +21,20 @@ abstract class Seeder */ public $withinTransaction = true; + /** + * The name of the database connection to use. + * + * @var null|string + */ + protected $connection = 'default'; + /** * Get the seeder connection name. * - * @return string|null + * @return null|string */ public function getConnection() { return $this->connection; } -} \ No newline at end of file +} diff --git a/src/database/src/Seeders/SeederCreator.php b/src/database/src/Seeders/SeederCreator.php index 42393e124..cfb3a3c95 100644 --- a/src/database/src/Seeders/SeederCreator.php +++ b/src/database/src/Seeders/SeederCreator.php @@ -56,6 +56,26 @@ class SeederCreator return $path; } + /** + * Get the path to the stubs. + * + * @return string + */ + public function stubPath() + { + return __DIR__ . '/stubs'; + } + + /** + * Get the filesystem instance. + * + * @return \Hyperf\Utils\Filesystem\Filesystem + */ + public function getFilesystem() + { + return $this->files; + } + /** * Get the seeder stub file. * @@ -63,7 +83,7 @@ class SeederCreator */ protected function getStub() { - return $this->files->get($this->stubPath().'/seeder.stub'); + return $this->files->get($this->stubPath() . '/seeder.stub'); } /** @@ -82,7 +102,6 @@ class SeederCreator * Ensure that a seeder with the given name doesn't already exist. * * @param string $name - * @return void * * @throws \InvalidArgumentException */ @@ -96,7 +115,7 @@ class SeederCreator /** * Get the class name of a seeder name. * - * @param string $name + * @param string $name * @return string */ protected function getClassName($name) @@ -113,26 +132,6 @@ class SeederCreator */ protected function getPath($name, $path) { - return $path.'/'.$name.'.php'; + return $path . '/' . $name . '.php'; } - - /** - * Get the path to the stubs. - * - * @return string - */ - public function stubPath() - { - return __DIR__.'/stubs'; - } - - /** - * Get the filesystem instance. - * - * @return \Hyperf\Utils\Filesystem\Filesystem - */ - public function getFilesystem() - { - return $this->files; - } -} \ No newline at end of file +}