From a25e5a58a43b5ac6d5b49135affb4b89c826864e Mon Sep 17 00:00:00 2001 From: codepuncher Date: Wed, 28 Feb 2024 11:35:23 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8E=A8=20add=20type=20hints=20to=20`a?= =?UTF-8?q?ssets`=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Block.php | 7 ++----- src/Console/UpgradeCommand.php | 7 ++++--- src/Console/stubs/block.construct.stub | 2 +- src/Console/stubs/block.stub | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Block.php b/src/Block.php index 172f6388..6d55be24 100644 --- a/src/Block.php +++ b/src/Block.php @@ -241,7 +241,7 @@ abstract class Block extends Composer implements BlockContract * * @return void * - * @deprecated Use `assets($block)` instead. + * @deprecated Use `assets(array $block): void` instead. */ public function enqueue() { @@ -250,11 +250,8 @@ public function enqueue() /** * Assets enqueued when rendering the block. - * - * @param array $block - * @return void */ - public function assets($block) + public function assets(array $block): void { // } diff --git a/src/Console/UpgradeCommand.php b/src/Console/UpgradeCommand.php index a578a93c..d7f26017 100644 --- a/src/Console/UpgradeCommand.php +++ b/src/Console/UpgradeCommand.php @@ -42,9 +42,10 @@ public function handle() $this->replacements = [ 'use StoutLogic\\AcfBuilder\\FieldsBuilder;' => 'use Log1x\\AcfComposer\\Builder;', 'new FieldsBuilder(' => 'Builder::make(', - 'public function enqueue($block)' => 'public function assets($block)', - 'public function enqueue($block = [])' => 'public function assets($block)', - 'public function enqueue()' => 'public function assets($block)', + 'public function assets($block)' => 'public function assets(array $block)', + 'public function enqueue($block)' => 'public function assets(array $block)', + 'public function enqueue($block = [])' => 'public function assets(array $block)', + 'public function enqueue()' => 'public function assets(array $block)', '/->addFields\(\$this->get\((.*?)\)\)/' => fn ($match) => "->addPartial({$match[1]})", ]; diff --git a/src/Console/stubs/block.construct.stub b/src/Console/stubs/block.construct.stub index e3bcaa6c..c9049973 100644 --- a/src/Console/stubs/block.construct.stub +++ b/src/Console/stubs/block.construct.stub @@ -200,7 +200,7 @@ class DummyClass extends Block * @param array $block * @return void */ - public function assets($block) + public function assets(array $block): void { // } diff --git a/src/Console/stubs/block.stub b/src/Console/stubs/block.stub index 15ace2f7..74376405 100644 --- a/src/Console/stubs/block.stub +++ b/src/Console/stubs/block.stub @@ -197,7 +197,7 @@ class DummyClass extends Block * @param array $block * @return void */ - public function assets($block) + public function assets(array $block): void { // } From 9beee882dcaffa38bc993449491a71e24f783e1e Mon Sep 17 00:00:00 2001 From: codepuncher Date: Wed, 28 Feb 2024 13:38:50 +0000 Subject: [PATCH 2/2] remove superfluous docblock hints from stubs --- src/Console/stubs/block.construct.stub | 3 --- src/Console/stubs/block.stub | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/Console/stubs/block.construct.stub b/src/Console/stubs/block.construct.stub index c9049973..654b569c 100644 --- a/src/Console/stubs/block.construct.stub +++ b/src/Console/stubs/block.construct.stub @@ -196,9 +196,6 @@ class DummyClass extends Block /** * Assets enqueued when rendering the block. - * - * @param array $block - * @return void */ public function assets(array $block): void { diff --git a/src/Console/stubs/block.stub b/src/Console/stubs/block.stub index 74376405..e2f62974 100644 --- a/src/Console/stubs/block.stub +++ b/src/Console/stubs/block.stub @@ -193,9 +193,6 @@ class DummyClass extends Block /** * Assets enqueued when rendering the block. - * - * @param array $block - * @return void */ public function assets(array $block): void {