From 7135f6d469ced1315b90952f0b47077a5f9712c8 Mon Sep 17 00:00:00 2001 From: Juan Tejera Date: Wed, 3 Jan 2024 14:58:48 -0300 Subject: [PATCH 1/3] feat: modify stubs to declare strict types --- cspell.json | 3 + stubs/cast.inbound.stub | 21 +++++++ stubs/cast.stub | 31 ++++++++++ stubs/console.stub | 32 ++++++++++ stubs/controller.api.stub | 51 ++++++++++++++++ stubs/controller.invokable.stub | 19 ++++++ stubs/controller.model.api.stub | 52 ++++++++++++++++ stubs/controller.model.stub | 68 +++++++++++++++++++++ stubs/controller.nested.api.stub | 53 +++++++++++++++++ stubs/controller.nested.singleton.api.stub | 45 ++++++++++++++ stubs/controller.nested.singleton.stub | 61 +++++++++++++++++++ stubs/controller.nested.stub | 69 ++++++++++++++++++++++ stubs/controller.plain.stub | 13 ++++ stubs/controller.singleton.api.stub | 43 ++++++++++++++ stubs/controller.singleton.stub | 59 ++++++++++++++++++ stubs/controller.stub | 67 +++++++++++++++++++++ stubs/event.stub | 38 ++++++++++++ stubs/factory.stub | 25 ++++++++ stubs/job.queued.stub | 33 +++++++++++ stubs/job.stub | 28 +++++++++ stubs/mail.stub | 55 +++++++++++++++++ stubs/markdown-mail.stub | 55 +++++++++++++++++ stubs/markdown-notification.stub | 53 +++++++++++++++++ stubs/middleware.stub | 22 +++++++ stubs/migration.create.stub | 29 +++++++++ stubs/migration.stub | 26 ++++++++ stubs/migration.update.stub | 30 ++++++++++ stubs/model.pivot.stub | 12 ++++ stubs/model.stub | 13 ++++ stubs/notification.stub | 56 ++++++++++++++++++ stubs/observer.plain.stub | 10 ++++ stubs/observer.stub | 50 ++++++++++++++++ stubs/policy.plain.stub | 18 ++++++ stubs/policy.stub | 68 +++++++++++++++++++++ stubs/provider.stub | 26 ++++++++ stubs/request.stub | 30 ++++++++++ stubs/resource-collection.stub | 21 +++++++ stubs/resource.stub | 21 +++++++ stubs/rule.stub | 21 +++++++ stubs/scope.stub | 20 +++++++ stubs/seeder.stub | 19 ++++++ stubs/test.stub | 22 +++++++ stubs/test.unit.stub | 18 ++++++ stubs/view-component.stub | 28 +++++++++ 44 files changed, 1534 insertions(+) create mode 100644 stubs/cast.inbound.stub create mode 100644 stubs/cast.stub create mode 100644 stubs/console.stub create mode 100644 stubs/controller.api.stub create mode 100644 stubs/controller.invokable.stub create mode 100644 stubs/controller.model.api.stub create mode 100644 stubs/controller.model.stub create mode 100644 stubs/controller.nested.api.stub create mode 100644 stubs/controller.nested.singleton.api.stub create mode 100644 stubs/controller.nested.singleton.stub create mode 100644 stubs/controller.nested.stub create mode 100644 stubs/controller.plain.stub create mode 100644 stubs/controller.singleton.api.stub create mode 100644 stubs/controller.singleton.stub create mode 100644 stubs/controller.stub create mode 100644 stubs/event.stub create mode 100644 stubs/factory.stub create mode 100644 stubs/job.queued.stub create mode 100644 stubs/job.stub create mode 100644 stubs/mail.stub create mode 100644 stubs/markdown-mail.stub create mode 100644 stubs/markdown-notification.stub create mode 100644 stubs/middleware.stub create mode 100644 stubs/migration.create.stub create mode 100644 stubs/migration.stub create mode 100644 stubs/migration.update.stub create mode 100644 stubs/model.pivot.stub create mode 100644 stubs/model.stub create mode 100644 stubs/notification.stub create mode 100644 stubs/observer.plain.stub create mode 100644 stubs/observer.stub create mode 100644 stubs/policy.plain.stub create mode 100644 stubs/policy.stub create mode 100644 stubs/provider.stub create mode 100644 stubs/request.stub create mode 100644 stubs/resource-collection.stub create mode 100644 stubs/resource.stub create mode 100644 stubs/rule.stub create mode 100644 stubs/scope.stub create mode 100644 stubs/seeder.stub create mode 100644 stubs/test.stub create mode 100644 stubs/test.unit.stub create mode 100644 stubs/view-component.stub diff --git a/cspell.json b/cspell.json index ecb5f8fe71f..4ef02db81aa 100644 --- a/cspell.json +++ b/cspell.json @@ -11,6 +11,9 @@ "vendor" ], "words": [ + "Dispatchable", + "Queueable", + "Mailables", "autoload", "Autoloaded", "autoloading", diff --git a/stubs/cast.inbound.stub b/stubs/cast.inbound.stub new file mode 100644 index 00000000000..1567dcccc81 --- /dev/null +++ b/stubs/cast.inbound.stub @@ -0,0 +1,21 @@ + $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } +} diff --git a/stubs/cast.stub b/stubs/cast.stub new file mode 100644 index 00000000000..0e9e01b80ae --- /dev/null +++ b/stubs/cast.stub @@ -0,0 +1,31 @@ + $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return $value; + } +} diff --git a/stubs/console.stub b/stubs/console.stub new file mode 100644 index 00000000000..a8b0ab65472 --- /dev/null +++ b/stubs/console.stub @@ -0,0 +1,32 @@ + + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('channel-name'), + ]; + } +} diff --git a/stubs/factory.stub b/stubs/factory.stub new file mode 100644 index 00000000000..0c32253dc75 --- /dev/null +++ b/stubs/factory.stub @@ -0,0 +1,25 @@ + + */ +class {{ factory }}Factory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/stubs/job.queued.stub b/stubs/job.queued.stub new file mode 100644 index 00000000000..d0a8943e7f8 --- /dev/null +++ b/stubs/job.queued.stub @@ -0,0 +1,33 @@ + + */ + public function attachments(): array + { + return []; + } +} diff --git a/stubs/markdown-mail.stub b/stubs/markdown-mail.stub new file mode 100644 index 00000000000..30fa2c3420b --- /dev/null +++ b/stubs/markdown-mail.stub @@ -0,0 +1,55 @@ + + */ + public function attachments(): array + { + return []; + } +} diff --git a/stubs/markdown-notification.stub b/stubs/markdown-notification.stub new file mode 100644 index 00000000000..eb550a23f91 --- /dev/null +++ b/stubs/markdown-notification.stub @@ -0,0 +1,53 @@ + + */ + public function via(object $notifiable): array + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + */ + public function toMail(object $notifiable): MailMessage + { + return (new MailMessage)->markdown('{{ view }}'); + } + + /** + * Get the array representation of the notification. + * + * @return array + */ + public function toArray(object $notifiable): array + { + return [ + // + ]; + } +} diff --git a/stubs/middleware.stub b/stubs/middleware.stub new file mode 100644 index 00000000000..51963f565ed --- /dev/null +++ b/stubs/middleware.stub @@ -0,0 +1,22 @@ +id(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('{{ table }}'); + } +}; diff --git a/stubs/migration.stub b/stubs/migration.stub new file mode 100644 index 00000000000..bcc4ece924f --- /dev/null +++ b/stubs/migration.stub @@ -0,0 +1,26 @@ + + */ + public function via(object $notifiable): array + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + */ + public function toMail(object $notifiable): MailMessage + { + return (new MailMessage) + ->line('The introduction to the notification.') + ->action('Notification Action', url('/')) + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + * + * @return array + */ + public function toArray(object $notifiable): array + { + return [ + // + ]; + } +} diff --git a/stubs/observer.plain.stub b/stubs/observer.plain.stub new file mode 100644 index 00000000000..75018a9e33b --- /dev/null +++ b/stubs/observer.plain.stub @@ -0,0 +1,10 @@ +|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/stubs/resource-collection.stub b/stubs/resource-collection.stub new file mode 100644 index 00000000000..8630b988295 --- /dev/null +++ b/stubs/resource-collection.stub @@ -0,0 +1,21 @@ + + */ + public function toArray(Request $request): array + { + return parent::toArray($request); + } +} diff --git a/stubs/resource.stub b/stubs/resource.stub new file mode 100644 index 00000000000..529838dc092 --- /dev/null +++ b/stubs/resource.stub @@ -0,0 +1,21 @@ + + */ + public function toArray(Request $request): array + { + return parent::toArray($request); + } +} diff --git a/stubs/rule.stub b/stubs/rule.stub new file mode 100644 index 00000000000..d5393b0195a --- /dev/null +++ b/stubs/rule.stub @@ -0,0 +1,21 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/stubs/test.unit.stub b/stubs/test.unit.stub new file mode 100644 index 00000000000..ad07c563047 --- /dev/null +++ b/stubs/test.unit.stub @@ -0,0 +1,18 @@ +assertTrue(true); + } +} diff --git a/stubs/view-component.stub b/stubs/view-component.stub new file mode 100644 index 00000000000..235d7b2f28e --- /dev/null +++ b/stubs/view-component.stub @@ -0,0 +1,28 @@ + Date: Wed, 3 Jan 2024 15:38:42 -0300 Subject: [PATCH 2/3] ref: words sort in ascending order --- cspell.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cspell.json b/cspell.json index 4ef02db81aa..3a2df0a7932 100644 --- a/cspell.json +++ b/cspell.json @@ -11,9 +11,6 @@ "vendor" ], "words": [ - "Dispatchable", - "Queueable", - "Mailables", "autoload", "Autoloaded", "autoloading", @@ -24,6 +21,7 @@ "clsx", "DBAL", "Debugbar", + "Dispatchable", "docblocks", "EHLO", "Encrypter", @@ -42,6 +40,7 @@ "LIVEWIRE", "macvim", "magento", + "Mailables", "mailgun", "Mailpit", "medtech", @@ -55,7 +54,6 @@ "Npkj", "Nuno", "nunomaduro", - "roundrobin", "PAPERTRAIL", "Parens", "passw", @@ -63,6 +61,8 @@ "Phpstan", "phpstorm", "phpunit", + "Queueable", + "roundrobin", "sasl", "Slevomat", "sqlanywhere", From d7260baf3ac36c44d41d4b14304132192ef4654e Mon Sep 17 00:00:00 2001 From: Juan Tejera Date: Wed, 3 Jan 2024 15:44:18 -0300 Subject: [PATCH 3/3] fix: add missing semicolon --- stubs/cast.inbound.stub | 2 +- stubs/cast.stub | 2 +- stubs/console.stub | 2 +- stubs/controller.api.stub | 2 +- stubs/controller.invokable.stub | 2 +- stubs/controller.model.api.stub | 2 +- stubs/controller.model.stub | 2 +- stubs/controller.nested.api.stub | 2 +- stubs/controller.nested.singleton.api.stub | 2 +- stubs/controller.nested.singleton.stub | 2 +- stubs/controller.nested.stub | 2 +- stubs/controller.plain.stub | 2 +- stubs/controller.singleton.api.stub | 2 +- stubs/controller.singleton.stub | 2 +- stubs/controller.stub | 2 +- stubs/event.stub | 2 +- stubs/factory.stub | 2 +- stubs/job.queued.stub | 2 +- stubs/job.stub | 2 +- stubs/mail.stub | 2 +- stubs/markdown-mail.stub | 2 +- stubs/markdown-notification.stub | 2 +- stubs/middleware.stub | 2 +- stubs/migration.create.stub | 2 +- stubs/migration.stub | 2 +- stubs/migration.update.stub | 2 +- stubs/model.pivot.stub | 2 +- stubs/model.stub | 2 +- stubs/notification.stub | 2 +- stubs/observer.plain.stub | 2 +- stubs/observer.stub | 2 +- stubs/policy.plain.stub | 2 +- stubs/policy.stub | 2 +- stubs/provider.stub | 2 +- stubs/request.stub | 2 +- stubs/resource-collection.stub | 2 +- stubs/resource.stub | 2 +- stubs/rule.stub | 2 +- stubs/scope.stub | 2 +- stubs/seeder.stub | 2 +- stubs/test.stub | 2 +- stubs/test.unit.stub | 2 +- stubs/view-component.stub | 2 +- 43 files changed, 43 insertions(+), 43 deletions(-) diff --git a/stubs/cast.inbound.stub b/stubs/cast.inbound.stub index 1567dcccc81..dc17eb11fa2 100644 --- a/stubs/cast.inbound.stub +++ b/stubs/cast.inbound.stub @@ -1,6 +1,6 @@