From e8b10e69f0180e9eecfe415ad829f60621b9a365 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 12 Jul 2023 11:10:25 +0800 Subject: [PATCH 01/51] wip Signed-off-by: Mior Muhammad Zaki --- pint.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pint.json b/pint.json index e7a8443..628bd22 100644 --- a/pint.json +++ b/pint.json @@ -7,6 +7,9 @@ "strict": true }, "no_superfluous_phpdoc_tags": false, - "php_unit_method_casing": false + "php_unit_method_casing": false, + "nullable_type_declaration_for_default_null_value": { + "use_nullable_type_declaration": true + } } } From 3c4a69d6b6e34109fd22ff8cc0f764234b5605f9 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 28 Jul 2023 10:16:43 +0800 Subject: [PATCH 02/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a18758a..6402584 100644 --- a/composer.json +++ b/composer.json @@ -27,12 +27,12 @@ "php": "^8.1", "composer-runtime-api": "^2.2", "composer/semver": "^3.0", - "illuminate/console": "^10.0", - "illuminate/filesystem": "^10.0" + "illuminate/console": "^10.17", + "illuminate/filesystem": "^10.17" }, "require-dev": { "laravel/pint": "^1.6", - "orchestra/testbench": "^8.5", + "orchestra/testbench": "^8.5.11", "phpstan/phpstan": "^1.10.6", "phpunit/phpunit": "^10.1" }, From fe212a931cf3492104075a40767567c59c3f8812 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 28 Jul 2023 10:21:07 +0800 Subject: [PATCH 03/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Command.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index ebf21b0..e1afdcd 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -37,20 +37,29 @@ public function __construct(Preset $preset) $this->specifyParameters(); } + /** - * Run the console command. + * Initializes the command after the input has been bound and before the input + * is validated. * - * @return int + * @return void */ - public function run(InputInterface $input, OutputInterface $output): int + protected function initialize(InputInterface $input, OutputInterface $output) { + $this->input = $input; $this->output = new OutputStyle($input, $output); $this->components = new Factory($this->output); + } - return parent::run( - $this->input = $input, $this->output - ); + /** + * Run the console command. + * + * @return int + */ + public function run(InputInterface $input, OutputInterface $output): int + { + return parent::run($this->input, $this->output); } /** From c4b86b4e099d51e70ad9354f9495c9e67de77b2f Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 28 Jul 2023 10:22:34 +0800 Subject: [PATCH 04/51] wip Signed-off-by: Mior Muhammad Zaki --- .github/workflows/tests.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1547966..e72219c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -4,8 +4,6 @@ on: push: pull_request: workflow_dispatch: - schedule: - - cron: '0 0 * * 4' jobs: tests: From 81ff0e283f1dfd5607e25db53887a58a18be74ce Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 28 Jul 2023 10:29:39 +0800 Subject: [PATCH 05/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Command.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index e1afdcd..b3d76bf 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -37,7 +37,6 @@ public function __construct(Preset $preset) $this->specifyParameters(); } - /** * Initializes the command after the input has been bound and before the input * is validated. From 6729c77780e5a830487c7b7ceb99758f64b330bf Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 28 Jul 2023 11:19:04 +0800 Subject: [PATCH 06/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Command.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index b3d76bf..b89698c 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -45,10 +45,7 @@ public function __construct(Preset $preset) */ protected function initialize(InputInterface $input, OutputInterface $output) { - $this->input = $input; - $this->output = new OutputStyle($input, $output); - - $this->components = new Factory($this->output); + $this->components = new Factory($output); } /** @@ -58,7 +55,10 @@ protected function initialize(InputInterface $input, OutputInterface $output) */ public function run(InputInterface $input, OutputInterface $output): int { - return parent::run($this->input, $this->output); + return parent::run( + $this->input = $input, + $this->output = new OutputStyle($input, $output) + ); } /** From 69cfede4d28281494387c6ca15499417c6c889bc Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 28 Jul 2023 11:25:50 +0800 Subject: [PATCH 07/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index b89698c..bb04328 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -45,7 +45,7 @@ public function __construct(Preset $preset) */ protected function initialize(InputInterface $input, OutputInterface $output) { - $this->components = new Factory($output); + $this->components = new Factory($this->output); } /** From 38c3c041a3975cfaf914f84de4f373cf67038d08 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 28 Jul 2023 11:27:46 +0800 Subject: [PATCH 08/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Command.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index bb04328..7056ee1 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -42,6 +42,8 @@ public function __construct(Preset $preset) * is validated. * * @return void + * + * @phpstan-param \Symfony\Component\Console\Output\OutputInterface&\Illuminate\Console\OutputStyle $output */ protected function initialize(InputInterface $input, OutputInterface $output) { From a115ed5b1cb9dedfa75adbef9d4d0e9cc791b957 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 28 Jul 2023 11:28:03 +0800 Subject: [PATCH 09/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index 7056ee1..cca7c2c 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -47,7 +47,7 @@ public function __construct(Preset $preset) */ protected function initialize(InputInterface $input, OutputInterface $output) { - $this->components = new Factory($this->output); + $this->components = new Factory($output); } /** From 356c45b1876a3836fedc1b921af4c376b733a0ff Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 11 Aug 2023 10:18:57 +0800 Subject: [PATCH 10/51] Supports `laravel/prompts` (#3) * wip Signed-off-by: Mior Muhammad Zaki * wip Signed-off-by: Mior Muhammad Zaki * wip --------- Signed-off-by: Mior Muhammad Zaki --- composer.json | 3 ++- src/Commands/Command.php | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6402584..b1f78af 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "composer-runtime-api": "^2.2", "composer/semver": "^3.0", "illuminate/console": "^10.17", - "illuminate/filesystem": "^10.17" + "illuminate/filesystem": "^10.17", + "laravel/prompts": "^0.1.3" }, "require-dev": { "laravel/pint": "^1.6", diff --git a/src/Commands/Command.php b/src/Commands/Command.php index cca7c2c..57b2395 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -3,6 +3,7 @@ namespace Orchestra\Canvas\Core\Commands; use Illuminate\Console\Concerns\CallsCommands; +use Illuminate\Console\Concerns\ConfiguresPrompts; use Illuminate\Console\Concerns\HasParameters; use Illuminate\Console\Concerns\InteractsWithIO; use Illuminate\Console\OutputStyle; @@ -15,6 +16,7 @@ abstract class Command extends \Symfony\Component\Console\Command\Command { use CallsCommands, + ConfiguresPrompts, HasParameters, InteractsWithIO; @@ -48,6 +50,8 @@ public function __construct(Preset $preset) protected function initialize(InputInterface $input, OutputInterface $output) { $this->components = new Factory($output); + + $this->configurePrompts($input); } /** From f2ff2a7a56abf7535825e2fd5a5fa1042b4318ad Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 11 Aug 2023 10:20:34 +0800 Subject: [PATCH 11/51] wip --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b1f78af..4ff3f77 100644 --- a/composer.json +++ b/composer.json @@ -28,11 +28,11 @@ "composer-runtime-api": "^2.2", "composer/semver": "^3.0", "illuminate/console": "^10.17", - "illuminate/filesystem": "^10.17", - "laravel/prompts": "^0.1.3" + "illuminate/filesystem": "^10.17" }, "require-dev": { "laravel/pint": "^1.6", + "laravel/prompts": "^0.1.3", "orchestra/testbench": "^8.5.11", "phpstan/phpstan": "^1.10.6", "phpunit/phpunit": "^10.1" From aa823f6d7d9a9301f0536fbf3a400239e9b4888e Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 11 Aug 2023 10:24:46 +0800 Subject: [PATCH 12/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 4ff3f77..945c5d2 100644 --- a/composer.json +++ b/composer.json @@ -28,12 +28,13 @@ "composer-runtime-api": "^2.2", "composer/semver": "^3.0", "illuminate/console": "^10.17", - "illuminate/filesystem": "^10.17" + "illuminate/filesystem": "^10.17", + "orchestra/testbench-core": "^8.6" }, "require-dev": { "laravel/pint": "^1.6", - "laravel/prompts": "^0.1.3", - "orchestra/testbench": "^8.5.11", + "laravel/prompts": "^0.1.4", + "orchestra/testbench": "^8.6", "phpstan/phpstan": "^1.10.6", "phpunit/phpunit": "^10.1" }, From 1a3c9c26cdfe93fc07f1b1e2545bbc0999999474 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 11 Aug 2023 10:46:30 +0800 Subject: [PATCH 13/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 4 ++-- src/Commands/Command.php | 13 +++++++++++++ src/Presets/Laravel.php | 8 ++++++++ src/Presets/Package.php | 8 ++++++++ src/Presets/Preset.php | 13 +++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 945c5d2..bd6d634 100644 --- a/composer.json +++ b/composer.json @@ -29,12 +29,12 @@ "composer/semver": "^3.0", "illuminate/console": "^10.17", "illuminate/filesystem": "^10.17", - "orchestra/testbench-core": "^8.6" + "orchestra/testbench-core": "^8.6.2" }, "require-dev": { "laravel/pint": "^1.6", "laravel/prompts": "^0.1.4", - "orchestra/testbench": "^8.6", + "orchestra/testbench": "^8.6.3", "phpstan/phpstan": "^1.10.6", "phpunit/phpunit": "^10.1" }, diff --git a/src/Commands/Command.php b/src/Commands/Command.php index 57b2395..2c880d6 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -9,6 +9,7 @@ use Illuminate\Console\OutputStyle; use Illuminate\Console\View\Components\Factory; use Orchestra\Canvas\Core\Presets\Preset; +use Orchestra\Testbench\Foundation\Application as Testbench; use Symfony\Component\Console\Command\Command as SymfonyConsole; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -61,6 +62,8 @@ protected function initialize(InputInterface $input, OutputInterface $output) */ public function run(InputInterface $input, OutputInterface $output): int { + $this->laravel = Testbench::create(basePath: $this->preset->laravelPath()); + return parent::run( $this->input = $input, $this->output = new OutputStyle($input, $output) @@ -81,4 +84,14 @@ protected function resolveCommand($command) : $command ); } + + /** + * Get the Laravel application instance. + * + * @return \Illuminate\Contracts\Foundation\Application + */ + public function getLaravel() + { + return $this->laravel; + } } diff --git a/src/Presets/Laravel.php b/src/Presets/Laravel.php index 02c1488..08c8a32 100644 --- a/src/Presets/Laravel.php +++ b/src/Presets/Laravel.php @@ -12,6 +12,14 @@ public function name(): string return 'laravel'; } + /** + * Get the path to the base working directory. + */ + public function laravelPath(): string + { + return $this->basePath(); + } + /** * Get the path to the source directory. */ diff --git a/src/Presets/Package.php b/src/Presets/Package.php index e0f895d..54783a6 100644 --- a/src/Presets/Package.php +++ b/src/Presets/Package.php @@ -14,6 +14,14 @@ public function name(): string return 'package'; } + /** + * Get the path to the base working directory. + */ + public function laravelPath(): string + { + return sprintf('%s/orchestra/testbench-core/laravel', $this->vendorPath()); + } + /** * Get the path to the source directory. */ diff --git a/src/Presets/Preset.php b/src/Presets/Preset.php index cee1ccd..29c9c3d 100644 --- a/src/Presets/Preset.php +++ b/src/Presets/Preset.php @@ -59,6 +59,14 @@ public function basePath(): string return $this->basePath; } + /** + * Get the path to the base working directory. + */ + public function vendorPath(): string + { + return "{$this->basePath}/vendor"; + } + /** * Get the path to the resource directory. */ @@ -131,6 +139,11 @@ public function hasCustomStubPath(): bool */ abstract public function name(): string; + /** + * Get the path to the base working directory. + */ + abstract public function laravelPath(): string; + /** * Get the path to the source directory. */ From a0bd50ac2a89c5013a79dcb045301c6d55bbc9e9 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 11 Aug 2023 10:50:48 +0800 Subject: [PATCH 14/51] wip Signed-off-by: Mior Muhammad Zaki --- .coveralls.yml | 1 - composer.json | 1 - 2 files changed, 2 deletions(-) delete mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 9160059..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -service_name: travis-ci diff --git a/composer.json b/composer.json index bd6d634..fe95cb9 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,6 @@ }, "require-dev": { "laravel/pint": "^1.6", - "laravel/prompts": "^0.1.4", "orchestra/testbench": "^8.6.3", "phpstan/phpstan": "^1.10.6", "phpunit/phpunit": "^10.1" From 9ff5b9a8c6db316217150bf53d3b2c2dadfa3d14 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 11 Aug 2023 11:10:57 +0800 Subject: [PATCH 15/51] wip Signed-off-by: Mior Muhammad Zaki --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 6600020..767bc9c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,11 +3,11 @@ # Ignore following folder/file. /.github export-ignore /tests export-ignore -/.coveralls.yml export-ignore /.gitattributes export-ignore /.gitignore export-ignore /.phpunit.cache export-ignore /canvas.yaml export-ignore +/phpstan-baseline.neon export-ignore /phpstan.neon.dist export-ignore /phpunit.xml export-ignore /pint.json export-ignore From 1e95f5e1e90fd139f22eeafbd0b9390fa9813771 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 11 Aug 2023 11:18:21 +0800 Subject: [PATCH 16/51] wip Signed-off-by: Mior Muhammad Zaki --- tests/Unit/Presets/LaravelTest.php | 2 ++ tests/Unit/Presets/PackageTest.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/Unit/Presets/LaravelTest.php b/tests/Unit/Presets/LaravelTest.php index 9cb93bc..1da5902 100644 --- a/tests/Unit/Presets/LaravelTest.php +++ b/tests/Unit/Presets/LaravelTest.php @@ -20,12 +20,14 @@ public function it_has_proper_signatures() $this->assertFalse($preset->is('package')); $this->assertSame($directory, $preset->basePath()); + $this->assertSame($preset->basePath(), $preset->laravelPath()); $this->assertSame('App', $preset->rootNamespace()); $this->assertSame('App\Models', $preset->modelNamespace()); $this->assertSame('App\Providers', $preset->providerNamespace()); $this->assertSame("{$directory}/app", $preset->sourcePath()); + $this->assertSame("{$directory}/vendor", $preset->vendorPath()); $this->assertSame("{$directory}/resources", $preset->resourcePath()); $this->assertSame("{$directory}/database/factories", $preset->factoryPath()); $this->assertSame("{$directory}/database/migrations", $preset->migrationPath()); diff --git a/tests/Unit/Presets/PackageTest.php b/tests/Unit/Presets/PackageTest.php index 91d84e9..b91a574 100644 --- a/tests/Unit/Presets/PackageTest.php +++ b/tests/Unit/Presets/PackageTest.php @@ -20,12 +20,14 @@ public function it_has_proper_signatures() $this->assertFalse($preset->is('laravel')); $this->assertSame($directory, $preset->basePath()); + $this->assertSame("{$directory}/vendor/orchestra/testbench-core/laravel", $preset->laravelPath()); $this->assertSame('FooBar', $preset->rootNamespace()); $this->assertSame('FooBar', $preset->modelNamespace()); $this->assertSame('FooBar', $preset->providerNamespace()); $this->assertSame("{$directory}/src", $preset->sourcePath()); + $this->assertSame("{$directory}/vendor", $preset->vendorPath()); $this->assertSame("{$directory}/resources", $preset->resourcePath()); $this->assertSame("{$directory}/database/factories", $preset->factoryPath()); $this->assertSame("{$directory}/database/migrations", $preset->migrationPath()); From 0754f0266630eefe0df82f22ad857c3bda422f17 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Sun, 13 Aug 2023 06:32:50 +0800 Subject: [PATCH 17/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index c2a0d53..1460165 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -11,8 +11,8 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * @property string $name - * @property string $description + * @property string|null $name + * @property string|null $description */ abstract class Generator extends Command implements GeneratesCodeListener { From 5c0ad272f79ec12a1adce38fc40bbf27fdea9aeb Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 15 Aug 2023 22:40:52 +0800 Subject: [PATCH 18/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Command.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index 2c880d6..66363b2 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -28,6 +28,13 @@ abstract class Command extends \Symfony\Component\Console\Command\Command */ protected $preset; + /** + * The Laravel application instance. + * + * @var \Illuminate\Contracts\Foundation\Application + */ + protected $laravel; + /** * Construct a new generator command. */ From 407be3c332506b8818f8c651b1c24a423bace618 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 15 Aug 2023 22:44:20 +0800 Subject: [PATCH 19/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Command.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index 66363b2..1882aae 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -8,6 +8,7 @@ use Illuminate\Console\Concerns\InteractsWithIO; use Illuminate\Console\OutputStyle; use Illuminate\Console\View\Components\Factory; +use Illuminate\Container\Container; use Orchestra\Canvas\Core\Presets\Preset; use Orchestra\Testbench\Foundation\Application as Testbench; use Symfony\Component\Console\Command\Command as SymfonyConsole; @@ -69,7 +70,11 @@ protected function initialize(InputInterface $input, OutputInterface $output) */ public function run(InputInterface $input, OutputInterface $output): int { - $this->laravel = Testbench::create(basePath: $this->preset->laravelPath()); + $container = Container::getInstance(); + + $this->laravel = $container->bound('app') + ? $container->get('app') + : Testbench::create(basePath: $this->preset->laravelPath()); return parent::run( $this->input = $input, From 1d616b8728982876541c6fd306d46ed2942c8230 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 15 Aug 2023 22:45:09 +0800 Subject: [PATCH 20/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index fe95cb9..7edb556 100644 --- a/composer.json +++ b/composer.json @@ -28,12 +28,11 @@ "composer-runtime-api": "^2.2", "composer/semver": "^3.0", "illuminate/console": "^10.17", - "illuminate/filesystem": "^10.17", - "orchestra/testbench-core": "^8.6.2" + "illuminate/filesystem": "^10.17" }, "require-dev": { "laravel/pint": "^1.6", - "orchestra/testbench": "^8.6.3", + "orchestra/testbench": "^8.8.1", "phpstan/phpstan": "^1.10.6", "phpunit/phpunit": "^10.1" }, From 16766c44b15703cd2699426f22181ca262afa572 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 06:27:59 +0800 Subject: [PATCH 21/51] wip Signed-off-by: Mior Muhammad Zaki --- src/GeneratesCommandCode.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/GeneratesCommandCode.php b/src/GeneratesCommandCode.php index 479913b..262f82e 100644 --- a/src/GeneratesCommandCode.php +++ b/src/GeneratesCommandCode.php @@ -2,8 +2,10 @@ namespace Orchestra\Canvas\Core; +use Illuminate\Support\Str; + /** - * @see https://github.com/laravel/framework/blob/8.x/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php + * @see https://github.com/laravel/framework/blob/10.x/src/Illuminate/Foundation/Console/ConsoleMakeCommand.php */ class GeneratesCommandCode extends GeneratesCode { @@ -16,6 +18,8 @@ protected function replaceClass(string $stub, string $name): string { $stub = parent::replaceClass($stub, $name); - return str_replace(['dummy:command', '{{ command }}', '{{command}}'], $this->options['command'], $stub); + $command = $this->options['command'] ?: 'app:'.Str::of($name)->classBasename()->kebab()->value(); + + return str_replace(['dummy:command', '{{ command }}', '{{command}}'], $command, $stub); } } From 1d654c8e8d5f85ec5edea395de3c4e92eeee0307 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:14:03 +0800 Subject: [PATCH 22/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 1460165..a85f241 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -2,6 +2,7 @@ namespace Orchestra\Canvas\Core\Commands; +use Illuminate\Console\Concerns\CreatesMatchingTest; use Orchestra\Canvas\Core\CodeGenerator; use Orchestra\Canvas\Core\Contracts\GeneratesCodeListener; use Orchestra\Canvas\Core\GeneratesCode; @@ -49,6 +50,10 @@ public function __construct(Preset $preset) { $this->files = $preset->filesystem(); + if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { + $this->addTestOptions(); + } + parent::__construct($preset); } @@ -97,6 +102,10 @@ public function codeHasBeenGenerated(string $className): int { $this->components->info(sprintf('%s [%s] created successfully.', $this->type, $className)); + if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { + $this->handleTestCreation($path); + } + return static::SUCCESS; } From 32d69dfad9fa293ec69e510e4a9c2cd0a097d653 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:15:08 +0800 Subject: [PATCH 23/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index a85f241..48f6440 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -50,7 +50,7 @@ public function __construct(Preset $preset) { $this->files = $preset->filesystem(); - if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { + if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { $this->addTestOptions(); } @@ -102,7 +102,7 @@ public function codeHasBeenGenerated(string $className): int { $this->components->info(sprintf('%s [%s] created successfully.', $this->type, $className)); - if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { + if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { $this->handleTestCreation($path); } From a03834f94c42f1887e2db54b8a924de8e730e660 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:16:00 +0800 Subject: [PATCH 24/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 48f6440..d6124fd 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -51,6 +51,7 @@ public function __construct(Preset $preset) $this->files = $preset->filesystem(); if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { + /** @phpstan-ignore-next-line */ $this->addTestOptions(); } @@ -103,6 +104,7 @@ public function codeHasBeenGenerated(string $className): int $this->components->info(sprintf('%s [%s] created successfully.', $this->type, $className)); if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { + /** @phpstan-ignore-next-line */ $this->handleTestCreation($path); } From 3f023128f83d5bf4e3d6be38be8cd74208af9c97 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:31:01 +0800 Subject: [PATCH 25/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 5 ----- src/GeneratesCode.php | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index d6124fd..6859617 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -103,11 +103,6 @@ public function codeHasBeenGenerated(string $className): int { $this->components->info(sprintf('%s [%s] created successfully.', $this->type, $className)); - if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { - /** @phpstan-ignore-next-line */ - $this->handleTestCreation($path); - } - return static::SUCCESS; } diff --git a/src/GeneratesCode.php b/src/GeneratesCode.php index a4aea3c..ccec6c8 100644 --- a/src/GeneratesCode.php +++ b/src/GeneratesCode.php @@ -2,6 +2,7 @@ namespace Orchestra\Canvas\Core; +use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Foundation\Auth\User; use Illuminate\Support\Str; @@ -59,7 +60,12 @@ public function __invoke(bool $force = false) $this->files->put($path, $this->sortImports($this->buildClass($className))); - return $this->listener->codeHasBeenGenerated($className); + return tap($this->listener->codeHasBeenGenerated($className), function ($exitCode) use ($path) { + if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this->listener))) { + /** @phpstan-ignore-next-line */ + $this->handleTestCreation($path); + } + }); } /** From 524e3b5c322cd2f02476177835d642049270eb9b Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:35:34 +0800 Subject: [PATCH 26/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 11 +++++++++++ src/GeneratesCode.php | 7 ++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 6859617..3c74629 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -106,6 +106,17 @@ public function codeHasBeenGenerated(string $className): int return static::SUCCESS; } + /** + * Run after Code successfully generated. + */ + public function afterCodeHasBeenGenerated(string $className, string $path): int + { + if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { + /** @phpstan-ignore-next-line */ + $this->handleTestCreation($path); + } + } + /** * Get the published stub file for the generator. */ diff --git a/src/GeneratesCode.php b/src/GeneratesCode.php index ccec6c8..d486bed 100644 --- a/src/GeneratesCode.php +++ b/src/GeneratesCode.php @@ -60,11 +60,8 @@ public function __invoke(bool $force = false) $this->files->put($path, $this->sortImports($this->buildClass($className))); - return tap($this->listener->codeHasBeenGenerated($className), function ($exitCode) use ($path) { - if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this->listener))) { - /** @phpstan-ignore-next-line */ - $this->handleTestCreation($path); - } + return tap($this->listener->codeHasBeenGenerated($className), function ($exitCode) use ($className, $path) { + $this->listener->afterCodeHasBeenGenerated($className, $path); }); } From 24d1b554372fd2ec276a5cb1a4c5a232edec2067 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:38:16 +0800 Subject: [PATCH 27/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 6 ++++-- src/Contracts/GeneratesCodeListener.php | 5 +++++ src/GeneratesCode.php | 1 - 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 3c74629..5f04a33 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -107,9 +107,11 @@ public function codeHasBeenGenerated(string $className): int } /** - * Run after Code successfully generated. + * Code successfully generated. + * + * @return void */ - public function afterCodeHasBeenGenerated(string $className, string $path): int + public function afterCodeHasBeenGenerated(string $className, string $path): void { if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { /** @phpstan-ignore-next-line */ diff --git a/src/Contracts/GeneratesCodeListener.php b/src/Contracts/GeneratesCodeListener.php index f49311e..9ce556e 100644 --- a/src/Contracts/GeneratesCodeListener.php +++ b/src/Contracts/GeneratesCodeListener.php @@ -18,6 +18,11 @@ public function codeAlreadyExists(string $className): mixed; */ public function codeHasBeenGenerated(string $className): mixed; + /** + * Code successfully generated. + */ + public function afterCodeHasBeenGenerated(string $className, string $path): void; + /** * Get the stub file for the generator. */ diff --git a/src/GeneratesCode.php b/src/GeneratesCode.php index d486bed..ad384ff 100644 --- a/src/GeneratesCode.php +++ b/src/GeneratesCode.php @@ -2,7 +2,6 @@ namespace Orchestra\Canvas\Core; -use Illuminate\Console\Concerns\CreatesMatchingTest; use Illuminate\Foundation\Auth\User; use Illuminate\Support\Str; From 64eddfad2d112be2f35d998d978e0b6dc658558e Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:39:53 +0800 Subject: [PATCH 28/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 5f04a33..7194b5e 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -50,11 +50,6 @@ public function __construct(Preset $preset) { $this->files = $preset->filesystem(); - if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { - /** @phpstan-ignore-next-line */ - $this->addTestOptions(); - } - parent::__construct($preset); } @@ -70,6 +65,11 @@ protected function configure() $this->setName($this->getName()) ->setDescription($this->getDescription()) ->addArgument('name', InputArgument::REQUIRED, "The name of the {$this->fileType}"); + + if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { + /** @phpstan-ignore-next-line */ + $this->addTestOptions(); + } } /** From bb12a5dfbb2edbb2e072a27e07a6cfcb1897d343 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:46:40 +0800 Subject: [PATCH 29/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 7194b5e..35dad83 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -3,6 +3,7 @@ namespace Orchestra\Canvas\Core\Commands; use Illuminate\Console\Concerns\CreatesMatchingTest; +use Illuminate\Support\Str; use Orchestra\Canvas\Core\CodeGenerator; use Orchestra\Canvas\Core\Contracts\GeneratesCodeListener; use Orchestra\Canvas\Core\GeneratesCode; @@ -115,7 +116,7 @@ public function afterCodeHasBeenGenerated(string $className, string $path): void { if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { /** @phpstan-ignore-next-line */ - $this->handleTestCreation($path); + $this->handleTestCreation(Str::of($path)->after($this->preset->sourcePath())); } } From a2ffe12c15179b0a52cce21f2e48074121b55589 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:50:27 +0800 Subject: [PATCH 30/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 4 +--- src/Contracts/GeneratesCodeListener.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 35dad83..7d65e98 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -108,9 +108,7 @@ public function codeHasBeenGenerated(string $className): int } /** - * Code successfully generated. - * - * @return void + * Run after code successfully generated. */ public function afterCodeHasBeenGenerated(string $className, string $path): void { diff --git a/src/Contracts/GeneratesCodeListener.php b/src/Contracts/GeneratesCodeListener.php index 9ce556e..6ad213a 100644 --- a/src/Contracts/GeneratesCodeListener.php +++ b/src/Contracts/GeneratesCodeListener.php @@ -19,7 +19,7 @@ public function codeAlreadyExists(string $className): mixed; public function codeHasBeenGenerated(string $className): mixed; /** - * Code successfully generated. + * Run after code successfully generated. */ public function afterCodeHasBeenGenerated(string $className, string $path): void; From 3ee8cf0ff2cc69a2ec215f643d8f657b02925e41 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:56:43 +0800 Subject: [PATCH 31/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 2 +- src/GeneratesCode.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 7d65e98..0583c2e 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -114,7 +114,7 @@ public function afterCodeHasBeenGenerated(string $className, string $path): void { if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { /** @phpstan-ignore-next-line */ - $this->handleTestCreation(Str::of($path)->after($this->preset->sourcePath())); + $this->handleTestCreation($path); } } diff --git a/src/GeneratesCode.php b/src/GeneratesCode.php index ad384ff..7cbc703 100644 --- a/src/GeneratesCode.php +++ b/src/GeneratesCode.php @@ -60,7 +60,7 @@ public function __invoke(bool $force = false) $this->files->put($path, $this->sortImports($this->buildClass($className))); return tap($this->listener->codeHasBeenGenerated($className), function ($exitCode) use ($className, $path) { - $this->listener->afterCodeHasBeenGenerated($className, $path); + $this->listener->afterCodeHasBeenGenerated($className, Str::of($path)->after($this->preset->sourcePath())); }); } From 9bb48e6738cd0ae6ee9c55adde4089d3524da2ba Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 16 Aug 2023 08:56:59 +0800 Subject: [PATCH 32/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 0583c2e..d2011d6 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -3,7 +3,6 @@ namespace Orchestra\Canvas\Core\Commands; use Illuminate\Console\Concerns\CreatesMatchingTest; -use Illuminate\Support\Str; use Orchestra\Canvas\Core\CodeGenerator; use Orchestra\Canvas\Core\Contracts\GeneratesCodeListener; use Orchestra\Canvas\Core\GeneratesCode; From c5fc475c62657b4b199d60e2f7c297f80b7ed4c7 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Sat, 19 Aug 2023 20:31:49 +0800 Subject: [PATCH 33/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 14 +++++++++----- src/Presets/Preset.php | 18 +++++++++++++++++- tests/Feature/CommandsProviderTest.php | 2 +- tests/Unit/Presets/LaravelTest.php | 2 +- tests/Unit/Presets/PackageTest.php | 2 +- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 7edb556..feff2be 100644 --- a/composer.json +++ b/composer.json @@ -53,15 +53,19 @@ } }, "scripts": { - "post-autoload-dump": "@composer run prepare", + "post-autoload-dump": "@prepare", "prepare": "@php ./vendor/bin/testbench package:discover --ansi", - "ci": [ - "@composer audit", - "@composer run prepare", + "lint": [ "@php vendor/bin/phpstan analyse", "@php vendor/bin/pint" ], - "test": "@php vendor/bin/phpunit -c ./ --color" + "test": "@php vendor/bin/phpunit -c ./ --color", + "ci": [ + "@composer audit", + "@prepare", + "@lint", + "@test" + ] }, "prefer-stable": true, "minimum-stability": "dev" diff --git a/src/Presets/Preset.php b/src/Presets/Preset.php index 29c9c3d..eb95853 100644 --- a/src/Presets/Preset.php +++ b/src/Presets/Preset.php @@ -111,10 +111,26 @@ public function seederPath(): string return sprintf( '%s/%s', $this->basePath(), - $this->config('seeder.path', 'database/seeds') + $this->config('seeder.path', 'database/seeders') ); } + /** + * Databases namespace. + */ + public function databaseFactoryNamespace(): string + { + return $this->config('factory.namespace', 'Database\Factories\\'); + } + + /** + * Databases namespace. + */ + public function databaseSeederNamespace(): string + { + return $this->config('seeder.path', 'Database\Factories\\'); + } + /** * Sync commands to preset. */ diff --git a/tests/Feature/CommandsProviderTest.php b/tests/Feature/CommandsProviderTest.php index e96d1b2..3f9c2b6 100644 --- a/tests/Feature/CommandsProviderTest.php +++ b/tests/Feature/CommandsProviderTest.php @@ -29,6 +29,6 @@ public function it_can_setup_laravel_preset() $this->assertSame("{$directory}/resources", $preset->resourcePath()); $this->assertSame("{$directory}/database/factories", $preset->factoryPath()); $this->assertSame("{$directory}/database/migrations", $preset->migrationPath()); - $this->assertSame("{$directory}/database/seeds", $preset->seederPath()); + $this->assertSame("{$directory}/database/seeders", $preset->seederPath()); } } diff --git a/tests/Unit/Presets/LaravelTest.php b/tests/Unit/Presets/LaravelTest.php index 1da5902..df5bf76 100644 --- a/tests/Unit/Presets/LaravelTest.php +++ b/tests/Unit/Presets/LaravelTest.php @@ -31,7 +31,7 @@ public function it_has_proper_signatures() $this->assertSame("{$directory}/resources", $preset->resourcePath()); $this->assertSame("{$directory}/database/factories", $preset->factoryPath()); $this->assertSame("{$directory}/database/migrations", $preset->migrationPath()); - $this->assertSame("{$directory}/database/seeds", $preset->seederPath()); + $this->assertSame("{$directory}/database/seeders", $preset->seederPath()); $this->assertFalse($preset->hasCustomStubPath()); $this->assertNull($preset->getCustomStubPath()); diff --git a/tests/Unit/Presets/PackageTest.php b/tests/Unit/Presets/PackageTest.php index b91a574..963b22d 100644 --- a/tests/Unit/Presets/PackageTest.php +++ b/tests/Unit/Presets/PackageTest.php @@ -31,7 +31,7 @@ public function it_has_proper_signatures() $this->assertSame("{$directory}/resources", $preset->resourcePath()); $this->assertSame("{$directory}/database/factories", $preset->factoryPath()); $this->assertSame("{$directory}/database/migrations", $preset->migrationPath()); - $this->assertSame("{$directory}/database/seeds", $preset->seederPath()); + $this->assertSame("{$directory}/database/seeders", $preset->seederPath()); $this->assertFalse($preset->hasCustomStubPath()); $this->assertNull($preset->getCustomStubPath()); From 27f8bf3f5fa1285d3c22070a5ae72078c118984f Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Sat, 19 Aug 2023 20:35:20 +0800 Subject: [PATCH 34/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Presets/Preset.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Presets/Preset.php b/src/Presets/Preset.php index eb95853..27b4652 100644 --- a/src/Presets/Preset.php +++ b/src/Presets/Preset.php @@ -116,19 +116,19 @@ public function seederPath(): string } /** - * Databases namespace. + * Database factory namespace. */ - public function databaseFactoryNamespace(): string + public function factoryNamespace(): string { - return $this->config('factory.namespace', 'Database\Factories\\'); + return $this->config('factory.namespace', 'Database\Factories'); } /** - * Databases namespace. + * Database seeder namespace. */ - public function databaseSeederNamespace(): string + public function seederNamespace(): string { - return $this->config('seeder.path', 'Database\Factories\\'); + return $this->config('seeder.path', 'Database\Seeders'); } /** From 454f43388725aa3cfd8d1807e9e11a9c9f0c4f3d Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Sat, 19 Aug 2023 20:57:43 +0800 Subject: [PATCH 35/51] wip Signed-off-by: Mior Muhammad Zaki --- tests/Unit/Presets/LaravelTest.php | 4 +++- tests/Unit/Presets/PackageTest.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Unit/Presets/LaravelTest.php b/tests/Unit/Presets/LaravelTest.php index df5bf76..e824bda 100644 --- a/tests/Unit/Presets/LaravelTest.php +++ b/tests/Unit/Presets/LaravelTest.php @@ -1,6 +1,6 @@ assertSame('App', $preset->rootNamespace()); $this->assertSame('App\Models', $preset->modelNamespace()); $this->assertSame('App\Providers', $preset->providerNamespace()); + $this->assertSame('Database\Factories', $preset->factoryNamespace()); + $this->assertSame('Database\Seeders', $preset->seederNamespace()); $this->assertSame("{$directory}/app", $preset->sourcePath()); $this->assertSame("{$directory}/vendor", $preset->vendorPath()); diff --git a/tests/Unit/Presets/PackageTest.php b/tests/Unit/Presets/PackageTest.php index 963b22d..27ffce7 100644 --- a/tests/Unit/Presets/PackageTest.php +++ b/tests/Unit/Presets/PackageTest.php @@ -1,6 +1,6 @@ assertSame('FooBar', $preset->rootNamespace()); $this->assertSame('FooBar', $preset->modelNamespace()); $this->assertSame('FooBar', $preset->providerNamespace()); + $this->assertSame('Database\Factories', $preset->factoryNamespace()); + $this->assertSame('Database\Seeders', $preset->seederNamespace()); $this->assertSame("{$directory}/src", $preset->sourcePath()); $this->assertSame("{$directory}/vendor", $preset->vendorPath()); From 0b651acc58782b417fa2d3a49f7a1f1837e9715d Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Sun, 20 Aug 2023 23:14:26 +0800 Subject: [PATCH 36/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 3 +++ src/Testing/TestCase.php | 24 ------------------------ 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index feff2be..cfe2b93 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,9 @@ "phpstan/phpstan": "^1.10.6", "phpunit/phpunit": "^10.1" }, + "conflict": { + "orchestra/testbench-core": "<8.2.0" + }, "config": { "sort-packages": true }, diff --git a/src/Testing/TestCase.php b/src/Testing/TestCase.php index 01d9a8f..b72a20b 100644 --- a/src/Testing/TestCase.php +++ b/src/Testing/TestCase.php @@ -15,28 +15,4 @@ class TestCase extends \Orchestra\Testbench\TestCase * @var array|null */ protected $files = []; - - /** - * Setup the test environment. - */ - protected function setUp(): void - { - parent::setUp(); - - if (InstalledVersions::satisfies(new VersionParser, 'orchestra/testbench-core', '<8.2.0')) { - $this->setUpInteractsWithPublishedFiles(); - } - } - - /** - * Teardown the test environment. - */ - protected function tearDown(): void - { - if (InstalledVersions::satisfies(new VersionParser, 'orchestra/testbench-core', '<8.2.0')) { - $this->tearDownInteractsWithPublishedFiles(); - } - - parent::tearDown(); - } } From 012bc4afe74d6f6a15483730c6d07ac4ad5fc5fa Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 16:47:13 +0800 Subject: [PATCH 37/51] wip Signed-off-by: Mior Muhammad Zaki --- .coveralls.yml | 1 - .gitattributes | 5 +---- .php_cs | 28 ---------------------------- composer.json | 3 +++ phpstan-baseline.neon | 11 +++++++++++ phpstan.neon.dist | 1 + src/CodeGenerator.php | 1 - src/Commands/Command.php | 1 - src/Commands/Generator.php | 4 ++-- src/Presets/Preset.php | 3 +-- 10 files changed, 19 insertions(+), 39 deletions(-) delete mode 100644 .coveralls.yml delete mode 100644 .php_cs create mode 100644 phpstan-baseline.neon diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 9160059..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -service_name: travis-ci diff --git a/.gitattributes b/.gitattributes index 960f009..2aa4a89 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,12 +3,9 @@ # Ignore following folder/file. /.github export-ignore /tests export-ignore -/.coveralls.yml export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.php_cs export-ignore -/.travis.yml export-ignore -/canvas.yaml export-ignore +/phpstan-baseline.neon export-ignore /phpstan.neon.dist export-ignore /phpunit.xml export-ignore /sync.sh export-ignore diff --git a/.php_cs b/.php_cs deleted file mode 100644 index b961703..0000000 --- a/.php_cs +++ /dev/null @@ -1,28 +0,0 @@ -in(__DIR__.'/src') - ->in(__DIR__.'/tests'); - -return PhpCsFixer\Config::create() - ->setRiskyAllowed(false) - ->setRules([ - '@Symfony' => true, - 'array_syntax' => ['syntax' => 'short'], - 'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false], - 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true], - 'no_extra_blank_lines' => false, - 'no_empty_comment' => false, - 'no_extra_consecutive_blank_lines' => false, - 'no_unneeded_control_parentheses' => false, - 'not_operator_with_successor_space' => true, - 'ordered_imports' => ['sortAlgorithm' => 'alpha'], - 'phpdoc_align' => false, - 'phpdoc_no_empty_return' => false, - 'phpdoc_order' => true, - 'php_unit_method_casing' => false, - 'pre_increment' => false, - 'single_trait_insert_per_statement' => false, - 'yoda_style' => false, - ]) - ->setFinder($finder); diff --git a/composer.json b/composer.json index 4eb8153..0934ace 100644 --- a/composer.json +++ b/composer.json @@ -48,5 +48,8 @@ ] } }, + "scripts": { + "lint": "vendor/bin/phpstan analyse" + }, "minimum-stability": "dev" } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..12c7d01 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,11 @@ +parameters: + ignoreErrors: + - + message: "#^Access to private property \\$description of parent class Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\.$#" + count: 1 + path: src/Commands/Generator.php + + - + message: "#^Access to private property \\$name of parent class Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\.$#" + count: 1 + path: src/Commands/Generator.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index dcaf9ec..52008e3 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,6 @@ includes: - ./vendor/nunomaduro/larastan/extension.neon + - ./phpstan-baseline.neon parameters: diff --git a/src/CodeGenerator.php b/src/CodeGenerator.php index 955b7a9..73a2379 100644 --- a/src/CodeGenerator.php +++ b/src/CodeGenerator.php @@ -15,7 +15,6 @@ trait CodeGenerator * Set Preset for generator. * * @param \Orchestra\Canvas\Core\Presets\Preset $preset - * * @return $this */ public function setPreset(Presets\Preset $preset) diff --git a/src/Commands/Command.php b/src/Commands/Command.php index e43dbe0..36a1fd5 100644 --- a/src/Commands/Command.php +++ b/src/Commands/Command.php @@ -54,7 +54,6 @@ public function run(InputInterface $input, OutputInterface $output) * Resolve the console command instance for the given command. * * @param \Symfony\Component\Console\Command\Command|string $command - * * @return \Symfony\Component\Console\Command\Command */ protected function resolveCommand($command) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index eb9a51a..469419a 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -73,9 +73,9 @@ protected function configure() /** * Execute the command. * - * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException - * * @return int 0 if everything went fine, or an exit code + * + * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Presets/Preset.php b/src/Presets/Preset.php index 09f92ae..1a47887 100644 --- a/src/Presets/Preset.php +++ b/src/Presets/Preset.php @@ -51,10 +51,9 @@ public function is(string $name): bool * Get configuration. * * @param mixed|null $default - * * @return mixed */ - public function config(?string $key = null, $default = null) + public function config(string $key = null, $default = null) { if (\is_null($key)) { return $this->config; From 7246b0e2d249560047c2f3d4c30c1d175f3fe9e9 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 16:49:05 +0800 Subject: [PATCH 38/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Testing/TestCase.php | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/Testing/TestCase.php b/src/Testing/TestCase.php index deba928..28411cb 100644 --- a/src/Testing/TestCase.php +++ b/src/Testing/TestCase.php @@ -12,24 +12,4 @@ class TestCase extends \Orchestra\Testbench\TestCase * @var array|null */ protected $files = []; - - /** - * Setup the test environment. - */ - protected function setUp(): void - { - parent::setUp(); - - $this->setUpInteractsWithPublishedFiles(); - } - - /** - * Teardown the test environment. - */ - protected function tearDown(): void - { - $this->tearDownInteractsWithPublishedFiles(); - - parent::tearDown(); - } } From 0d1b8dd09446d20970b8b3f0830c073f31eccf34 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 16:56:30 +0800 Subject: [PATCH 39/51] wip Signed-off-by: Mior Muhammad Zaki --- phpstan-baseline.neon | 11 ----------- phpstan.neon.dist | 1 - src/Commands/Generator.php | 4 ++-- 3 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 phpstan-baseline.neon diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index 12c7d01..0000000 --- a/phpstan-baseline.neon +++ /dev/null @@ -1,11 +0,0 @@ -parameters: - ignoreErrors: - - - message: "#^Access to private property \\$description of parent class Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\.$#" - count: 1 - path: src/Commands/Generator.php - - - - message: "#^Access to private property \\$name of parent class Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\.$#" - count: 1 - path: src/Commands/Generator.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 52008e3..dcaf9ec 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,5 @@ includes: - ./vendor/nunomaduro/larastan/extension.neon - - ./phpstan-baseline.neon parameters: diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 469419a..8e4d4a9 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -65,8 +65,8 @@ protected function configure() { $this->ignoreValidationErrors(); - $this->setName($this->name) - ->setDescription($this->description) + $this->setName($this->getName()) + ->setDescription($this->getDescription()) ->addArgument('name', InputArgument::REQUIRED, "The name of the {$this->fileType}"); } From 4870984c7589427ad810b721e06e551bce830e08 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 17:01:58 +0800 Subject: [PATCH 40/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0934ace..6dfcf65 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,10 @@ } }, "scripts": { - "lint": "vendor/bin/phpstan analyse" + "post-autoload-dump": "@prepare", + "prepare": "@php vendor/bin/testbench package:discover --ansi", + "lint": "@php vendor/bin/phpstan analyse", + "test": "@php vendor/bin/phpunit -c ./ --color" }, "minimum-stability": "dev" } From 59e4a4ced817a72b6a7d443692fdb6ae82853497 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 17:03:01 +0800 Subject: [PATCH 41/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Commands/Generator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 8e4d4a9..469419a 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -65,8 +65,8 @@ protected function configure() { $this->ignoreValidationErrors(); - $this->setName($this->getName()) - ->setDescription($this->getDescription()) + $this->setName($this->name) + ->setDescription($this->description) ->addArgument('name', InputArgument::REQUIRED, "The name of the {$this->fileType}"); } From 8d01a234d669ffe2115291b061643285353a374f Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 17:04:34 +0800 Subject: [PATCH 42/51] wip Signed-off-by: Mior Muhammad Zaki --- .../workflows/{analyse.yml => analyse.yaml} | 6 +-- .../{coveralls.yml => coveralls.yaml} | 6 +-- .github/workflows/experimental-tests.yml | 42 ------------------- .github/workflows/{tests.yml => tests.yaml} | 8 ++-- 4 files changed, 10 insertions(+), 52 deletions(-) rename .github/workflows/{analyse.yml => analyse.yaml} (90%) rename .github/workflows/{coveralls.yml => coveralls.yaml} (92%) delete mode 100644 .github/workflows/experimental-tests.yml rename .github/workflows/{tests.yml => tests.yaml} (93%) diff --git a/.github/workflows/analyse.yml b/.github/workflows/analyse.yaml similarity index 90% rename from .github/workflows/analyse.yml rename to .github/workflows/analyse.yaml index 5880cc2..682f248 100644 --- a/.github/workflows/analyse.yml +++ b/.github/workflows/analyse.yaml @@ -13,7 +13,7 @@ jobs: os: - "ubuntu-latest" php: - - "8.0" + - 8.1 dependencies: - "locked" experimental: @@ -23,7 +23,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -33,7 +33,7 @@ jobs: coverage: none - name: Install dependencies - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v2" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "--prefer-dist --no-cache" diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yaml similarity index 92% rename from .github/workflows/coveralls.yml rename to .github/workflows/coveralls.yaml index a4b9984..c48fa97 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yaml @@ -13,7 +13,7 @@ jobs: os: - "ubuntu-latest" php: - - "7.3" + - 8.1 dependencies: - "locked" laravel: @@ -25,7 +25,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -35,7 +35,7 @@ jobs: coverage: xdebug - name: Install dependencies - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v2" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "--prefer-dist" diff --git a/.github/workflows/experimental-tests.yml b/.github/workflows/experimental-tests.yml deleted file mode 100644 index fd7cdcf..0000000 --- a/.github/workflows/experimental-tests.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: experimental-tests - -on: - push: - -jobs: - experimental-php-test: - runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.experimental }} - strategy: - matrix: - os: - - "ubuntu-latest" - php: - - "8.2" - dependencies: - - "highest" - - "locked" - experimental: - - true - - name: PHP${{ matrix.php }} on ${{ matrix.os }} (${{ matrix.dependencies }}) - - steps: - - name: Checkout code - uses: actions/checkout@v1 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, intl, fileinfo - coverage: none - - - name: Install dependencies - uses: "ramsey/composer-install@v1" - with: - dependency-versions: "${{ matrix.dependencies }}" - composer-options: "--prefer-dist --no-cache" - - - name: Execute tests - run: vendor/bin/phpunit diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yaml similarity index 93% rename from .github/workflows/tests.yml rename to .github/workflows/tests.yaml index 0370ef1..1957190 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yaml @@ -15,10 +15,10 @@ jobs: os: - "ubuntu-latest" php: - - "7.3" - - "7.4" - - "8.0" - - "8.1" + - 7.3 + - 7.4 + - '8.0' + - 8.1 dependencies: - "locked" - "lowest" From be92116375d3266cf07d9ee0af44fbf516bbd09f Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 17:19:17 +0800 Subject: [PATCH 43/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 6dfcf65..26267c4 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,9 @@ "nunomaduro/larastan": "^1.0.1", "orchestra/testbench": "^6.22" }, + "conflict": { + "orchestra/testbench-core": "<6.32.0" + }, "config": { "sort-packages": true }, From 79e21eb7fd78a218596cce2dabaca51c41e5327d Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 19:01:33 +0800 Subject: [PATCH 44/51] wip Signed-off-by: Mior Muhammad Zaki --- .gitignore | 1 + src/Commands/Generator.php | 8 ++++++++ src/Contracts/GeneratesCodeListener.php | 5 +++++ src/GeneratesCode.php | 4 +++- src/Presets/Preset.php | 18 +++++++++++++++++- 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 09b6cda..fbcf30f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ vendor/* # PHPUnit /coverage/* +/.phpunit.cache /.phpunit.result.cache diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 469419a..79b1a77 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -104,6 +104,14 @@ public function codeHasBeenGenerated(string $className): int return 0; } + /** + * Run after code successfully generated. + */ + public function afterCodeHasBeenGenerated(string $className, string $path) + { + // + } + /** * Get the published stub file for the generator. */ diff --git a/src/Contracts/GeneratesCodeListener.php b/src/Contracts/GeneratesCodeListener.php index a940277..54d5e41 100644 --- a/src/Contracts/GeneratesCodeListener.php +++ b/src/Contracts/GeneratesCodeListener.php @@ -18,6 +18,11 @@ public function codeAlreadyExists(string $className); */ public function codeHasBeenGenerated(string $className); + /** + * Run after code successfully generated. + */ + public function afterCodeHasBeenGenerated(string $className, string $path); + /** * Get the stub file for the generator. */ diff --git a/src/GeneratesCode.php b/src/GeneratesCode.php index 2129a9c..0584ba9 100644 --- a/src/GeneratesCode.php +++ b/src/GeneratesCode.php @@ -73,7 +73,9 @@ public function __invoke(bool $force = false) $this->files->put($path, $this->sortImports($this->buildClass($className))); - return $this->listener->codeHasBeenGenerated($className); + return tap($this->listener->codeHasBeenGenerated($className), function ($exitCode) use ($className, $path) { + $this->listener->afterCodeHasBeenGenerated($className, Str::of($path)->after($this->preset->sourcePath())); + }); } /** diff --git a/src/Presets/Preset.php b/src/Presets/Preset.php index 1a47887..8f976ac 100644 --- a/src/Presets/Preset.php +++ b/src/Presets/Preset.php @@ -122,10 +122,26 @@ public function seederPath(): string return sprintf( '%s/%s', $this->basePath(), - $this->config('seeder.path', 'database/seeds') + $this->config('seeder.path', 'database/seeders') ); } + /** + * Database factory namespace. + */ + public function factoryNamespace(): string + { + return $this->config('factory.namespace', 'Database\Factories'); + } + + /** + * Database seeder namespace. + */ + public function seederNamespace(): string + { + return $this->config('seeder.path', 'Database\Seeders'); + } + /** * Sync commands to preset. */ From ad99c025be053444eaff2e9c881794b516c73cb9 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 19:02:59 +0800 Subject: [PATCH 45/51] wip Signed-off-by: Mior Muhammad Zaki --- tests/Feature/CommandsProviderTest.php | 2 +- tests/Unit/Presets/LaravelTest.php | 6 ++++-- tests/Unit/Presets/PackageTest.php | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/Feature/CommandsProviderTest.php b/tests/Feature/CommandsProviderTest.php index e96d1b2..3f9c2b6 100644 --- a/tests/Feature/CommandsProviderTest.php +++ b/tests/Feature/CommandsProviderTest.php @@ -29,6 +29,6 @@ public function it_can_setup_laravel_preset() $this->assertSame("{$directory}/resources", $preset->resourcePath()); $this->assertSame("{$directory}/database/factories", $preset->factoryPath()); $this->assertSame("{$directory}/database/migrations", $preset->migrationPath()); - $this->assertSame("{$directory}/database/seeds", $preset->seederPath()); + $this->assertSame("{$directory}/database/seeders", $preset->seederPath()); } } diff --git a/tests/Unit/Presets/LaravelTest.php b/tests/Unit/Presets/LaravelTest.php index 9cb93bc..5d0dc98 100644 --- a/tests/Unit/Presets/LaravelTest.php +++ b/tests/Unit/Presets/LaravelTest.php @@ -1,6 +1,6 @@ assertSame('App', $preset->rootNamespace()); $this->assertSame('App\Models', $preset->modelNamespace()); $this->assertSame('App\Providers', $preset->providerNamespace()); + $this->assertSame('Database\Factories', $preset->factoryNamespace()); + $this->assertSame('Database\Seeders', $preset->seederNamespace()); $this->assertSame("{$directory}/app", $preset->sourcePath()); $this->assertSame("{$directory}/resources", $preset->resourcePath()); $this->assertSame("{$directory}/database/factories", $preset->factoryPath()); $this->assertSame("{$directory}/database/migrations", $preset->migrationPath()); - $this->assertSame("{$directory}/database/seeds", $preset->seederPath()); + $this->assertSame("{$directory}/database/seeders", $preset->seederPath()); $this->assertFalse($preset->hasCustomStubPath()); $this->assertNull($preset->getCustomStubPath()); diff --git a/tests/Unit/Presets/PackageTest.php b/tests/Unit/Presets/PackageTest.php index 91d84e9..b92ba0d 100644 --- a/tests/Unit/Presets/PackageTest.php +++ b/tests/Unit/Presets/PackageTest.php @@ -1,6 +1,6 @@ assertSame('FooBar', $preset->rootNamespace()); $this->assertSame('FooBar', $preset->modelNamespace()); $this->assertSame('FooBar', $preset->providerNamespace()); + $this->assertSame('Database\Factories', $preset->factoryNamespace()); + $this->assertSame('Database\Seeders', $preset->seederNamespace()); $this->assertSame("{$directory}/src", $preset->sourcePath()); $this->assertSame("{$directory}/resources", $preset->resourcePath()); $this->assertSame("{$directory}/database/factories", $preset->factoryPath()); $this->assertSame("{$directory}/database/migrations", $preset->migrationPath()); - $this->assertSame("{$directory}/database/seeds", $preset->seederPath()); + $this->assertSame("{$directory}/database/seeders", $preset->seederPath()); $this->assertFalse($preset->hasCustomStubPath()); $this->assertNull($preset->getCustomStubPath()); From e6d0cb642d3e40459d3f656ad8e15938a6028803 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 19:04:13 +0800 Subject: [PATCH 46/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 7 ++++++- src/Commands/Generator.php | 2 ++ src/Contracts/GeneratesCodeListener.php | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 26267c4..761475b 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,12 @@ "post-autoload-dump": "@prepare", "prepare": "@php vendor/bin/testbench package:discover --ansi", "lint": "@php vendor/bin/phpstan analyse", - "test": "@php vendor/bin/phpunit -c ./ --color" + "test": "@php vendor/bin/phpunit -c ./ --color", + "ci": [ + "@prepare", + "@lint", + "@test" + ] }, "minimum-stability": "dev" } diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index 79b1a77..7235663 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -106,6 +106,8 @@ public function codeHasBeenGenerated(string $className): int /** * Run after code successfully generated. + * + * @return void */ public function afterCodeHasBeenGenerated(string $className, string $path) { diff --git a/src/Contracts/GeneratesCodeListener.php b/src/Contracts/GeneratesCodeListener.php index 54d5e41..c1f5bce 100644 --- a/src/Contracts/GeneratesCodeListener.php +++ b/src/Contracts/GeneratesCodeListener.php @@ -20,6 +20,8 @@ public function codeHasBeenGenerated(string $className); /** * Run after code successfully generated. + * + * @return void */ public function afterCodeHasBeenGenerated(string $className, string $path); From cb721f7b1a25b063117b2af8a74da0a700cd8ca5 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 20:12:10 +0800 Subject: [PATCH 47/51] wip Signed-off-by: Mior Muhammad Zaki --- src/Presets/Preset.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Presets/Preset.php b/src/Presets/Preset.php index 15dda32..b1d316c 100644 --- a/src/Presets/Preset.php +++ b/src/Presets/Preset.php @@ -59,6 +59,14 @@ public function basePath(): string return $this->basePath; } + /** + * Get the path to the base working directory. + */ + public function vendorPath(): string + { + return "{$this->basePath}/vendor"; + } + /** * Get the path to the resource directory. */ From 27fa84f88475729e9fac4378022c9b8c4b990f7a Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 20:23:21 +0800 Subject: [PATCH 48/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 4 ++-- phpstan.neon.dist | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 761475b..b3e187d 100644 --- a/composer.json +++ b/composer.json @@ -29,8 +29,8 @@ "illuminate/filesystem": "^8.75" }, "require-dev": { - "nunomaduro/larastan": "^1.0.1", - "orchestra/testbench": "^6.22" + "orchestra/testbench": "^6.22", + "phpstan/phpstan": "^1.10.6" }, "conflict": { "orchestra/testbench-core": "<6.32.0" diff --git a/phpstan.neon.dist b/phpstan.neon.dist index dcaf9ec..4db19cb 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,4 @@ includes: - - ./vendor/nunomaduro/larastan/extension.neon - parameters: paths: From 63a96f79e8cd3952e7717e23fee457be30d96e31 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 20:24:48 +0800 Subject: [PATCH 49/51] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b3e187d..886cdd4 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "illuminate/filesystem": "^8.75" }, "require-dev": { - "orchestra/testbench": "^6.22", + "orchestra/testbench": "^6.32", "phpstan/phpstan": "^1.10.6" }, "conflict": { From 486a3899a720508e1373bb88905687f4f60e34e9 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 20:28:06 +0800 Subject: [PATCH 50/51] wip Signed-off-by: Mior Muhammad Zaki --- phpstan.neon.dist | 4 ++-- pint.json | 15 +++++++++++++++ src/Presets/Preset.php | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 pint.json diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 4db19cb..263d7ad 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,6 +7,6 @@ parameters: # The level 8 is the highest level level: 7 + checkGenericClassInNonGenericObjectType: false checkMissingIterableValueType: false - noUnnecessaryCollectionCall: false - checkModelProperties: false + treatPhpDocTypesAsCertain: false diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..628bd22 --- /dev/null +++ b/pint.json @@ -0,0 +1,15 @@ +{ + "preset": "laravel", + "rules": { + "native_function_invocation": { + "include": ["@compiler_optimized"], + "scope": "namespaced", + "strict": true + }, + "no_superfluous_phpdoc_tags": false, + "php_unit_method_casing": false, + "nullable_type_declaration_for_default_null_value": { + "use_nullable_type_declaration": true + } + } +} diff --git a/src/Presets/Preset.php b/src/Presets/Preset.php index 8f976ac..ca5475c 100644 --- a/src/Presets/Preset.php +++ b/src/Presets/Preset.php @@ -53,7 +53,7 @@ public function is(string $name): bool * @param mixed|null $default * @return mixed */ - public function config(string $key = null, $default = null) + public function config(?string $key = null, $default = null) { if (\is_null($key)) { return $this->config; From 0bd49827edadc649411c803d2ddd7e824be53835 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 21 Aug 2023 20:31:08 +0800 Subject: [PATCH 51/51] wip Signed-off-by: Mior Muhammad Zaki --- phpstan-baseline.neon | 6 ++++++ phpstan.neon.dist | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 phpstan-baseline.neon diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..d60fac4 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,6 @@ +parameters: + ignoreErrors: + - + message: "#^Call to an undefined method Illuminate\\\\Contracts\\\\Container\\\\Container\\:\\:basePath\\(\\)\\.$#" + count: 1 + path: src/LaravelServiceProvider.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 263d7ad..bfd81a8 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,4 +1,6 @@ includes: + - ./phpstan-baseline.neon + parameters: paths: