diff --git a/composer.json b/composer.json index 2a7d9e52a..6f36c965e 100644 --- a/composer.json +++ b/composer.json @@ -1,78 +1,78 @@ { - "name": "nwidart/laravel-modules", - "description": "Laravel Module management", - "keywords": [ - "modules", - "laravel", - "nwidart", - "module", - "rad" - ], - "license": "MIT", - "authors": [ - { - "name": "Nicolas Widart", - "email": "n.widart@gmail.com", - "homepage": "https://nicolaswidart.com", - "role": "Developer" - } - ], - "require": { - "php": ">=8.2", - "ext-dom": "*", - "ext-json": "*", - "ext-simplexml": "*", - "wikimedia/composer-merge-plugin": "^2.1" - }, - "require-dev": { - "phpunit/phpunit": "^11.0", - "mockery/mockery": "^1.6", - "orchestra/testbench": "^v9.0", - "friendsofphp/php-cs-fixer": "^v3.52", - "laravel/framework": "^v11.33", - "laravel/pint": "^1.16", - "spatie/phpunit-snapshot-assertions": "^5.0", - "phpstan/phpstan": "^1.4" - }, - "autoload": { - "psr-4": { - "Nwidart\\Modules\\": "src" + "name": "nwidart/laravel-modules", + "description": "Laravel Module management", + "keywords": [ + "modules", + "laravel", + "nwidart", + "module", + "rad" + ], + "license": "MIT", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com", + "homepage": "https://nicolaswidart.com", + "role": "Developer" + } + ], + "require": { + "php": ">=8.2", + "ext-dom": "*", + "ext-json": "*", + "ext-simplexml": "*", + "wikimedia/composer-merge-plugin": "^2.1" }, - "files": [ - "src/helpers.php" - ] - }, - "autoload-dev": { - "psr-4": { - "Nwidart\\Modules\\Tests\\": "tests", - "Modules\\Recipe\\": "tests/stubs/valid/Recipe" - } - }, - "extra": { - "laravel": { - "providers": [ - "Nwidart\\Modules\\LaravelModulesServiceProvider" - ], - "aliases": { - "Module": "Nwidart\\Modules\\Facades\\Module" - } + "require-dev": { + "phpunit/phpunit": "^11.0", + "mockery/mockery": "^1.6", + "orchestra/testbench": "^v9.0", + "friendsofphp/php-cs-fixer": "^v3.52", + "laravel/framework": "^v11.33", + "laravel/pint": "^1.16", + "spatie/phpunit-snapshot-assertions": "^5.0", + "phpstan/phpstan": "^1.4" }, - "branch-alias": { - "dev-master": "11.0-dev" - } - }, - "config": { - "allow-plugins": { - "wikimedia/composer-merge-plugin": true - } - }, - "scripts": { - "update-snapshots": "./phpunit --no-coverage -d --update-snapshots", - "lint": "pint", - "test": "phpunit", - "test-coverage": "phpunit --coverage-html coverage", - "pcf": "vendor/bin/php-cs-fixer fix --verbose" - }, - "minimum-stability": "dev", - "prefer-stable": true + "autoload": { + "psr-4": { + "Nwidart\\Modules\\": "src" + }, + "files": [ + "src/helpers.php" + ] + }, + "autoload-dev": { + "psr-4": { + "Nwidart\\Modules\\Tests\\": "tests", + "Modules\\Recipe\\": "tests/stubs/valid/Recipe" + } + }, + "extra": { + "laravel": { + "providers": [ + "Nwidart\\Modules\\LaravelModulesServiceProvider" + ], + "aliases": { + "Module": "Nwidart\\Modules\\Facades\\Module" + } + }, + "branch-alias": { + "dev-master": "11.0-dev" + } + }, + "config": { + "allow-plugins": { + "wikimedia/composer-merge-plugin": true + } + }, + "scripts": { + "update-snapshots": "phpunit --no-coverage -d --update-snapshots", + "lint": "pint", + "test": "phpunit", + "test-coverage": "phpunit --coverage-html coverage", + "pcf": "vendor/bin/php-cs-fixer fix --verbose" + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/config/config.php b/config/config.php index e2d4d9dd1..2b6e64c90 100644 --- a/config/config.php +++ b/config/config.php @@ -44,7 +44,7 @@ 'vite' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME'], 'json' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'], 'views/index' => ['LOWER_NAME'], - 'views/master' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME',], + 'views/master' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME'], 'scaffold/config' => ['STUDLY_NAME'], 'composer' => [ 'LOWER_NAME', diff --git a/src/Activators/FileActivator.php b/src/Activators/FileActivator.php index c669d3a0f..849b3af9d 100644 --- a/src/Activators/FileActivator.php +++ b/src/Activators/FileActivator.php @@ -13,31 +13,23 @@ class FileActivator implements ActivatorInterface { /** * Laravel Filesystem instance - * - * @var Filesystem */ - private $files; + private Filesystem $files; /** * Laravel config instance - * - * @var Config */ - private $config; + private Config $config; /** * Array of modules activation statuses - * - * @var array */ - private $modulesStatuses; + private array $modulesStatuses; /** * File used to store activation statuses - * - * @var string */ - private $statusesFile; + private string $statusesFile; public function __construct(Container $app) { @@ -149,8 +141,6 @@ private function readJson(): array /** * Reads a config parameter under the 'activators.file' key - * - * @return mixed */ private function config(string $key, $default = null) { diff --git a/src/Collection.php b/src/Collection.php index 36351fcd2..137f7c5bd 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -9,20 +9,16 @@ class Collection extends BaseCollection { /** * Get items collections. - * - * @return array */ - public function getItems() + public function getItems(): array { return $this->items; } /** * Get the collection of items as a plain array. - * - * @return array */ - public function toArray() + public function toArray(): array { return array_map(function ($value) { if ($value instanceof Module) { diff --git a/src/Commands/Actions/CheckLangCommand.php b/src/Commands/Actions/CheckLangCommand.php index 73111f971..a23851d98 100644 --- a/src/Commands/Actions/CheckLangCommand.php +++ b/src/Commands/Actions/CheckLangCommand.php @@ -98,7 +98,7 @@ private function getDirectories($module) private function checkMissingFiles(Collection $directories) { - //show missing files + // show missing files $missingFilesMessage = []; $uniqeLangFiles = $directories->pluck('files')->flatten()->unique()->values(); @@ -135,7 +135,7 @@ private function checkMissingFiles(Collection $directories) private function checkMissingKeys(Collection $directories) { - //show missing keys + // show missing keys $uniqeLangFiles = $directories->pluck('files')->flatten()->unique(); $langDirectories = $directories->pluck('name'); diff --git a/src/Commands/Database/SeedCommand.php b/src/Commands/Database/SeedCommand.php index a3ae3fe1f..a66978a0f 100644 --- a/src/Commands/Database/SeedCommand.php +++ b/src/Commands/Database/SeedCommand.php @@ -102,14 +102,14 @@ public function moduleSeed(Module $module) } } } else { - $class = $this->getSeederName($name); //legacy support + $class = $this->getSeederName($name); // legacy support $class = implode('\\', array_map('ucwords', explode('\\', $class))); if (class_exists($class)) { $seeders[] = $class; } else { - //look at other namespaces + // look at other namespaces $classes = $this->getSeederNames($name); foreach ($classes as $class) { if (class_exists($class)) { diff --git a/src/Commands/UpdatePhpunitCoverage.php b/src/Commands/UpdatePhpunitCoverage.php index 858e71240..8a17d8864 100644 --- a/src/Commands/UpdatePhpunitCoverage.php +++ b/src/Commands/UpdatePhpunitCoverage.php @@ -23,30 +23,31 @@ class UpdatePhpunitCoverage extends Command /** * Execute the console command. - * - * @return int */ public function handle(): int { $appFolder = config('modules.paths.app_folder', 'app/'); - $appFolder = rtrim($appFolder, '/') . '/'; + $appFolder = rtrim($appFolder, '/').'/'; $phpunitXmlPath = base_path('phpunit.xml'); $modulesStatusPath = base_path('modules_statuses.json'); - if (!file_exists($phpunitXmlPath)) { + if (! file_exists($phpunitXmlPath)) { $this->error("phpunit.xml file not found: {$phpunitXmlPath}"); + return 100; } - if (!file_exists($modulesStatusPath)) { + if (! file_exists($modulesStatusPath)) { $this->error("Modules statuses file not found: {$modulesStatusPath}"); + return 99; } $enabledModules = json_decode(file_get_contents($modulesStatusPath), true); if (json_last_error() !== JSON_ERROR_NONE) { - $this->error("Error decoding JSON from {$modulesStatusPath}: " . json_last_error_msg()); + $this->error("Error decoding JSON from {$modulesStatusPath}: ".json_last_error_msg()); + return 98; } @@ -55,15 +56,13 @@ public function handle(): int foreach ($enabledModules as $module => $status) { if ($status) { // Only add enabled modules - $moduleDir = $modulesPath . $module . '/' . $appFolder; + $moduleDir = $modulesPath.$module.'/'.$appFolder; if (is_dir($moduleDir)) { $moduleDirs[] = $moduleDir; } } } - - $phpunitXml = simplexml_load_file($phpunitXmlPath); $sourceInclude = $phpunitXml->xpath('//source/include')[0]; @@ -77,13 +76,13 @@ public function handle(): int $directory->addAttribute('suffix', '.php'); } - $dom = new DOMDocument(); + $dom = new DOMDocument; $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($phpunitXml->asXML()); $dom->save($phpunitXmlPath); - $this->info("phpunit.xml updated with enabled module directories."); + $this->info('phpunit.xml updated with enabled module directories.'); return 0; } diff --git a/src/Contracts/ConfirmableCommand.php b/src/Contracts/ConfirmableCommand.php index 772b56114..fd33f181b 100644 --- a/src/Contracts/ConfirmableCommand.php +++ b/src/Contracts/ConfirmableCommand.php @@ -2,6 +2,4 @@ namespace Nwidart\Modules\Contracts; -interface ConfirmableCommand -{ -} +interface ConfirmableCommand {} diff --git a/src/Contracts/PublisherInterface.php b/src/Contracts/PublisherInterface.php index b0e219618..85fba657d 100644 --- a/src/Contracts/PublisherInterface.php +++ b/src/Contracts/PublisherInterface.php @@ -6,8 +6,6 @@ interface PublisherInterface { /** * Publish something. - * - * @return mixed */ public function publish(); } diff --git a/src/Contracts/RepositoryInterface.php b/src/Contracts/RepositoryInterface.php index 37acd59bc..3794bc856 100644 --- a/src/Contracts/RepositoryInterface.php +++ b/src/Contracts/RepositoryInterface.php @@ -2,6 +2,8 @@ namespace Nwidart\Modules\Contracts; +use Illuminate\Filesystem\Filesystem; +use Nwidart\Modules\Collection; use Nwidart\Modules\Exceptions\ModuleNotFoundException; use Nwidart\Modules\Module; @@ -9,96 +11,68 @@ interface RepositoryInterface { /** * Get all modules. - * - * @return mixed */ public function all(); /** * Scan & get all available modules. - * - * @return array */ - public function scan(); + public function scan(): array; /** * Get modules as modules collection instance. - * - * @return \Nwidart\Modules\Collection */ - public function toCollection(); + public function toCollection(): Collection; /** * Get scanned paths. - * - * @return array */ - public function getScanPaths(); + public function getScanPaths(): array; /** * Get list of enabled modules. - * - * @return mixed */ public function allEnabled(); /** * Get list of disabled modules. - * - * @return mixed */ public function allDisabled(); /** * Get count from all modules. - * - * @return int */ - public function count(); + public function count(): int; /** * Get all ordered modules. - * - * @param string $direction - * @return mixed */ - public function getOrdered($direction = 'asc'); + public function getOrdered(string $direction = 'asc'); /** * Get modules by the given status. - * - * @param int $status - * @return mixed */ - public function getByStatus($status); + public function getByStatus(int|bool $status); /** * Find a specific module. - * - * @return Module|null */ - public function find(string $name); + public function find(string $name): ?Module; /** * Find a specific module. If there return that, otherwise throw exception. - * - * - * @return mixed */ public function findOrFail(string $name); - public function getModulePath($moduleName); + public function getModulePath(string $moduleName); /** - * @return \Illuminate\Filesystem\Filesystem + * Get Files */ - public function getFiles(); + public function getFiles(): Filesystem; /** * Get a specific config data from a configuration file. - * - * @param string|null $default - * @return mixed */ public function config(string $key, $default = null); diff --git a/src/Contracts/RunableInterface.php b/src/Contracts/RunableInterface.php index 7cd50b66a..8db269bf6 100644 --- a/src/Contracts/RunableInterface.php +++ b/src/Contracts/RunableInterface.php @@ -6,8 +6,6 @@ interface RunableInterface { /** * Run the specified command. - * - * @param string $command */ - public function run($command); + public function run(string $command); } diff --git a/src/Exceptions/FileAlreadyExistException.php b/src/Exceptions/FileAlreadyExistException.php index 3512c348b..087392cd3 100644 --- a/src/Exceptions/FileAlreadyExistException.php +++ b/src/Exceptions/FileAlreadyExistException.php @@ -2,6 +2,4 @@ namespace Nwidart\Modules\Exceptions; -class FileAlreadyExistException extends \Exception -{ -} +class FileAlreadyExistException extends \Exception {} diff --git a/src/Exceptions/InvalidJsonException.php b/src/Exceptions/InvalidJsonException.php index e03496fd8..7a35421fe 100644 --- a/src/Exceptions/InvalidJsonException.php +++ b/src/Exceptions/InvalidJsonException.php @@ -2,6 +2,4 @@ namespace Nwidart\Modules\Exceptions; -class InvalidJsonException extends \Exception -{ -} +class InvalidJsonException extends \Exception {} diff --git a/src/Exceptions/ModuleNotFoundException.php b/src/Exceptions/ModuleNotFoundException.php index 6de5e6fbc..26c128ab3 100644 --- a/src/Exceptions/ModuleNotFoundException.php +++ b/src/Exceptions/ModuleNotFoundException.php @@ -2,6 +2,4 @@ namespace Nwidart\Modules\Exceptions; -class ModuleNotFoundException extends \Exception -{ -} +class ModuleNotFoundException extends \Exception {} diff --git a/src/Facades/Module.php b/src/Facades/Module.php index a8534d06d..09f7952f9 100644 --- a/src/Facades/Module.php +++ b/src/Facades/Module.php @@ -37,9 +37,6 @@ class Module extends Facade * Indicate if destructive Artisan commands should be prohibited. * * Prohibits: module:migrate-fresh, module:migrate-refresh, and module:migrate-reset - * - * @param bool $prohibit - * @return void */ public static function prohibitDestructiveCommands(bool $prohibit = true): void { diff --git a/src/FileRepository.php b/src/FileRepository.php index 1adf5e704..7e7d14708 100644 --- a/src/FileRepository.php +++ b/src/FileRepository.php @@ -16,6 +16,7 @@ use Nwidart\Modules\Exceptions\ModuleNotFoundException; use Nwidart\Modules\Process\Installer; use Nwidart\Modules\Process\Updater; +use Symfony\Component\Process\Process; abstract class FileRepository implements Countable, RepositoryInterface { @@ -30,51 +31,45 @@ abstract class FileRepository implements Countable, RepositoryInterface /** * The module path. - * - * @var string|null */ - protected $path; + protected ?string $path; /** * The scanned paths. - * - * @var array */ - protected $paths = []; + protected array $paths = []; /** - * @var string + * Stub path */ - protected $stubPath; + protected ?string $stubPath = null; /** - * @var UrlGenerator + * URL Generator */ - private $url; + private UrlGenerator $url; /** - * @var ConfigRepository + * Config Repository */ - private $config; + private ConfigRepository $config; /** - * @var Filesystem + * File system */ - private $files; + private Filesystem $files; /** - * @var CacheManager + * Cache Manager */ - private $cache; + private CacheManager $cache; private static $modules = []; /** * The constructor. - * - * @param string|null $path */ - public function __construct(Container $app, $path = null) + public function __construct(Container $app, ?string $path = null) { $this->app = $app; $this->path = $path; @@ -86,11 +81,8 @@ public function __construct(Container $app, $path = null) /** * Add other module location. - * - * @param string $path - * @return $this */ - public function addLocation($path) + public function addLocation(string $path): self { $this->paths[] = $path; @@ -127,20 +119,13 @@ public function getScanPaths(): array /** * Creates a new Module instance - * - * @param Container $app - * @param string $args - * @param string $path - * @return \Nwidart\Modules\Module */ - abstract protected function createModule(...$args); + abstract protected function createModule(Container $app, string $name, string $path): Module; /** * Get & scan all modules. - * - * @return array */ - public function scan() + public function scan(): array { if (! empty(self::$modules) && ! $this->app->runningUnitTests()) { return self::$modules; @@ -151,9 +136,7 @@ public function scan() $modules = []; foreach ($paths as $key => $path) { - $manifests = $this->getFiles()->glob("{$path}/module.json"); - - is_array($manifests) || $manifests = []; + $manifests = (array) $this->getFiles()->glob("{$path}/module.json"); foreach ($manifests as $manifest) { $json = Json::make($manifest); @@ -235,10 +218,8 @@ public function count(): int /** * Get all ordered modules. - * - * @param string $direction */ - public function getOrdered($direction = 'asc'): array + public function getOrdered(string $direction = 'asc'): array { $modules = $this->allEnabled(); @@ -288,7 +269,7 @@ public function boot(): void /** * {@inheritDoc} */ - public function find(string $name) + public function find(string $name): ?Module { return $this->all()[strtolower($name)] ?? null; } @@ -296,12 +277,9 @@ public function find(string $name) /** * Find a specific module, if there return that, otherwise throw exception. * - * - * @return Module - * * @throws ModuleNotFoundException */ - public function findOrFail(string $name) + public function findOrFail(string $name): Module { $module = $this->find($name); @@ -322,11 +300,8 @@ public function collections($status = 1): Collection /** * Get module path for a specific module. - * - * - * @return string */ - public function getModulePath($module) + public function getModulePath($module): string { try { return $this->findOrFail($module)->getPath().'/'; @@ -372,7 +347,6 @@ public function getUsedStoragePath(): string /** * Set module used for cli session. * - * * @throws ModuleNotFoundException */ public function setUsed($name) @@ -423,11 +397,9 @@ public function getAssetsPath(): string /** * Get asset url from a specific module. * - * @param string $asset - * * @throws InvalidAssetPath */ - public function asset($asset): string + public function asset(string $asset): string { if (Str::contains($asset, ':') === false) { throw InvalidAssetPath::missingModuleName($asset); @@ -460,12 +432,9 @@ public function isDisabled(string $name): bool /** * Enabling a specific module. * - * @param string $name - * @return void - * * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function enable($name) + public function enable(string $name) { $this->findOrFail($name)->enable(); } @@ -473,12 +442,9 @@ public function enable($name) /** * Disabling a specific module. * - * @param string $name - * @return void - * * @throws \Nwidart\Modules\Exceptions\ModuleNotFoundException */ - public function disable($name) + public function disable(string $name) { $this->findOrFail($name)->disable(); } @@ -493,24 +459,16 @@ public function delete(string $name): bool /** * Update dependencies for the specified module. - * - * @param string $module */ - public function update($module) + public function update(string $module) { with(new Updater($this))->update($module); } /** * Install the specified module. - * - * @param string $name - * @param string $version - * @param string $type - * @param bool $subtree - * @return \Symfony\Component\Process\Process */ - public function install($name, $version = 'dev-master', $type = 'composer', $subtree = false) + public function install(string $name, string $version = 'dev-master', string $type = 'composer', bool $subtree = false): Process { $installer = new Installer($name, $version, $type, $subtree); @@ -519,10 +477,8 @@ public function install($name, $version = 'dev-master', $type = 'composer', $sub /** * Get stub path. - * - * @return string|null */ - public function getStubPath() + public function getStubPath(): ?string { if ($this->stubPath !== null) { return $this->stubPath; @@ -537,11 +493,8 @@ public function getStubPath() /** * Set stub path. - * - * @param string $stubPath - * @return $this */ - public function setStubPath($stubPath) + public function setStubPath(string $stubPath): self { $this->stubPath = $stubPath; diff --git a/src/Generators/FileGenerator.php b/src/Generators/FileGenerator.php index 4c935617a..d277931c1 100644 --- a/src/Generators/FileGenerator.php +++ b/src/Generators/FileGenerator.php @@ -9,46 +9,36 @@ class FileGenerator extends Generator { /** * The path wil be used. - * - * @var string */ - protected $path; + protected string $path; /** * The contens will be used. - * - * @var string */ - protected $contents; + protected string $contents; /** * The laravel filesystem or null. - * - * @var \Illuminate\Filesystem\Filesystem|null */ - protected $filesystem; + protected ?Filesystem $filesystem; /** - * @var bool + * Overwrite File */ - private $overwriteFile; + private bool $overwriteFile; /** * The constructor. - * - * @param null $filesystem */ - public function __construct($path, $contents, $filesystem = null) + public function __construct(string $path, string $contents, $filesystem = null) { $this->path = $path; $this->contents = $contents; - $this->filesystem = $filesystem ?: new Filesystem(); + $this->filesystem = $filesystem ?: new Filesystem; } /** * Get contents. - * - * @return mixed */ public function getContents() { @@ -57,11 +47,8 @@ public function getContents() /** * Set contents. - * - * @param mixed $contents - * @return $this */ - public function setContents($contents) + public function setContents(string $contents): self { $this->contents = $contents; @@ -70,8 +57,6 @@ public function setContents($contents) /** * Get filesystem. - * - * @return mixed */ public function getFilesystem() { @@ -80,11 +65,8 @@ public function getFilesystem() /** * Set filesystem. - * - * - * @return $this */ - public function setFilesystem(Filesystem $filesystem) + public function setFilesystem(Filesystem $filesystem): self { $this->filesystem = $filesystem; @@ -93,8 +75,6 @@ public function setFilesystem(Filesystem $filesystem) /** * Get path. - * - * @return mixed */ public function getPath() { @@ -103,11 +83,8 @@ public function getPath() /** * Set path. - * - * @param mixed $path - * @return $this */ - public function setPath($path) + public function setPath(string $path): self { $this->path = $path; diff --git a/src/Generators/Generator.php b/src/Generators/Generator.php index d2f889a32..7798f160e 100644 --- a/src/Generators/Generator.php +++ b/src/Generators/Generator.php @@ -2,6 +2,4 @@ namespace Nwidart\Modules\Generators; -abstract class Generator -{ -} +abstract class Generator {} diff --git a/src/Generators/ModuleGenerator.php b/src/Generators/ModuleGenerator.php index cfe59adb2..14076ec66 100644 --- a/src/Generators/ModuleGenerator.php +++ b/src/Generators/ModuleGenerator.php @@ -53,7 +53,6 @@ class ModuleGenerator extends Generator /** * The module instance. */ - /*?Module*/ protected mixed $module = null; /** diff --git a/src/Json.php b/src/Json.php index 357eff2e7..02e85f393 100644 --- a/src/Json.php +++ b/src/Json.php @@ -3,60 +3,48 @@ namespace Nwidart\Modules; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Collection; use Nwidart\Modules\Exceptions\InvalidJsonException; class Json { /** * The file path. - * - * @var string */ - protected $path; + protected string $path; /** * The laravel filesystem instance. - * - * @var \Illuminate\Filesystem\Filesystem */ - protected $filesystem; + protected Filesystem $filesystem; /** * The attributes collection. - * - * @var \Illuminate\Support\Collection */ - protected $attributes; + protected ?Collection $attributes = null; /** * The constructor. - * - * @param mixed $path */ public function __construct($path, ?Filesystem $filesystem = null) { $this->path = (string) $path; - $this->filesystem = $filesystem ?: new Filesystem(); + $this->filesystem = $filesystem ?: new Filesystem; $this->attributes = Collection::make($this->getAttributes()); } /** * Get filesystem. - * - * @return Filesystem */ - public function getFilesystem() + public function getFilesystem(): Filesystem { return $this->filesystem; } /** * Set filesystem. - * - * - * @return $this */ - public function setFilesystem(Filesystem $filesystem) + public function setFilesystem(Filesystem $filesystem): self { $this->filesystem = $filesystem; @@ -65,21 +53,16 @@ public function setFilesystem(Filesystem $filesystem) /** * Get path. - * - * @return string */ - public function getPath() + public function getPath(): string { return $this->path; } /** * Set path. - * - * @param mixed $path - * @return $this */ - public function setPath($path) + public function setPath($path): self { $this->path = (string) $path; @@ -88,21 +71,16 @@ public function setPath($path) /** * Make new instance. - * - * @param string $path - * @return static */ - public static function make($path, ?Filesystem $filesystem = null) + public static function make(string $path, ?Filesystem $filesystem = null): static { return new static($path, $filesystem); } /** * Get file content. - * - * @return string */ - public function getContents() + public function getContents(): string { return $this->filesystem->get($this->getPath()); } @@ -110,11 +88,9 @@ public function getContents() /** * Decode contents as array. * - * @return array - * * @throws InvalidJsonException */ - public function decodeContents() + public function decodeContents(): array { $attributes = $this->filesystem->json($this->getPath()); @@ -130,33 +106,25 @@ public function decodeContents() * Get file contents as array, either from the cache or from * the json content file if the cache is disabled. * - * @return array - * * @throws \Exception */ - public function getAttributes() + public function getAttributes(): array { - return $this->attributes ?? $this->decodeContents(); + return $this->attributes ? $this->attributes->toArray() : $this->decodeContents(); } /** * Convert the given array data to pretty json. - * - * - * @return string */ - public function toJsonPretty(?array $data = null) + public function toJsonPretty(?array $data = null): string { return json_encode($data ?: $this->attributes, JSON_PRETTY_PRINT); } /** * Update json contents from array data. - * - * - * @return bool */ - public function update(array $data) + public function update(array $data): bool { $this->attributes = new Collection(array_merge($this->attributes->toArray(), $data)); @@ -165,12 +133,8 @@ public function update(array $data) /** * Set a specific key & value. - * - * @param string $key - * @param mixed $value - * @return $this */ - public function set($key, $value) + public function set(string $key, $value): self { $this->attributes->offsetSet($key, $value); @@ -179,44 +143,32 @@ public function set($key, $value) /** * Save the current attributes array to the file storage. - * - * @return bool */ - public function save() + public function save(): bool { return $this->filesystem->put($this->getPath(), $this->toJsonPretty()); } /** * Handle magic method __get. - * - * @param string $key - * @return mixed */ - public function __get($key) + public function __get(string $key) { return $this->get($key); } /** * Get the specified attribute from json file. - * - * @param null $default - * @return mixed */ - public function get($key, $default = null) + public function get(string $key, $default = null) { return $this->attributes->get($key, $default); } /** * Handle call to __call method. - * - * @param string $method - * @param array $arguments - * @return mixed */ - public function __call($method, $arguments = []) + public function __call(string $method, array $arguments = []) { if (method_exists($this, $method)) { return call_user_func_array([$this, $method], $arguments); @@ -227,10 +179,8 @@ public function __call($method, $arguments = []) /** * Handle call to __toString method. - * - * @return string */ - public function __toString() + public function __toString(): string { return $this->getContents(); } diff --git a/src/Laravel/LaravelFileRepository.php b/src/Laravel/LaravelFileRepository.php index 600f298fd..abb4d7869 100644 --- a/src/Laravel/LaravelFileRepository.php +++ b/src/Laravel/LaravelFileRepository.php @@ -2,6 +2,7 @@ namespace Nwidart\Modules\Laravel; +use Illuminate\Container\Container; use Nwidart\Modules\FileRepository; class LaravelFileRepository extends FileRepository @@ -9,8 +10,8 @@ class LaravelFileRepository extends FileRepository /** * {@inheritdoc} */ - protected function createModule(...$args) + protected function createModule(Container $app, string $name, string $path): Module { - return new Module(...$args); + return new Module($app, $name, $path); } } diff --git a/src/Laravel/Module.php b/src/Laravel/Module.php index 019c81be3..994bdecf4 100644 --- a/src/Laravel/Module.php +++ b/src/Laravel/Module.php @@ -29,7 +29,7 @@ public function getCachedServicesPath(): string */ public function registerProviders(): void { - (new ProviderRepository($this->app, new Filesystem(), $this->getCachedServicesPath())) + (new ProviderRepository($this->app, new Filesystem, $this->getCachedServicesPath())) ->load($this->get('providers', [])); } diff --git a/src/LaravelModulesServiceProvider.php b/src/LaravelModulesServiceProvider.php index f325e075d..8dcae7b22 100644 --- a/src/LaravelModulesServiceProvider.php +++ b/src/LaravelModulesServiceProvider.php @@ -29,7 +29,7 @@ public function boot() $this->app->singleton( ModuleManifest::class, fn () => new ModuleManifest( - new Filesystem(), + new Filesystem, app(Contracts\RepositoryInterface::class)->getScanPaths(), $this->getCachedModulePath(), app(ActivatorInterface::class) @@ -134,7 +134,6 @@ protected function registerTranslations(): void }); } - private function registerEvents(): void { Event::listen( diff --git a/src/Lumen/LumenFileRepository.php b/src/Lumen/LumenFileRepository.php index de2b783f0..08d9efea6 100644 --- a/src/Lumen/LumenFileRepository.php +++ b/src/Lumen/LumenFileRepository.php @@ -2,15 +2,17 @@ namespace Nwidart\Modules\Lumen; +use Illuminate\Container\Container; use Nwidart\Modules\FileRepository; +use Nwidart\Modules\Module; class LumenFileRepository extends FileRepository { /** * {@inheritdoc} */ - protected function createModule(...$args) + protected function createModule(Container $app, string $name, ?string $path = null): Module { - return new Module(...$args); + return new Module($app, $name, $path); } } diff --git a/src/Lumen/Module.php b/src/Lumen/Module.php index 0e477aeb6..855f85c0c 100644 --- a/src/Lumen/Module.php +++ b/src/Lumen/Module.php @@ -28,7 +28,5 @@ public function registerProviders(): void /** * {@inheritdoc} */ - public function registerAliases(): void - { - } + public function registerAliases(): void {} } diff --git a/src/Migrations/Migrator.php b/src/Migrations/Migrator.php index 5467b1128..5a8eb9d15 100644 --- a/src/Migrations/Migrator.php +++ b/src/Migrations/Migrator.php @@ -219,7 +219,7 @@ public function resolve($file) return include $this->getPath().'/'.$file.'.php'; } - return new $class(); + return new $class; } /** diff --git a/src/Module.php b/src/Module.php index 47e2ed9dc..ad88afdef 100644 --- a/src/Module.php +++ b/src/Module.php @@ -26,44 +26,42 @@ abstract class Module /** * The module name. */ - protected $name; + protected string $name; /** * The module path. - * - * @var string */ - protected $path; + protected string $path; /** - * @var array of cached Json objects, keyed by filename + * Array of cached Json objects, keyed by filename */ - protected $moduleJson = []; + protected array $moduleJson = []; /** - * @var CacheManager + * Cache Manager */ - private $cache; + private CacheManager $cache; /** - * @var Filesystem + * Filesystem */ - private $files; + private Filesystem $files; /** - * @var Translator + * Translator */ - private $translator; + private Translator $translator; /** - * @var ActivatorInterface + * ActivatorInterface */ - private $activator; + private ActivatorInterface $activator; /** * The constructor. */ - public function __construct(Container $app, string $name, $path) + public function __construct(Container $app, string $name, string $path) { $this->name = $name; $this->path = $path; @@ -177,11 +175,8 @@ public function getAppPath(): string /** * Set path. - * - * @param string $path - * @return $this */ - public function setPath($path): Module + public function setPath(string $path): self { $this->path = $path; @@ -220,10 +215,8 @@ protected function registerTranslation(): void /** * Get json contents from the cache, setting as needed. - * - * @param string $file */ - public function json($file = null): Json + public function json(?string $file = null): Json { if ($file === null) { $file = 'module.json'; @@ -236,9 +229,6 @@ public function json($file = null): Json /** * Get a specific data from json file by given the key. - * - * @param null $default - * @return mixed */ public function get(string $key, $default = null) { @@ -247,11 +237,8 @@ public function get(string $key, $default = null) /** * Get a specific data from composer.json file by given the key. - * - * @param null $default - * @return mixed */ - public function getComposerAttr($key, $default = null) + public function getComposerAttr(string $key, $default = null) { return $this->json('composer.json')->get($key, $default); } @@ -307,10 +294,8 @@ protected function registerFiles(): void /** * Handle call __toString. - * - * @return string */ - public function __toString() + public function __toString(): string { return $this->getStudlyName(); } @@ -392,7 +377,7 @@ public function delete(): bool */ public function getExtraPath(?string $path): string { - return $this->getPath() . ($path ? '/' . $path : ''); + return $this->getPath().($path ? '/'.$path : ''); } /** diff --git a/src/ModuleManifest.php b/src/ModuleManifest.php index b5eb6914f..40f974149 100644 --- a/src/ModuleManifest.php +++ b/src/ModuleManifest.php @@ -11,24 +11,18 @@ class ModuleManifest { /** * The filesystem instance. - * - * @var \Illuminate\Filesystem\Filesystem */ - private $files; + private Filesystem $files; /** * The base path. - * - * @var string */ - public $paths; + public Collection $paths; /** * The manifest path. - * - * @var string|null */ - public $manifestPath; + public ?string $manifestPath; /** * The manifestData @@ -37,10 +31,8 @@ class ModuleManifest /** * The loaded manifest array. - * - * @var array */ - private $manifest; + private array $manifest = []; /** * module activator class @@ -49,12 +41,8 @@ class ModuleManifest /** * Create a new package manifest instance. - * - * @param Collection $paths - * @param string $manifestPath - * @return void */ - public function __construct(Filesystem $files, $paths, $manifestPath, ActivatorInterface $activator) + public function __construct(Filesystem $files, array $paths, string $manifestPath, ActivatorInterface $activator) { $this->files = $files; $this->paths = collect($paths); @@ -64,53 +52,42 @@ public function __construct(Filesystem $files, $paths, $manifestPath, ActivatorI /** * Get all of the service provider class names for all packages. - * - * @return array */ - public function providers() + public function providers(): array { return $this->config('providers'); } /** * Get all of the service provider class names for all packages. - * - * @return array */ - public function providersArray() + public function providersArray(): array { return $this->getManifest()['providers'] ?? []; } /** * Get all of the aliases for all packages. - * - * @return array */ - public function aliases() + public function aliases(): array { return $this->config('aliases'); } /** * Get all of the values for all packages for the given configuration name. - * - * @param string $key - * @return array */ - public function config($key) + public function config(string $key): array { return collect($this->getManifest())->flatMap(function ($configuration) use ($key) { - return (array)($configuration[$key] ?? []); + return (array) ($configuration[$key] ?? []); })->filter()->all(); } /** * Get the current package manifest. - * - * @return array */ - protected function getManifest() + protected function getManifest(): array { if (! is_null($this->manifest)) { return $this->manifest; @@ -126,8 +103,6 @@ protected function getManifest() /** * Build the manifest and write it to disk. - * - * @return void */ public function build(): void { @@ -149,8 +124,6 @@ public function build(): void /** * Write the given manifest array to disk. * - * @return void - * * @throws \Exception */ protected function write(array $manifest): void @@ -166,7 +139,7 @@ protected function write(array $manifest): void public function registerFiles(): void { - //todo check this section store on module.php or not? + // todo check this section store on module.php or not? $this->getModulesData() ->each(function (array $manifest) { if (empty($manifest['files'])) { diff --git a/src/ModulesServiceProvider.php b/src/ModulesServiceProvider.php index a93690d60..bad5deac6 100644 --- a/src/ModulesServiceProvider.php +++ b/src/ModulesServiceProvider.php @@ -65,10 +65,8 @@ abstract protected function registerServices(); /** * Get the services provided by the provider. - * - * @return array */ - public function provides() + public function provides(): array { return [Contracts\RepositoryInterface::class, 'modules']; } diff --git a/src/Process/Installer.php b/src/Process/Installer.php index be992bdb9..7be2970cc 100644 --- a/src/Process/Installer.php +++ b/src/Process/Installer.php @@ -11,65 +11,48 @@ class Installer { /** * The module name. - * - * @var string */ - protected $name; + protected string $name; /** * The version of module being installed. - * - * @var string */ - protected $version; + protected string $version; /** * The module repository instance. - * - * @var \Nwidart\Modules\Contracts\RepositoryInterface */ - protected $repository; + protected RepositoryInterface $repository; /** * The console command instance. - * - * @var \Illuminate\Console\Command */ - protected $console; + protected Command $console; /** * The destionation path. - * - * @var string */ - protected $path; + protected string $path; /** * The process timeout. - * - * @var int */ - protected $timeout = 3360; + protected int $timeout = 3360; /** - * @var null|string + * Type */ - private $type; + private ?string $type; /** - * @var bool + * Tree */ - private $tree; + private bool $tree; /** * The constructor. - * - * @param string $name - * @param string $version - * @param string $type - * @param bool $tree */ - public function __construct($name, $version = null, $type = null, $tree = false) + public function __construct(string $name, ?string $version = null, ?string $type = null, bool $tree = false) { $this->name = $name; $this->version = $version; @@ -79,11 +62,8 @@ public function __construct($name, $version = null, $type = null, $tree = false) /** * Set destination path. - * - * @param string $path - * @return $this */ - public function setPath($path) + public function setPath(string $path): self { $this->path = $path; @@ -92,10 +72,8 @@ public function setPath($path) /** * Set the module repository instance. - * - * @return $this */ - public function setRepository(RepositoryInterface $repository) + public function setRepository(RepositoryInterface $repository): self { $this->repository = $repository; @@ -104,11 +82,8 @@ public function setRepository(RepositoryInterface $repository) /** * Set console command instance. - * - * - * @return $this */ - public function setConsole(Command $console) + public function setConsole(Command $console): self { $this->console = $console; @@ -117,11 +92,8 @@ public function setConsole(Command $console) /** * Set process timeout. - * - * @param int $timeout - * @return $this */ - public function setTimeout($timeout) + public function setTimeout(int $timeout): self { $this->timeout = $timeout; @@ -130,10 +102,8 @@ public function setTimeout($timeout) /** * Run the installation process. - * - * @return \Symfony\Component\Process\Process */ - public function run() + public function run(): Process { $process = $this->getProcess(); @@ -150,10 +120,8 @@ public function run() /** * Get process instance. - * - * @return \Symfony\Component\Process\Process */ - public function getProcess() + public function getProcess(): Process { if ($this->type) { if ($this->tree) { @@ -168,10 +136,8 @@ public function getProcess() /** * Get destination path. - * - * @return string */ - public function getDestinationPath() + public function getDestinationPath(): string { if ($this->path) { return $this->path; @@ -182,10 +148,8 @@ public function getDestinationPath() /** * Get git repo url. - * - * @return string|null */ - public function getRepoUrl() + public function getRepoUrl(): ?string { switch ($this->type) { case 'github': @@ -203,7 +167,6 @@ public function getRepoUrl() return "git@bitbucket.org:{$this->name}.git"; default: - // Check of type 'scheme://host/path' if (filter_var($this->type, FILTER_VALIDATE_URL)) { return $this->type; @@ -213,29 +176,21 @@ public function getRepoUrl() if (filter_var($this->type, FILTER_VALIDATE_EMAIL)) { return "{$this->type}:{$this->name}.git"; } - - return; - - break; } } /** * Get branch name. - * - * @return string */ - public function getBranch() + public function getBranch(): string { return is_null($this->version) ? 'master' : $this->version; } /** * Get module name. - * - * @return string */ - public function getModuleName() + public function getModuleName(): string { $parts = explode('/', $this->name); @@ -244,10 +199,8 @@ public function getModuleName() /** * Get composer package name. - * - * @return string */ - public function getPackageName() + public function getPackageName(): string { if (is_null($this->version)) { return $this->name.':dev-master'; @@ -258,10 +211,8 @@ public function getPackageName() /** * Install the module via git. - * - * @return \Symfony\Component\Process\Process */ - public function installViaGit() + public function installViaGit(): Process { return Process::fromShellCommandline(sprintf( 'cd %s && git clone %s %s && cd %s && git checkout %s', @@ -275,10 +226,8 @@ public function installViaGit() /** * Install the module via git subtree. - * - * @return \Symfony\Component\Process\Process */ - public function installViaSubtree() + public function installViaSubtree(): Process { return Process::fromShellCommandline(sprintf( 'cd %s && git remote add %s %s && git subtree add --prefix=%s --squash %s %s', @@ -293,10 +242,8 @@ public function installViaSubtree() /** * Install the module via composer. - * - * @return \Symfony\Component\Process\Process */ - public function installViaComposer() + public function installViaComposer(): Process { return Process::fromShellCommandline(sprintf( 'cd %s && composer require %s', diff --git a/src/Process/Runner.php b/src/Process/Runner.php index 489ce677a..76186a9c1 100644 --- a/src/Process/Runner.php +++ b/src/Process/Runner.php @@ -9,10 +9,8 @@ class Runner implements RunableInterface { /** * The module instance. - * - * @var RepositoryInterface */ - protected $module; + protected RepositoryInterface $module; public function __construct(RepositoryInterface $module) { @@ -21,10 +19,8 @@ public function __construct(RepositoryInterface $module) /** * Run the given command. - * - * @param string $command */ - public function run($command) + public function run(string $command) { passthru($command); } diff --git a/src/Process/Updater.php b/src/Process/Updater.php index e80b79f08..1921f46ff 100644 --- a/src/Process/Updater.php +++ b/src/Process/Updater.php @@ -8,10 +8,8 @@ class Updater extends Runner { /** * Update the dependencies for the specified module by given the module name. - * - * @param string $module */ - public function update($module) + public function update(string $module) { $module = $this->module->findOrFail($module); @@ -24,10 +22,8 @@ public function update($module) /** * Check if composer should output anything. - * - * @return string */ - private function isComposerSilenced() + private function isComposerSilenced(): string { return config('modules.composer.composer-output') === false ? ' --quiet' : ''; } diff --git a/src/Providers/BootstrapServiceProvider.php b/src/Providers/BootstrapServiceProvider.php index 849ffdabf..870dca403 100644 --- a/src/Providers/BootstrapServiceProvider.php +++ b/src/Providers/BootstrapServiceProvider.php @@ -25,9 +25,9 @@ public function register(): void } /** - * @return LaravelFileRepository + * Get Repository Interface */ - public function getRepositoryInterface() + public function getRepositoryInterface(): LaravelFileRepository { return $this->app[RepositoryInterface::class]; } diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php index 1417e532d..b3f9c1f0f 100644 --- a/src/Providers/ConsoleServiceProvider.php +++ b/src/Providers/ConsoleServiceProvider.php @@ -85,7 +85,7 @@ public static function defaultCommands(): Collection Commands\Make\TestMakeCommand::class, Commands\Make\ViewMakeCommand::class, - //Publish Commands + // Publish Commands Commands\Publish\PublishCommand::class, Commands\Publish\PublishConfigurationCommand::class, Commands\Publish\PublishMigrationCommand::class, diff --git a/src/Publishing/AssetPublisher.php b/src/Publishing/AssetPublisher.php index ec7004dd3..99fbe1390 100644 --- a/src/Publishing/AssetPublisher.php +++ b/src/Publishing/AssetPublisher.php @@ -8,27 +8,21 @@ class AssetPublisher extends Publisher { /** * Determine whether the result message will shown in the console. - * - * @var bool */ - protected $showMessage = false; + protected bool $showMessage = false; /** * Get destination path. - * - * @return string */ - public function getDestinationPath() + public function getDestinationPath(): string { return $this->repository->assetPath($this->module->getLowerName()); } /** * Get source path. - * - * @return string */ - public function getSourcePath() + public function getSourcePath(): string { return $this->getModule()->getExtraPath( GenerateConfigReader::read('assets')->getPath() diff --git a/src/Publishing/LangPublisher.php b/src/Publishing/LangPublisher.php index 7aff580f5..89ca5774a 100644 --- a/src/Publishing/LangPublisher.php +++ b/src/Publishing/LangPublisher.php @@ -8,17 +8,13 @@ class LangPublisher extends Publisher { /** * Determine whether the result message will shown in the console. - * - * @var bool */ - protected $showMessage = false; + protected bool $showMessage = false; /** * Get destination path. - * - * @return string */ - public function getDestinationPath() + public function getDestinationPath(): string { $name = $this->module->getLowerName(); @@ -27,10 +23,8 @@ public function getDestinationPath() /** * Get source path. - * - * @return string */ - public function getSourcePath() + public function getSourcePath(): string { return $this->getModule()->getExtraPath( GenerateConfigReader::read('lang')->getPath() diff --git a/src/Publishing/MigrationPublisher.php b/src/Publishing/MigrationPublisher.php index 7d03e3b2c..7a74a7630 100644 --- a/src/Publishing/MigrationPublisher.php +++ b/src/Publishing/MigrationPublisher.php @@ -7,9 +7,9 @@ class MigrationPublisher extends AssetPublisher { /** - * @var Migrator + * Migrator */ - private $migrator; + private Migrator $migrator; /** * MigrationPublisher constructor. @@ -22,20 +22,16 @@ public function __construct(Migrator $migrator) /** * Get destination path. - * - * @return string */ - public function getDestinationPath() + public function getDestinationPath(): string { return $this->repository->config('paths.migration'); } /** * Get source path. - * - * @return string */ - public function getSourcePath() + public function getSourcePath(): string { return $this->migrator->getPath(); } diff --git a/src/Publishing/Publisher.php b/src/Publishing/Publisher.php index e8416faee..2ef3e51a1 100644 --- a/src/Publishing/Publisher.php +++ b/src/Publishing/Publisher.php @@ -3,6 +3,7 @@ namespace Nwidart\Modules\Publishing; use Illuminate\Console\Command; +use Illuminate\Filesystem\Filesystem; use Nwidart\Modules\Contracts\PublisherInterface; use Nwidart\Modules\Contracts\RepositoryInterface; use Nwidart\Modules\Module; @@ -11,45 +12,33 @@ abstract class Publisher implements PublisherInterface { /** * The name of module will used. - * - * @var string */ - protected $module; + protected Module $module; /** * The modules repository instance. - * - * @var RepositoryInterface */ - protected $repository; + protected RepositoryInterface $repository; /** * The laravel console instance. - * - * @var \Illuminate\Console\Command */ - protected $console; + protected Command $console; /** * The success message will displayed at console. - * - * @var string */ - protected $success; + protected string $success; /** * The error message will displayed at console. - * - * @var string */ - protected $error = ''; + protected string $error = ''; /** * Determine whether the result message will shown in the console. - * - * @var bool */ - protected $showMessage = true; + protected bool $showMessage = true; /** * The constructor. @@ -61,10 +50,8 @@ public function __construct(Module $module) /** * Show the result message. - * - * @return self */ - public function showMessage() + public function showMessage(): self { $this->showMessage = true; @@ -73,10 +60,8 @@ public function showMessage() /** * Hide the result message. - * - * @return self */ - public function hideMessage() + public function hideMessage(): self { $this->showMessage = false; @@ -85,20 +70,16 @@ public function hideMessage() /** * Get module instance. - * - * @return \Nwidart\Modules\Module */ - public function getModule() + public function getModule(): Module { return $this->module; } /** * Set modules repository instance. - * - * @return $this */ - public function setRepository(RepositoryInterface $repository) + public function setRepository(RepositoryInterface $repository): self { $this->repository = $repository; @@ -107,21 +88,16 @@ public function setRepository(RepositoryInterface $repository) /** * Get modules repository instance. - * - * @return RepositoryInterface */ - public function getRepository() + public function getRepository(): RepositoryInterface { return $this->repository; } /** * Set console instance. - * - * - * @return $this */ - public function setConsole(Command $console) + public function setConsole(Command $console): self { $this->console = $console; @@ -130,37 +106,29 @@ public function setConsole(Command $console) /** * Get console instance. - * - * @return \Illuminate\Console\Command */ - public function getConsole() + public function getConsole(): Command { return $this->console; } /** * Get laravel filesystem instance. - * - * @return \Illuminate\Filesystem\Filesystem */ - public function getFilesystem() + public function getFilesystem(): Filesystem { return $this->repository->getFiles(); } /** * Get destination path. - * - * @return string */ - abstract public function getDestinationPath(); + abstract public function getDestinationPath(): string; /** * Get source path. - * - * @return string */ - abstract public function getSourcePath(); + abstract public function getSourcePath(): string; /** * Publish something. diff --git a/src/Support/Migrations/NameParser.php b/src/Support/Migrations/NameParser.php index 3e4d7003f..582ad7175 100644 --- a/src/Support/Migrations/NameParser.php +++ b/src/Support/Migrations/NameParser.php @@ -6,24 +6,18 @@ class NameParser { /** * The migration name. - * - * @var string */ - protected $name; + protected string $name; /** * The array data. - * - * @var array */ - protected $data = []; + protected array $data = []; /** * The available schema actions. - * - * @var array */ - protected $actions = [ + protected array $actions = [ 'create' => [ 'create', 'make', @@ -46,10 +40,8 @@ class NameParser /** * The constructor. - * - * @param string $name */ - public function __construct($name) + public function __construct(string $name) { $this->name = $name; $this->data = $this->fetchData(); @@ -57,30 +49,24 @@ public function __construct($name) /** * Get original migration name. - * - * @return string */ - public function getOriginalName() + public function getOriginalName(): string { return $this->name; } /** * Get schema type or action. - * - * @return string */ - public function getAction() + public function getAction(): string { return head($this->data); } /** * Get the table will be used. - * - * @return string */ - public function getTableName() + public function getTableName(): string { $matches = array_reverse($this->getMatches()); @@ -89,10 +75,8 @@ public function getTableName() /** * Get matches data from regex. - * - * @return array */ - public function getMatches() + public function getMatches(): array { preg_match($this->getPattern(), $this->name, $matches); @@ -101,10 +85,8 @@ public function getMatches() /** * Get name pattern. - * - * @return string */ - public function getPattern() + public function getPattern(): string { switch ($action = $this->getAction()) { case 'add': @@ -131,71 +113,56 @@ public function getPattern() /** * Fetch the migration name to an array data. - * - * @return array */ - protected function fetchData() + protected function fetchData(): array { return explode('_', $this->name); } /** * Get the array data. - * - * @return array */ - public function getData() + public function getData(): array { return $this->data; } /** * Determine whether the given type is same with the current schema action or type. - * - * - * @return bool */ - public function is($type) + public function is($type): bool { return $type === $this->getAction(); } /** * Determine whether the current schema action is a adding action. - * - * @return bool */ - public function isAdd() + public function isAdd(): bool { return in_array($this->getAction(), $this->actions['add']); } /** * Determine whether the current schema action is a deleting action. - * - * @return bool */ - public function isDelete() + public function isDelete(): bool { return in_array($this->getAction(), $this->actions['delete']); } /** * Determine whether the current schema action is a creating action. - * - * @return bool */ - public function isCreate() + public function isCreate(): bool { return in_array($this->getAction(), $this->actions['create']); } /** * Determine whether the current schema action is a dropping action. - * - * @return bool */ - public function isDrop() + public function isDrop(): bool { return in_array($this->getAction(), $this->actions['drop']); } diff --git a/src/Support/Migrations/SchemaParser.php b/src/Support/Migrations/SchemaParser.php index 924ecdfbb..285e38ec9 100644 --- a/src/Support/Migrations/SchemaParser.php +++ b/src/Support/Migrations/SchemaParser.php @@ -10,47 +10,36 @@ class SchemaParser implements Arrayable { /** * The array of custom attributes. - * - * @var array */ - protected $customAttributes = [ + protected array $customAttributes = [ 'remember_token' => 'rememberToken()', 'soft_delete' => 'softDeletes()', ]; /** * The migration schema. - * - * @var string */ - protected $schema; + protected ?string $schema; /** * The relationship keys. - * - * @var array */ - protected $relationshipKeys = [ + protected array $relationshipKeys = [ 'belongsTo', ]; /** * Create new instance. - * - * @param string|null $schema */ - public function __construct($schema = null) + public function __construct(?string $schema = null) { $this->schema = $schema; } /** * Parse a string to array of formatted schema. - * - * @param string $schema - * @return array */ - public function parse($schema) + public function parse(?string $schema): array { $this->schema = $schema; @@ -69,10 +58,8 @@ public function parse($schema) /** * Get array of schema. - * - * @return array */ - public function getSchemas() + public function getSchemas(): array { if (is_null($this->schema)) { return []; @@ -83,20 +70,16 @@ public function getSchemas() /** * Convert string migration to array. - * - * @return array */ - public function toArray() + public function toArray(): array { return $this->parse($this->schema); } /** * Render the migration to formatted script. - * - * @return string */ - public function render() + public function render(): string { $results = ''; @@ -109,20 +92,16 @@ public function render() /** * Render up migration fields. - * - * @return string */ - public function up() + public function up(): string { return $this->render(); } /** * Render down migration fields. - * - * @return string */ - public function down() + public function down(): string { $results = ''; @@ -136,13 +115,8 @@ public function down() /** * Create field. - * - * @param string $column - * @param array $attributes - * @param string $type - * @return string */ - public function createField($column, $attributes, $type = 'add') + public function createField(string $column, array $attributes, string $type = 'add'): string { $results = "\t\t\t".'$table'; @@ -159,13 +133,8 @@ public function createField($column, $attributes, $type = 'add') /** * Add relation column. - * - * @param int $key - * @param string $field - * @param string $column - * @return string */ - protected function addRelationColumn($key, $field, $column) + protected function addRelationColumn(int $key, string $field, ?string $column = null): string { if ($key === 0) { $relatedColumn = Str::snake(class_basename($field)).'_id'; @@ -187,13 +156,8 @@ protected function addRelationColumn($key, $field, $column) /** * Format field to script. - * - * @param int $key - * @param string $field - * @param string $column - * @return string */ - protected function addColumn($key, $field, $column) + protected function addColumn(int $key, string $field, string $column): string { if ($this->hasCustomAttribute($column)) { return '->'.$field; @@ -212,13 +176,8 @@ protected function addColumn($key, $field, $column) /** * Format field to script. - * - * @param int $key - * @param string $field - * @param string $column - * @return string */ - protected function removeColumn($key, $field, $column) + protected function removeColumn(int $key, string $field, string $column): string { if ($this->hasCustomAttribute($column)) { return '->'.$field; @@ -229,23 +188,16 @@ protected function removeColumn($key, $field, $column) /** * Get column name from schema. - * - * @param string $schema - * @return string */ - public function getColumn($schema) + public function getColumn(string $schema): string { return Arr::get(explode(':', $schema), 0); } /** * Get column attributes. - * - * @param string $column - * @param string $schema - * @return array */ - public function getAttributes($column, $schema) + public function getAttributes(string $column, string $schema): array { $fields = str_replace($column.':', '', $schema); @@ -254,22 +206,16 @@ public function getAttributes($column, $schema) /** * Determine whether the given column is exist in customAttributes array. - * - * @param string $column - * @return bool */ - public function hasCustomAttribute($column) + public function hasCustomAttribute(string $column): bool { return array_key_exists($column, $this->customAttributes); } /** * Get custom attributes value. - * - * @param string $column - * @return array */ - public function getCustomAttribute($column) + public function getCustomAttribute(string $column): array { return (array) $this->customAttributes[$column]; } diff --git a/src/Support/Stub.php b/src/Support/Stub.php index ca6dfc18a..6c1f443de 100644 --- a/src/Support/Stub.php +++ b/src/Support/Stub.php @@ -6,31 +6,23 @@ class Stub { /** * The stub path. - * - * @var string */ - protected $path; + protected string $path; /** * The base path of stub file. - * - * @var null|string */ - protected static $basePath = null; + protected static ?string $basePath = null; /** * The replacements array. - * - * @var array */ - protected $replaces = []; + protected array $replaces = []; /** * The contructor. - * - * @param string $path */ - public function __construct($path, array $replaces = []) + public function __construct(string $path, array $replaces = []) { $this->path = $path; $this->replaces = $replaces; @@ -38,22 +30,16 @@ public function __construct($path, array $replaces = []) /** * Create new self instance. - * - * @param string $path - * @return self */ - public static function create($path, array $replaces = []) + public static function create(string $path, array $replaces = []): self { return new static($path, $replaces); } /** * Set stub path. - * - * @param string $path - * @return self */ - public function setPath($path) + public function setPath(string $path): self { $this->path = $path; @@ -62,10 +48,8 @@ public function setPath($path) /** * Get stub path. - * - * @return string */ - public function getPath() + public function getPath(): string { $path = static::getBasePath().$this->path; @@ -74,30 +58,24 @@ public function getPath() /** * Set base path. - * - * @param string $path */ - public static function setBasePath($path) + public static function setBasePath(string $path) { static::$basePath = $path; } /** * Get base path. - * - * @return string|null */ - public static function getBasePath() + public static function getBasePath(): ?string { return static::$basePath; } /** * Get stub contents. - * - * @return mixed|string */ - public function getContents() + public function getContents(): string { $contents = file_get_contents($this->getPath()); @@ -110,33 +88,24 @@ public function getContents() /** * Get stub contents. - * - * @return string */ - public function render() + public function render(): string { return $this->getContents(); } /** * Save stub to specific path. - * - * @param string $path - * @param string $filename - * @return bool */ - public function saveTo($path, $filename) + public function saveTo(string $path, string $filename): bool { return file_put_contents($path.'/'.$filename, $this->getContents()); } /** * Set replacements array. - * - * - * @return $this */ - public function replace(array $replaces = []) + public function replace(array $replaces = []): self { $this->replaces = $replaces; @@ -145,20 +114,16 @@ public function replace(array $replaces = []) /** * Get replacements. - * - * @return array */ - public function getReplaces() + public function getReplaces(): array { return $this->replaces; } /** * Handle magic method __toString. - * - * @return string */ - public function __toString() + public function __toString(): string { return $this->render(); } diff --git a/src/Traits/MigrationLoaderTrait.php b/src/Traits/MigrationLoaderTrait.php index ae274ca34..c817c84db 100644 --- a/src/Traits/MigrationLoaderTrait.php +++ b/src/Traits/MigrationLoaderTrait.php @@ -6,10 +6,8 @@ trait MigrationLoaderTrait { /** * Include all migrations files from the specified module. - * - * @param string $module */ - protected function loadMigrationFiles($module) + protected function loadMigrationFiles(string $module) { $path = $this->laravel['modules']->getModulePath($module).$this->getMigrationGeneratorPath(); @@ -22,10 +20,8 @@ protected function loadMigrationFiles($module) /** * Get migration generator path. - * - * @return string */ - protected function getMigrationGeneratorPath() + protected function getMigrationGeneratorPath(): string { return $this->laravel['modules']->config('paths.generator.migration'); } diff --git a/src/helpers.php b/src/helpers.php index 8798fa6ea..af1506295 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -15,11 +15,8 @@ function module_path($name, $path = '') if (! function_exists('config_path')) { /** * Get the configuration path. - * - * @param string $path - * @return string */ - function config_path($path = '') + function config_path(string $path = ''): string { return app()->basePath().'/config'.($path ? DIRECTORY_SEPARATOR.$path : $path); } @@ -28,11 +25,8 @@ function config_path($path = '') if (! function_exists('public_path')) { /** * Get the path to the public folder. - * - * @param string $path - * @return string */ - function public_path($path = '') + function public_path(string $path = ''): string { return app()->make('path.public').($path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path); } diff --git a/tests/Activators/FileActivatorTest.php b/tests/Activators/FileActivatorTest.php index 1ac75197d..a896f9d72 100644 --- a/tests/Activators/FileActivatorTest.php +++ b/tests/Activators/FileActivatorTest.php @@ -25,7 +25,7 @@ class FileActivatorTest extends BaseTestCase */ private $activator; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->module = new TestModule($this->app, 'Recipe', __DIR__.'/stubs/valid/Recipe'); @@ -33,7 +33,7 @@ public function setUp(): void $this->activator = new FileActivator($this->app); } - public function tearDown(): void + protected function tearDown(): void { $this->activator->reset(); parent::tearDown(); diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 7d69a8c51..6e8843905 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -8,7 +8,7 @@ abstract class BaseTestCase extends OrchestraTestCase { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index 5b6f755b4..5cd83ada6 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -7,7 +7,7 @@ class CollectionTest extends BaseTestCase { - public function test_toArraySetsPathAttribute() + public function test_to_array_sets_path_attribute() { $moduleOnePath = __DIR__.'/stubs/valid/Recipe'; $moduleTwoPath = __DIR__.'/stubs/valid/Requirement'; @@ -24,7 +24,7 @@ public function test_toArraySetsPathAttribute() $this->assertEquals($moduleTwoPath, $collectionArray[1]['path']); } - public function test_getItemsReturnsTheCollectionItems() + public function test_get_items_returns_the_collection_items() { $modules = [ new Module($this->app, 'module-one', __DIR__.'/stubs/valid/Recipe'), diff --git a/tests/Commands/Actions/ClearCompiledCommandTest.php b/tests/Commands/Actions/ClearCompiledCommandTest.php index 1f141cd2a..113c9d2c4 100644 --- a/tests/Commands/Actions/ClearCompiledCommandTest.php +++ b/tests/Commands/Actions/ClearCompiledCommandTest.php @@ -15,7 +15,7 @@ class ClearCompiledCommandTest extends BaseTestCase private Filesystem $finder; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -23,7 +23,7 @@ public function setUp(): void $this->repository = $this->app[RepositoryInterface::class]; } - public function tearDown(): void + protected function tearDown(): void { $this->artisan('module:delete', ['--all' => true, '--force' => true]); parent::tearDown(); diff --git a/tests/Commands/Actions/DisableCommandTest.php b/tests/Commands/Actions/DisableCommandTest.php index de196696b..4b9258300 100644 --- a/tests/Commands/Actions/DisableCommandTest.php +++ b/tests/Commands/Actions/DisableCommandTest.php @@ -10,7 +10,7 @@ class DisableCommandTest extends BaseTestCase { private RepositoryInterface $repository; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->createModule('Blog'); @@ -18,7 +18,7 @@ public function setUp(): void $this->repository = $this->app[RepositoryInterface::class]; } - public function tearDown(): void + protected function tearDown(): void { $this->repository->delete('Blog'); $this->repository->delete('Taxonomy'); diff --git a/tests/Commands/Actions/EnableCommandTest.php b/tests/Commands/Actions/EnableCommandTest.php index 836bbcc27..9ad257899 100644 --- a/tests/Commands/Actions/EnableCommandTest.php +++ b/tests/Commands/Actions/EnableCommandTest.php @@ -10,7 +10,7 @@ class EnableCommandTest extends BaseTestCase { private RepositoryInterface $repository; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->createModule('Blog'); @@ -18,7 +18,7 @@ public function setUp(): void $this->repository = $this->app[RepositoryInterface::class]; } - public function tearDown(): void + protected function tearDown(): void { $this->repository->delete('Blog'); $this->repository->delete('Taxonomy'); diff --git a/tests/Commands/Actions/ListCommandTest.php b/tests/Commands/Actions/ListCommandTest.php index 66a61c1bd..250be7635 100644 --- a/tests/Commands/Actions/ListCommandTest.php +++ b/tests/Commands/Actions/ListCommandTest.php @@ -12,14 +12,14 @@ class ListCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->createModule(); $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Actions/ModuleDeleteCommandTest.php b/tests/Commands/Actions/ModuleDeleteCommandTest.php index 59bca661b..2f42a7e7f 100644 --- a/tests/Commands/Actions/ModuleDeleteCommandTest.php +++ b/tests/Commands/Actions/ModuleDeleteCommandTest.php @@ -23,14 +23,14 @@ class ModuleDeleteCommandTest extends BaseTestCase */ private $activator; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; $this->activator = new FileActivator($this->app); } - public function tearDown(): void + protected function tearDown(): void { $this->artisan('module:delete', ['--all' => true, '--force' => true]); diff --git a/tests/Commands/Actions/ModuleDiscoverCommandTest.php b/tests/Commands/Actions/ModuleDiscoverCommandTest.php index f0f0a4a7e..e4aa82759 100644 --- a/tests/Commands/Actions/ModuleDiscoverCommandTest.php +++ b/tests/Commands/Actions/ModuleDiscoverCommandTest.php @@ -15,7 +15,7 @@ class ModuleDiscoverCommandTest extends BaseTestCase private Filesystem $finder; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -23,7 +23,7 @@ public function setUp(): void $this->repository = $this->app[RepositoryInterface::class]; } - public function tearDown(): void + protected function tearDown(): void { $this->artisan('module:delete', ['--all' => true, '--force' => true]); parent::tearDown(); @@ -79,6 +79,4 @@ public function test_manifest_file_contain_multi_module_provider() $this->assertContains($provider, $manifest['eager'], 'provider not found in manifest file'); } } - - } diff --git a/tests/Commands/Make/ActionMakeCommandTest.php b/tests/Commands/Make/ActionMakeCommandTest.php index 0631781a7..953ad0507 100644 --- a/tests/Commands/Make/ActionMakeCommandTest.php +++ b/tests/Commands/Make/ActionMakeCommandTest.php @@ -20,7 +20,7 @@ class ActionMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/CastMakeCommandTest.php b/tests/Commands/Make/CastMakeCommandTest.php index 4c41ee2ee..cef20ce58 100644 --- a/tests/Commands/Make/CastMakeCommandTest.php +++ b/tests/Commands/Make/CastMakeCommandTest.php @@ -20,7 +20,7 @@ class CastMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ChannelMakeCommandTest.php b/tests/Commands/Make/ChannelMakeCommandTest.php index c622f764d..7c1fd3b95 100644 --- a/tests/Commands/Make/ChannelMakeCommandTest.php +++ b/tests/Commands/Make/ChannelMakeCommandTest.php @@ -20,7 +20,7 @@ class ChannelMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ClassMakeCommandTest.php b/tests/Commands/Make/ClassMakeCommandTest.php index 63ef4eb7e..2adce7ded 100644 --- a/tests/Commands/Make/ClassMakeCommandTest.php +++ b/tests/Commands/Make/ClassMakeCommandTest.php @@ -20,7 +20,7 @@ class ClassMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/CommandMakeCommandTest.php b/tests/Commands/Make/CommandMakeCommandTest.php index b2e6612c2..dd2f2a082 100644 --- a/tests/Commands/Make/CommandMakeCommandTest.php +++ b/tests/Commands/Make/CommandMakeCommandTest.php @@ -20,7 +20,7 @@ class CommandMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ComponentClassMakeCommandTest.php b/tests/Commands/Make/ComponentClassMakeCommandTest.php index 868ea6da6..ae32e6773 100644 --- a/tests/Commands/Make/ComponentClassMakeCommandTest.php +++ b/tests/Commands/Make/ComponentClassMakeCommandTest.php @@ -20,7 +20,7 @@ class ComponentClassMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ComponentViewMakeCommandTest.php b/tests/Commands/Make/ComponentViewMakeCommandTest.php index b7aaddde6..3be5bd352 100644 --- a/tests/Commands/Make/ComponentViewMakeCommandTest.php +++ b/tests/Commands/Make/ComponentViewMakeCommandTest.php @@ -20,7 +20,7 @@ class ComponentViewMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ControllerMakeCommandTest.php b/tests/Commands/Make/ControllerMakeCommandTest.php index 860ac6536..a6e876f88 100644 --- a/tests/Commands/Make/ControllerMakeCommandTest.php +++ b/tests/Commands/Make/ControllerMakeCommandTest.php @@ -20,7 +20,7 @@ class ControllerMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/EnumMakeCommandTest.php b/tests/Commands/Make/EnumMakeCommandTest.php index 1cb65afcf..5198cbb11 100644 --- a/tests/Commands/Make/EnumMakeCommandTest.php +++ b/tests/Commands/Make/EnumMakeCommandTest.php @@ -20,7 +20,7 @@ class EnumMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/EventMakeCommandTest.php b/tests/Commands/Make/EventMakeCommandTest.php index bbd2f63d2..99d6c7efd 100644 --- a/tests/Commands/Make/EventMakeCommandTest.php +++ b/tests/Commands/Make/EventMakeCommandTest.php @@ -20,7 +20,7 @@ class EventMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/EventProviderMakeCommandTest.php b/tests/Commands/Make/EventProviderMakeCommandTest.php index 6b7e87527..e028eda0e 100644 --- a/tests/Commands/Make/EventProviderMakeCommandTest.php +++ b/tests/Commands/Make/EventProviderMakeCommandTest.php @@ -20,7 +20,7 @@ class EventProviderMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ExceptionMakeCommandTest.php b/tests/Commands/Make/ExceptionMakeCommandTest.php index 0b8694e09..ecb203eb0 100644 --- a/tests/Commands/Make/ExceptionMakeCommandTest.php +++ b/tests/Commands/Make/ExceptionMakeCommandTest.php @@ -20,7 +20,7 @@ class ExceptionMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/FactoryMakeCommandTest.php b/tests/Commands/Make/FactoryMakeCommandTest.php index 6cafbf5a1..8f5c04b2f 100644 --- a/tests/Commands/Make/FactoryMakeCommandTest.php +++ b/tests/Commands/Make/FactoryMakeCommandTest.php @@ -20,7 +20,7 @@ class FactoryMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/HelperMakeCommandTest.php b/tests/Commands/Make/HelperMakeCommandTest.php index aaa28f66c..38e3964fa 100644 --- a/tests/Commands/Make/HelperMakeCommandTest.php +++ b/tests/Commands/Make/HelperMakeCommandTest.php @@ -20,7 +20,7 @@ class HelperMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/InterfaceMakeCommandTest.php b/tests/Commands/Make/InterfaceMakeCommandTest.php index c913baa56..a269ebfb9 100644 --- a/tests/Commands/Make/InterfaceMakeCommandTest.php +++ b/tests/Commands/Make/InterfaceMakeCommandTest.php @@ -20,7 +20,7 @@ class InterfaceMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/JobMakeCommandTest.php b/tests/Commands/Make/JobMakeCommandTest.php index 3ce343299..0c3495f1e 100644 --- a/tests/Commands/Make/JobMakeCommandTest.php +++ b/tests/Commands/Make/JobMakeCommandTest.php @@ -20,7 +20,7 @@ class JobMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ListenerMakeCommandTest.php b/tests/Commands/Make/ListenerMakeCommandTest.php index 13e706d7a..4282d50c6 100644 --- a/tests/Commands/Make/ListenerMakeCommandTest.php +++ b/tests/Commands/Make/ListenerMakeCommandTest.php @@ -20,7 +20,7 @@ class ListenerMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/MailMakeCommandTest.php b/tests/Commands/Make/MailMakeCommandTest.php index a90f5e67f..dee2d69e0 100644 --- a/tests/Commands/Make/MailMakeCommandTest.php +++ b/tests/Commands/Make/MailMakeCommandTest.php @@ -20,7 +20,7 @@ class MailMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/MiddlewareMakeCommandTest.php b/tests/Commands/Make/MiddlewareMakeCommandTest.php index 452901f6f..bf9e744e5 100644 --- a/tests/Commands/Make/MiddlewareMakeCommandTest.php +++ b/tests/Commands/Make/MiddlewareMakeCommandTest.php @@ -20,7 +20,7 @@ class MiddlewareMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/MigrationMakeCommandTest.php b/tests/Commands/Make/MigrationMakeCommandTest.php index 5158b5474..b643915dd 100644 --- a/tests/Commands/Make/MigrationMakeCommandTest.php +++ b/tests/Commands/Make/MigrationMakeCommandTest.php @@ -20,7 +20,7 @@ class MigrationMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleBasePath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ModelMakeCommandTest.php b/tests/Commands/Make/ModelMakeCommandTest.php index 65eb8fde4..71d991895 100644 --- a/tests/Commands/Make/ModelMakeCommandTest.php +++ b/tests/Commands/Make/ModelMakeCommandTest.php @@ -21,7 +21,7 @@ class ModelMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ModuleMakeCommandTest.php b/tests/Commands/Make/ModuleMakeCommandTest.php index 7cf5098b0..bb569e5ad 100644 --- a/tests/Commands/Make/ModuleMakeCommandTest.php +++ b/tests/Commands/Make/ModuleMakeCommandTest.php @@ -35,7 +35,7 @@ class ModuleMakeCommandTest extends BaseTestCase */ private $repository; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->modulePath = $this->getModuleBasePath(); @@ -44,7 +44,7 @@ public function setUp(): void $this->activator = $this->app[ActivatorInterface::class]; } - public function tearDown(): void + protected function tearDown(): void { $this->artisan('module:delete', ['--all' => true, '--force' => true]); @@ -131,7 +131,6 @@ public function test_it_generates_api_route_file_with_multi_segment_default_name $this->assertSame(0, $code); } - public function test_it_generates_vite_file() { $code = $this->artisan('module:make', ['name' => ['Blog']]); @@ -509,7 +508,7 @@ public function test_it_can_set_author_details() 'name' => ['Blog'], '--author-name' => 'Joe Blogs', '--author-email' => 'user@domain.com', - '--author-vendor' => 'JoeBlogs' + '--author-vendor' => 'JoeBlogs', ] ); diff --git a/tests/Commands/Make/NotificationMakeCommandTest.php b/tests/Commands/Make/NotificationMakeCommandTest.php index 432f4c177..6c870ebb0 100644 --- a/tests/Commands/Make/NotificationMakeCommandTest.php +++ b/tests/Commands/Make/NotificationMakeCommandTest.php @@ -20,7 +20,7 @@ class NotificationMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ObserverMakeCommandTest.php b/tests/Commands/Make/ObserverMakeCommandTest.php index b043d8f41..93e4e1ad0 100644 --- a/tests/Commands/Make/ObserverMakeCommandTest.php +++ b/tests/Commands/Make/ObserverMakeCommandTest.php @@ -20,7 +20,7 @@ class ObserverMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/PolicyMakeCommandTest.php b/tests/Commands/Make/PolicyMakeCommandTest.php index fec1f1a1c..a68e8b48e 100644 --- a/tests/Commands/Make/PolicyMakeCommandTest.php +++ b/tests/Commands/Make/PolicyMakeCommandTest.php @@ -20,7 +20,7 @@ class PolicyMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ProviderMakeCommandTest.php b/tests/Commands/Make/ProviderMakeCommandTest.php index 32909db35..905e21fb9 100644 --- a/tests/Commands/Make/ProviderMakeCommandTest.php +++ b/tests/Commands/Make/ProviderMakeCommandTest.php @@ -20,7 +20,7 @@ class ProviderMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->artisan('module:make', ['name' => ['Blog'], '--plain' => true]); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/RepositoryMakeCommandTest.php b/tests/Commands/Make/RepositoryMakeCommandTest.php index a6ea60a00..bd78769e1 100644 --- a/tests/Commands/Make/RepositoryMakeCommandTest.php +++ b/tests/Commands/Make/RepositoryMakeCommandTest.php @@ -20,7 +20,7 @@ class RepositoryMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/RequestMakeCommandTest.php b/tests/Commands/Make/RequestMakeCommandTest.php index ada86afa7..2ecc4510f 100644 --- a/tests/Commands/Make/RequestMakeCommandTest.php +++ b/tests/Commands/Make/RequestMakeCommandTest.php @@ -20,7 +20,7 @@ class RequestMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ResourceMakeCommandTest.php b/tests/Commands/Make/ResourceMakeCommandTest.php index a8b040806..2cd73ed3f 100644 --- a/tests/Commands/Make/ResourceMakeCommandTest.php +++ b/tests/Commands/Make/ResourceMakeCommandTest.php @@ -20,7 +20,7 @@ class ResourceMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/RouteProviderMakeCommandTest.php b/tests/Commands/Make/RouteProviderMakeCommandTest.php index 110492fe6..868d2bf34 100644 --- a/tests/Commands/Make/RouteProviderMakeCommandTest.php +++ b/tests/Commands/Make/RouteProviderMakeCommandTest.php @@ -20,7 +20,7 @@ class RouteProviderMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/RuleMakeCommandTest.php b/tests/Commands/Make/RuleMakeCommandTest.php index 288b411c3..60de67225 100644 --- a/tests/Commands/Make/RuleMakeCommandTest.php +++ b/tests/Commands/Make/RuleMakeCommandTest.php @@ -20,7 +20,7 @@ class RuleMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -28,7 +28,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ScopeMakeCommandTest.php b/tests/Commands/Make/ScopeMakeCommandTest.php index 8033a5bc6..5a18f0a30 100644 --- a/tests/Commands/Make/ScopeMakeCommandTest.php +++ b/tests/Commands/Make/ScopeMakeCommandTest.php @@ -20,7 +20,7 @@ class ScopeMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ServiceMakeCommandTest.php b/tests/Commands/Make/ServiceMakeCommandTest.php index cd9179e52..18fdd7454 100644 --- a/tests/Commands/Make/ServiceMakeCommandTest.php +++ b/tests/Commands/Make/ServiceMakeCommandTest.php @@ -20,7 +20,7 @@ class ServiceMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/TestMakeCommandTest.php b/tests/Commands/Make/TestMakeCommandTest.php index b0d7432b9..e17aba453 100644 --- a/tests/Commands/Make/TestMakeCommandTest.php +++ b/tests/Commands/Make/TestMakeCommandTest.php @@ -26,7 +26,7 @@ class TestMakeCommandTest extends BaseTestCase */ private $activator; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -35,7 +35,7 @@ public function setUp(): void $this->activator = $this->app[ActivatorInterface::class]; } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); $this->activator->reset(); diff --git a/tests/Commands/Make/TraitMakeCommandTest.php b/tests/Commands/Make/TraitMakeCommandTest.php index d8c6adf23..c0f141083 100644 --- a/tests/Commands/Make/TraitMakeCommandTest.php +++ b/tests/Commands/Make/TraitMakeCommandTest.php @@ -20,7 +20,7 @@ class TraitMakeCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -29,7 +29,7 @@ public function setUp(): void } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Make/ViewMakeCommandTest.php b/tests/Commands/Make/ViewMakeCommandTest.php index 8651e5680..4a254bcf6 100644 --- a/tests/Commands/Make/ViewMakeCommandTest.php +++ b/tests/Commands/Make/ViewMakeCommandTest.php @@ -18,7 +18,7 @@ class ViewMakeCommandTest extends BaseTestCase private string $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -26,7 +26,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Publish/PublishCommandTest.php b/tests/Commands/Publish/PublishCommandTest.php index 7aa02e1e2..6e6eb2d14 100644 --- a/tests/Commands/Publish/PublishCommandTest.php +++ b/tests/Commands/Publish/PublishCommandTest.php @@ -17,7 +17,7 @@ class PublishCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->createModule(); @@ -26,7 +26,7 @@ public function setUp(): void $this->finder->put($this->modulePath.'/resources/assets/script.js', 'assetfile'); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/Publish/PublishMigrationCommandTest.php b/tests/Commands/Publish/PublishMigrationCommandTest.php index 9eb005726..66a912c39 100644 --- a/tests/Commands/Publish/PublishMigrationCommandTest.php +++ b/tests/Commands/Publish/PublishMigrationCommandTest.php @@ -17,7 +17,7 @@ class PublishMigrationCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -26,7 +26,7 @@ public function setUp(): void $this->artisan('module:make-migration', ['name' => 'create_posts_table', 'module' => 'Blog']); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); $this->finder->delete($this->finder->allFiles(base_path('database/migrations'))); diff --git a/tests/Commands/Publish/PublishTranslationCommandTest.php b/tests/Commands/Publish/PublishTranslationCommandTest.php index 0e8da296d..fe343ee41 100644 --- a/tests/Commands/Publish/PublishTranslationCommandTest.php +++ b/tests/Commands/Publish/PublishTranslationCommandTest.php @@ -17,7 +17,7 @@ class PublishTranslationCommandTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -25,7 +25,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/Commands/UpdatePhpunitCoverageTest.php b/tests/Commands/UpdatePhpunitCoverageTest.php index 04f6c6848..02a912323 100644 --- a/tests/Commands/UpdatePhpunitCoverageTest.php +++ b/tests/Commands/UpdatePhpunitCoverageTest.php @@ -6,7 +6,7 @@ class UpdatePhpunitCoverageTest extends BaseTestCase { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/HelpersTest.php b/tests/HelpersTest.php index f6299d152..47d497bad 100644 --- a/tests/HelpersTest.php +++ b/tests/HelpersTest.php @@ -17,7 +17,7 @@ class HelpersTest extends BaseTestCase */ private $modulePath; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; @@ -25,7 +25,7 @@ public function setUp(): void $this->modulePath = $this->getModuleAppPath(); } - public function tearDown(): void + protected function tearDown(): void { $this->app[RepositoryInterface::class]->delete('Blog'); parent::tearDown(); diff --git a/tests/JsonTest.php b/tests/JsonTest.php index 955a37a27..29e4cab5a 100644 --- a/tests/JsonTest.php +++ b/tests/JsonTest.php @@ -12,7 +12,7 @@ class JsonTest extends BaseTestCase */ private $json; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $path = __DIR__.'/stubs/valid/module.json'; diff --git a/tests/LaravelFileRepositoryTest.php b/tests/LaravelFileRepositoryTest.php index 4dc0adb72..f7092c5b7 100644 --- a/tests/LaravelFileRepositoryTest.php +++ b/tests/LaravelFileRepositoryTest.php @@ -22,14 +22,14 @@ class LaravelFileRepositoryTest extends BaseTestCase */ private $activator; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->repository = new LaravelFileRepository($this->app); $this->activator = $this->app[ActivatorInterface::class]; } - public function tearDown(): void + protected function tearDown(): void { $this->activator->reset(); $this->artisan('module:delete', ['--all' => true, '--force' => true]); @@ -205,8 +205,7 @@ public function test_it_can_delete_a_module() public function test_it_can_register_macros() { - Module::macro('registeredMacro', function () { - }); + Module::macro('registeredMacro', function () {}); $this->assertTrue(Module::hasMacro('registeredMacro')); } diff --git a/tests/LaravelModuleTest.php b/tests/LaravelModuleTest.php index dd8878c53..39c1fa930 100644 --- a/tests/LaravelModuleTest.php +++ b/tests/LaravelModuleTest.php @@ -21,14 +21,14 @@ class LaravelModuleTest extends BaseTestCase */ private $activator; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->module = new TestingModule($this->app, 'Recipe Name', __DIR__.'/stubs/valid/Recipe'); $this->activator = $this->app[ActivatorInterface::class]; } - public function tearDown(): void + protected function tearDown(): void { $this->activator->reset(); parent::tearDown(); diff --git a/tests/LumenModuleTest.php b/tests/LumenModuleTest.php index 1dc142ea6..b94d94cb4 100644 --- a/tests/LumenModuleTest.php +++ b/tests/LumenModuleTest.php @@ -19,14 +19,14 @@ class LumenModuleTest extends BaseTestCase */ private $activator; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->module = new LumenTestingModule($this->app, 'Recipe Name', __DIR__.'/stubs/valid/Recipe'); $this->activator = $this->app[ActivatorInterface::class]; } - public function tearDown(): void + protected function tearDown(): void { $this->activator->reset(); parent::tearDown(); diff --git a/tests/StubTest.php b/tests/StubTest.php index 00089f026..a786371bf 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -12,13 +12,13 @@ class StubTest extends BaseTestCase */ private $finder; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->finder = $this->app['files']; } - public function tearDown(): void + protected function tearDown(): void { parent::tearDown(); $this->finder->delete([ diff --git a/tests/Traits/PathNamespaceTest.php b/tests/Traits/PathNamespaceTest.php index ceffac04e..a9eb0ea4a 100644 --- a/tests/Traits/PathNamespaceTest.php +++ b/tests/Traits/PathNamespaceTest.php @@ -6,11 +6,11 @@ class PathNamespaceTest extends BaseTestCase { - public function setUp(): void + protected function setUp(): void { parent::setUp(); - $this->class = new UsePathNamespaceTrait(); + $this->class = new UsePathNamespaceTrait; } public function test_studly_path() diff --git a/tests/stubs/valid/Recipe/Providers/DeferredServiceProvider.php b/tests/stubs/valid/Recipe/Providers/DeferredServiceProvider.php index 65ba14f66..eb16a9944 100644 --- a/tests/stubs/valid/Recipe/Providers/DeferredServiceProvider.php +++ b/tests/stubs/valid/Recipe/Providers/DeferredServiceProvider.php @@ -18,9 +18,7 @@ public function register() return 'bar'; }); - app()->bind('deferred', function () { - - }); + app()->bind('deferred', function () {}); } /** diff --git a/tests/stubs/valid/Recipe/Providers/RecipeServiceProvider.php b/tests/stubs/valid/Recipe/Providers/RecipeServiceProvider.php index a914dee15..f8596a6e9 100644 --- a/tests/stubs/valid/Recipe/Providers/RecipeServiceProvider.php +++ b/tests/stubs/valid/Recipe/Providers/RecipeServiceProvider.php @@ -38,7 +38,7 @@ private function registerBindings() $this->app->bind( 'Modules\Recipe\Repositories\RecipeRepository', function () { - $repository = new \Modules\Recipe\Repositories\Eloquent\EloquentRecipeRepository(new \Modules\Recipe\Entities\Recipe()); + $repository = new \Modules\Recipe\Repositories\Eloquent\EloquentRecipeRepository(new \Modules\Recipe\Entities\Recipe); if (! config('app.cache')) { return $repository; diff --git a/tests/stubs/valid/Recipe/Repositories/RecipeRepository.php b/tests/stubs/valid/Recipe/Repositories/RecipeRepository.php index abb7dff28..95cac3b30 100644 --- a/tests/stubs/valid/Recipe/Repositories/RecipeRepository.php +++ b/tests/stubs/valid/Recipe/Repositories/RecipeRepository.php @@ -4,6 +4,4 @@ use Modules\Core\Repositories\BaseRepository; -interface RecipeRepository extends BaseRepository -{ -} +interface RecipeRepository extends BaseRepository {}