From 834d205c0e0b2c04c8609d5aec3f6abd3065c04d Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Thu, 9 May 2024 11:31:23 +0100 Subject: [PATCH 1/7] ci: remove old artifacts --- .github/workflows/ci.yml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a74e714..3b78953 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -159,18 +159,17 @@ jobs: path: src/ standard: phpcs.xml -# TODO: Figure this one out: -# remove_old_artifacts: -# runs-on: ubuntu-latest -# -# steps: -# - name: Remove old artifacts for prior workflow runs on this repository -# env: -# GH_TOKEN: ${{ github.token }} -# run: | -# gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt -# while read id -# do -# echo -n "Deleting artifact ID $id ... " -# gh api --method DELETE /repos/${{ github.repository }}/actions/artifacts/$id && echo "Done" -# done artifact-id-list.txt + while read id + do + echo -n "Deleting artifact ID $id ... " + gh api --method DELETE /repos/${{ github.repository }}/actions/artifacts/$id && echo "Done" + done Date: Mon, 10 Feb 2025 14:35:53 +0000 Subject: [PATCH 2/7] ci: run all php versions --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b78953..dff0d36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,13 +7,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ 8.1, 8.2, 8.3 ] + php: [ 8.1, 8.2, 8.3, 8.4 ] steps: - uses: actions/checkout@v4 - name: Cache Composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: /tmp/composer-cache key: ${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }} @@ -37,7 +37,7 @@ jobs: needs: [ composer ] strategy: matrix: - php: [ 8.1, 8.2, 8.3 ] + php: [ 8.1, 8.2, 8.3, 8.4 ] outputs: coverage: ${{ steps.store-coverage.outputs.coverage_text }} @@ -52,7 +52,7 @@ jobs: run: tar -xvf /tmp/github-actions/build.tar ./ - name: PHP Unit tests - uses: php-actions/phpunit@v3 + uses: php-actions/phpunit@v4 env: XDEBUG_MODE: cover with: @@ -73,7 +73,7 @@ jobs: needs: [ phpunit ] strategy: matrix: - php: [ 8.1, 8.2, 8.3 ] + php: [ 8.1, 8.2, 8.3, 8.4 ] steps: - uses: actions/download-artifact@v4 @@ -94,7 +94,7 @@ jobs: needs: [ composer ] strategy: matrix: - php: [ 8.1, 8.2, 8.3 ] + php: [ 8.1, 8.2, 8.3, 8.4 ] steps: - uses: actions/download-artifact@v4 @@ -117,7 +117,7 @@ jobs: needs: [ composer ] strategy: matrix: - php: [ 8.1, 8.2, 8.3 ] + php: [ 8.1, 8.2, 8.3, 8.4 ] steps: - uses: actions/download-artifact@v4 @@ -141,7 +141,7 @@ jobs: needs: [ composer ] strategy: matrix: - php: [ 8.1, 8.2, 8.3 ] + php: [ 8.1, 8.2, 8.3, 8.4 ] steps: - uses: actions/download-artifact@v4 From 74e934005107bc487f5c0a1cdf05f8126f460be4 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Thu, 13 Feb 2025 11:41:03 +0000 Subject: [PATCH 3/7] deprecate: all with functions on the Input class for #301 --- src/Input.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Input.php b/src/Input.php index f6fe5c1..9b4557a 100644 --- a/src/Input.php +++ b/src/Input.php @@ -235,7 +235,7 @@ public function when(array|string...$matches):Trigger { /** * Return a Trigger that will only pass the provided keys to its callback. */ - public function with(string...$keys):Trigger { + public function select(string...$keys):Trigger { foreach($keys as $key) { if(!$this->parameters->contains($key)) { throw new MissingInputParameterException($key); @@ -244,21 +244,33 @@ public function with(string...$keys):Trigger { return $this->newTrigger("with", ...$keys); } + #[\Deprecated("Use select() instead to avoid ambiguity with immutable `with` functions")] + public function with(string...$keys):Trigger { + return $this->select(...$keys); + } /** * Return a Trigger that will pass all keys apart from the provided * keys to its callback. */ - public function without(string...$keys):Trigger { + public function selectAllExcept(string...$keys):Trigger { return $this->newTrigger("without", ...$keys); } + #[\Deprecated("Use selectAllExcept() instead to avoid ambiguity with immutable `with` functions")] + public function without(string...$keys):Trigger { + return $this->selectAllExcept(...$keys); + } /** * Return a Trigger that will pass all keys to its callback. */ - public function withAll():Trigger { + public function selectAll():Trigger { return $this->newTrigger("withAll"); } + #[\Deprecated("Use selectAll() instead to avoid ambiguity with immutable `with` functions")] + public function withAll():Trigger { + return $this->selectAll(); + } protected function newTrigger(string $functionName, string...$args):Trigger { $trigger = new Trigger($this); From c59f68c43d8482ba56f600eb7b0ead1fa3244bcb Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Thu, 13 Feb 2025 11:43:59 +0000 Subject: [PATCH 4/7] deprecate: all with functions on the Trigger class for #301 --- src/Trigger/Trigger.php | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Trigger/Trigger.php b/src/Trigger/Trigger.php index 82e1212..d4ecb92 100644 --- a/src/Trigger/Trigger.php +++ b/src/Trigger/Trigger.php @@ -13,9 +13,9 @@ class Trigger { /** @var array */ protected array $keyMatches; /** @var array */ - protected array $with; + protected array $select; /** @var array */ - protected array $without; + protected array $selectAllExcept; /** @var array */ protected array $callbacks; protected ?bool $hasFired; @@ -27,8 +27,8 @@ public function __construct(Input $input) { $this->matches = []; $this->keyMatches = []; - $this->with = []; - $this->without = []; + $this->select = []; + $this->selectAllExcept = []; $this->callbacks = []; $this->hasFired = null; } @@ -49,28 +49,40 @@ public function when(string|array...$matches):self { return $this; } - public function with(string...$keys):self { + public function select(string...$keys):self { foreach($keys as $key) { - $this->with []= $key; + $this->select []= $key; } return $this; } + #[\Deprecated("Use select() instead to avoid ambiguity with immutable `with` functions")] + public function with(string...$keys):self { + return $this->select(...$keys); + } - public function without(string...$keys):self { + public function selectAllExcept(string...$keys):self { foreach($keys as $key) { - $this->without []= $key; + $this->selectAllExcept []= $key; } return $this; } + #[\Deprecated("Use selectAllExcept() instead to avoid ambiguity with immutable `with` functions")] + public function without(string...$keys):self { + return $this->selectAllExcept(...$keys); + } - public function withAll():self { - $this->with = []; - $this->without = []; + public function selectAll():self { + $this->select = []; + $this->selectAllExcept = []; return $this; } + #[\Deprecated("Use selectAll() instead to avoid ambiguity with immutable `with` functions")] + public function withAll():self { + return $this->selectAll(); + } public function setTrigger(string $key, string $value):self { if(!isset($this->matches[$key])) { @@ -142,8 +154,8 @@ public function fire():bool { protected function callCallbacks():void { $fields = $this->inputDataFactory->create( $this->input, - $this->with, - $this->without + $this->select, + $this->selectAllExcept ); foreach($this->callbacks as $callback) { From b01434f1abe4eeda7580cc9770d66e6f4205d8e9 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Thu, 13 Feb 2025 11:53:41 +0000 Subject: [PATCH 5/7] tweak: deprecate pre-8.4 attribute --- src/Input.php | 7 ++++--- src/Trigger/Trigger.php | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Input.php b/src/Input.php index 9b4557a..202115f 100644 --- a/src/Input.php +++ b/src/Input.php @@ -244,7 +244,8 @@ public function select(string...$keys):Trigger { return $this->newTrigger("with", ...$keys); } - #[\Deprecated("Use select() instead to avoid ambiguity with immutable `with` functions")] + + /** @deprecated Use select() instead to avoid ambiguity with immutable `with` functions */ public function with(string...$keys):Trigger { return $this->select(...$keys); } @@ -256,7 +257,7 @@ public function with(string...$keys):Trigger { public function selectAllExcept(string...$keys):Trigger { return $this->newTrigger("without", ...$keys); } - #[\Deprecated("Use selectAllExcept() instead to avoid ambiguity with immutable `with` functions")] + /** @deprecated Use selectAllExcept() instead to avoid ambiguity with immutable `with` functions */ public function without(string...$keys):Trigger { return $this->selectAllExcept(...$keys); } @@ -267,7 +268,7 @@ public function without(string...$keys):Trigger { public function selectAll():Trigger { return $this->newTrigger("withAll"); } - #[\Deprecated("Use selectAll() instead to avoid ambiguity with immutable `with` functions")] + /** @deprecated Use selectAll() instead to avoid ambiguity with immutable `with` functions */ public function withAll():Trigger { return $this->selectAll(); } diff --git a/src/Trigger/Trigger.php b/src/Trigger/Trigger.php index d4ecb92..f029730 100644 --- a/src/Trigger/Trigger.php +++ b/src/Trigger/Trigger.php @@ -56,7 +56,7 @@ public function select(string...$keys):self { return $this; } - #[\Deprecated("Use select() instead to avoid ambiguity with immutable `with` functions")] + /** @deprecated Use select() instead to avoid ambiguity with immutable `with` functions */ public function with(string...$keys):self { return $this->select(...$keys); } @@ -68,7 +68,7 @@ public function selectAllExcept(string...$keys):self { return $this; } - #[\Deprecated("Use selectAllExcept() instead to avoid ambiguity with immutable `with` functions")] + /** @deprecated Use selectAllExcept() instead to avoid ambiguity with immutable `with` functions */ public function without(string...$keys):self { return $this->selectAllExcept(...$keys); } @@ -79,7 +79,7 @@ public function selectAll():self { return $this; } - #[\Deprecated("Use selectAll() instead to avoid ambiguity with immutable `with` functions")] + /** @deprecated Use selectAll() instead to avoid ambiguity with immutable `with` functions */ public function withAll():self { return $this->selectAll(); } From 61431486d32f3933f1be8b7fb11334bc0341ece3 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Thu, 13 Feb 2025 11:58:29 +0000 Subject: [PATCH 6/7] tweak: until deprecations are removed, suppress TooManyPublicMethods --- src/Input.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Input.php b/src/Input.php index 202115f..0c5a71f 100644 --- a/src/Input.php +++ b/src/Input.php @@ -23,6 +23,7 @@ * @implements ArrayAccess * @implements Iterator * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.TooManyPublicMethods) Only until the deprecations are removed */ class Input implements ArrayAccess, Countable, Iterator { use InputValueGetter; From e91124323b50259c58a8cacaa778ee6616631462 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Thu, 13 Feb 2025 14:45:11 +0000 Subject: [PATCH 7/7] tweak: line length --- src/Input.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Input.php b/src/Input.php index 0c5a71f..3ed042c 100644 --- a/src/Input.php +++ b/src/Input.php @@ -23,7 +23,7 @@ * @implements ArrayAccess * @implements Iterator * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @SuppressWarnings(PHPMD.TooManyPublicMethods) Only until the deprecations are removed + * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class Input implements ArrayAccess, Countable, Iterator { use InputValueGetter;