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 0c31ab83df903403339371c008345b8cd7f42991 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Wed, 26 Mar 2025 10:53:34 +0000 Subject: [PATCH 3/7] feature: implement selectPrefix closes #13 --- src/Input.php | 20 +++++++++++++++++++- src/Trigger/NeverTrigger.php | 16 ++++++++++++++++ test/phpunit/InputTest.php | 24 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/Trigger/NeverTrigger.php diff --git a/src/Input.php b/src/Input.php index 3ed042c..10eb55f 100644 --- a/src/Input.php +++ b/src/Input.php @@ -3,6 +3,7 @@ use ArrayAccess; use Countable; +use Gt\Input\Trigger\NeverTrigger; use Gt\Json\JsonDecodeException; use Gt\Json\JsonObject; use Gt\Json\JsonObjectBuilder; @@ -243,7 +244,7 @@ public function select(string...$keys):Trigger { } } - return $this->newTrigger("with", ...$keys); + return $this->newTrigger("select", ...$keys); } /** @deprecated Use select() instead to avoid ambiguity with immutable `with` functions */ @@ -251,6 +252,23 @@ public function with(string...$keys):Trigger { return $this->select(...$keys); } + public function selectPrefix(string $prefix):Trigger { + $keys = []; + + foreach($this->parameters as $key => $param) { + if(str_starts_with($key, $prefix)) { + array_push($keys, $key); + } + } + + if($keys) { + return $this->when(...$keys); + } + else { + return new NeverTrigger($this); + } + } + /** * Return a Trigger that will pass all keys apart from the provided * keys to its callback. diff --git a/src/Trigger/NeverTrigger.php b/src/Trigger/NeverTrigger.php new file mode 100644 index 0000000..68ef526 --- /dev/null +++ b/src/Trigger/NeverTrigger.php @@ -0,0 +1,16 @@ +getInt("id")); } + public function testSelectPrefix_noMatch():void { + $sut = new Input(["id" => 123]); + $trigger = $sut->selectPrefix("io_"); + + $triggered = false; + $trigger->call(function(...$args)use(&$triggered) { + $triggered = true; + }); + $trigger->fire(); + self::assertFalse($triggered); + } + + public function testSelectPrefix_match():void { + $sut = new Input(["id" => 123, "io_database" => "connect"]); + $trigger = $sut->selectPrefix("io_"); + + $triggered = false; + $trigger->call(function(...$args)use(&$triggered) { + $triggered = true; + }); + $trigger->fire(); + self::assertTrue($triggered); + } + public static function dataRandomGetPost():array { $data = []; From d57f4d8db2a37278fb8211bb235a9ec757d3185b Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Wed, 26 Mar 2025 11:17:42 +0000 Subject: [PATCH 4/7] tweak: ignore unused function parameter --- src/Input.php | 2 +- src/Trigger/NeverTrigger.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Input.php b/src/Input.php index 10eb55f..080376f 100644 --- a/src/Input.php +++ b/src/Input.php @@ -255,7 +255,7 @@ public function with(string...$keys):Trigger { public function selectPrefix(string $prefix):Trigger { $keys = []; - foreach($this->parameters as $key => $param) { + foreach(array_keys($this->parameters) as $key) { if(str_starts_with($key, $prefix)) { array_push($keys, $key); } diff --git a/src/Trigger/NeverTrigger.php b/src/Trigger/NeverTrigger.php index 68ef526..742b319 100644 --- a/src/Trigger/NeverTrigger.php +++ b/src/Trigger/NeverTrigger.php @@ -2,10 +2,12 @@ namespace Gt\Input\Trigger; class NeverTrigger extends Trigger { + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter public function call(callable $callback, string ...$args):Trigger { return $this; } + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter public function orCall(callable $callback, string ...$args):Trigger { return $this; } From 8c5a162bb24e773b00584aa287562a94b5d083eb Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Fri, 2 May 2025 12:49:23 +0100 Subject: [PATCH 5/7] build: update dependencies (for gt/http compatibility) --- composer.json | 4 +- composer.lock | 440 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 322 insertions(+), 122 deletions(-) diff --git a/composer.json b/composer.json index 5bc499a..ad1334b 100644 --- a/composer.json +++ b/composer.json @@ -5,8 +5,8 @@ "require": { "php": ">=8.1", - "phpgt/http": "^1.1", - "phpgt/json": "^1.2" + "phpgt/http": "1.*", + "phpgt/json": "^2.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 48ddd31..40100c0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,25 +4,225 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "74675ca63bc6a83c02404557686a1d27", + "content-hash": "2b25525793bab1c67e83d0dc7710d967", "packages": [ + { + "name": "justinrainbow/json-schema", + "version": "6.4.1", + "source": { + "type": "git", + "url": "https://github.com/jsonrainbow/json-schema.git", + "reference": "35d262c94959571e8736db1e5c9bc36ab94ae900" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/35d262c94959571e8736db1e5c9bc36ab94ae900", + "reference": "35d262c94959571e8736db1e5c9bc36ab94ae900", + "shasum": "" + }, + "require": { + "ext-json": "*", + "marc-mabe/php-enum": "^4.0", + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "3.3.0", + "json-schema/json-schema-test-suite": "1.2.0", + "marc-mabe/php-enum-phpstan": "^2.0", + "phpspec/prophecy": "^1.19", + "phpstan/phpstan": "^1.12", + "phpunit/phpunit": "^8.5" + }, + "bin": [ + "bin/validate-json" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.x-dev" + } + }, + "autoload": { + "psr-4": { + "JsonSchema\\": "src/JsonSchema/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" + } + ], + "description": "A library to validate a json schema.", + "homepage": "https://github.com/jsonrainbow/json-schema", + "keywords": [ + "json", + "schema" + ], + "support": { + "issues": "https://github.com/jsonrainbow/json-schema/issues", + "source": "https://github.com/jsonrainbow/json-schema/tree/6.4.1" + }, + "time": "2025-04-04T13:08:07+00:00" + }, + { + "name": "marc-mabe/php-enum", + "version": "v4.7.1", + "source": { + "type": "git", + "url": "https://github.com/marc-mabe/php-enum.git", + "reference": "7159809e5cfa041dca28e61f7f7ae58063aae8ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/marc-mabe/php-enum/zipball/7159809e5cfa041dca28e61f7f7ae58063aae8ed", + "reference": "7159809e5cfa041dca28e61f7f7ae58063aae8ed", + "shasum": "" + }, + "require": { + "ext-reflection": "*", + "php": "^7.1 | ^8.0" + }, + "require-dev": { + "phpbench/phpbench": "^0.16.10 || ^1.0.4", + "phpstan/phpstan": "^1.3.1", + "phpunit/phpunit": "^7.5.20 | ^8.5.22 | ^9.5.11", + "vimeo/psalm": "^4.17.0 | ^5.26.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-3.x": "3.2-dev", + "dev-master": "4.7-dev" + } + }, + "autoload": { + "psr-4": { + "MabeEnum\\": "src/" + }, + "classmap": [ + "stubs/Stringable.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Marc Bennewitz", + "email": "dev@mabe.berlin", + "homepage": "https://mabe.berlin/", + "role": "Lead" + } + ], + "description": "Simple and fast implementation of enumerations with native PHP", + "homepage": "https://github.com/marc-mabe/php-enum", + "keywords": [ + "enum", + "enum-map", + "enum-set", + "enumeration", + "enumerator", + "enummap", + "enumset", + "map", + "set", + "type", + "type-hint", + "typehint" + ], + "support": { + "issues": "https://github.com/marc-mabe/php-enum/issues", + "source": "https://github.com/marc-mabe/php-enum/tree/v4.7.1" + }, + "time": "2024-11-28T04:54:44+00:00" + }, + { + "name": "phpgt/cookie", + "version": "v1.0.3", + "source": { + "type": "git", + "url": "https://github.com/phpgt/Cookie.git", + "reference": "6c80638745ce4538aa397843e7c0b760b60a08c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpgt/Cookie/zipball/6c80638745ce4538aa397843e7c0b760b60a08c5", + "reference": "6c80638745ce4538aa397843e7c0b760b60a08c5", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpmd/phpmd": "^2.13", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.1", + "squizlabs/php_codesniffer": "^3.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Gt\\Cookie\\": "./src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Bowler", + "email": "greg.bowler@g105b.com" + } + ], + "description": "Object oriented cookie handler.", + "support": { + "issues": "https://github.com/phpgt/Cookie/issues", + "source": "https://github.com/phpgt/Cookie/tree/v1.0.3" + }, + "funding": [ + { + "url": "https://github.com/sponsors/PhpGt", + "type": "github" + } + ], + "time": "2025-03-07T17:42:38+00:00" + }, { "name": "phpgt/dataobject", - "version": "v1.0.7", + "version": "v1.1.0", "source": { "type": "git", "url": "https://github.com/PhpGt/DataObject.git", - "reference": "3b05cc3b64a0f2b763c8e550bc6c03b71474cd1a" + "reference": "534b593617e40f62ba5ea5a399797e4b0107a40a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhpGt/DataObject/zipball/3b05cc3b64a0f2b763c8e550bc6c03b71474cd1a", - "reference": "3b05cc3b64a0f2b763c8e550bc6c03b71474cd1a", + "url": "https://api.github.com/repos/PhpGt/DataObject/zipball/534b593617e40f62ba5ea5a399797e4b0107a40a", + "reference": "534b593617e40f62ba5ea5a399797e4b0107a40a", "shasum": "" }, "require": { "ext-json": "*", - "php": ">=8.0", + "php": ">=8.1", "phpgt/typesafegetter": "^1.3" }, "require-dev": { @@ -50,7 +250,7 @@ "description": " Structured, type-safe, immutable data transfer.", "support": { "issues": "https://github.com/PhpGt/DataObject/issues", - "source": "https://github.com/PhpGt/DataObject/tree/v1.0.7" + "source": "https://github.com/PhpGt/DataObject/tree/v1.1.0" }, "funding": [ { @@ -58,33 +258,31 @@ "type": "github" } ], - "time": "2023-07-13T09:45:07+00:00" + "time": "2025-02-14T16:43:15+00:00" }, { "name": "phpgt/http", - "version": "v1.1.9", + "version": "v1.1.2", "source": { "type": "git", "url": "https://github.com/PhpGt/Http.git", - "reference": "05566d327ba99f8d99ef17700f3b94164de8c3d7" + "reference": "80683cebb3c9490f0f7eb71fa5f25cc85a9eb5ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhpGt/Http/zipball/05566d327ba99f8d99ef17700f3b94164de8c3d7", - "reference": "05566d327ba99f8d99ef17700f3b94164de8c3d7", + "url": "https://api.github.com/repos/PhpGt/Http/zipball/80683cebb3c9490f0f7eb71fa5f25cc85a9eb5ed", + "reference": "80683cebb3c9490f0f7eb71fa5f25cc85a9eb5ed", "shasum": "" }, "require": { - "php": ">=8.1", - "phpgt/input": "^v1", - "psr/http-message": "^v1.0.1", - "willdurand/negotiation": "v3.1.0" + "php": ">=7.2", + "phpgt/cookie": "*", + "phpgt/input": "*", + "psr/http-message": "^1.0.1", + "willdurand/negotiation": "^2.3" }, "require-dev": { - "phpmd/phpmd": "^2.13", - "phpstan/phpstan": "^1.9", - "phpunit/phpunit": "^10.0", - "squizlabs/php_codesniffer": "^3.7" + "phpunit/phpunit": "8.*" }, "type": "library", "autoload": { @@ -99,34 +297,29 @@ "description": "PSR-7 HTTP message implementation.", "support": { "issues": "https://github.com/PhpGt/Http/issues", - "source": "https://github.com/PhpGt/Http/tree/v1.1.9" + "source": "https://github.com/PhpGt/Http/tree/v1.1.2" }, - "funding": [ - { - "url": "https://github.com/sponsors/PhpGt", - "type": "github" - } - ], - "time": "2023-03-10T15:04:04+00:00" + "time": "2020-06-16T13:13:25+00:00" }, { "name": "phpgt/json", - "version": "v1.2.1", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/PhpGt/Json.git", - "reference": "8938b374d550bc6114bf1d4e5c1cbe3283868e58" + "reference": "ba557c441a01e32a5040380556ee6e7e59599dfd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhpGt/Json/zipball/8938b374d550bc6114bf1d4e5c1cbe3283868e58", - "reference": "8938b374d550bc6114bf1d4e5c1cbe3283868e58", + "url": "https://api.github.com/repos/PhpGt/Json/zipball/ba557c441a01e32a5040380556ee6e7e59599dfd", + "reference": "ba557c441a01e32a5040380556ee6e7e59599dfd", "shasum": "" }, "require": { "ext-json": "*", + "justinrainbow/json-schema": "^6.1", "php": ">=8.1", - "phpgt/dataobject": "^1.0.7" + "phpgt/dataobject": "^1.1" }, "require-dev": { "phpmd/phpmd": "^2.13", @@ -153,7 +346,7 @@ "description": " Structured, type-safe, immutable JSON objects.", "support": { "issues": "https://github.com/PhpGt/Json/issues", - "source": "https://github.com/PhpGt/Json/tree/v1.2.1" + "source": "https://github.com/PhpGt/Json/tree/v2.1.0" }, "funding": [ { @@ -161,7 +354,7 @@ "type": "github" } ], - "time": "2023-07-13T13:20:08+00:00" + "time": "2025-03-01T16:17:53+00:00" }, { "name": "phpgt/typesafegetter", @@ -270,28 +463,28 @@ }, { "name": "willdurand/negotiation", - "version": "3.1.0", + "version": "v2.3.1", "source": { "type": "git", "url": "https://github.com/willdurand/Negotiation.git", - "reference": "68e9ea0553ef6e2ee8db5c1d98829f111e623ec2" + "reference": "03436ededa67c6e83b9b12defac15384cb399dc9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/willdurand/Negotiation/zipball/68e9ea0553ef6e2ee8db5c1d98829f111e623ec2", - "reference": "68e9ea0553ef6e2ee8db5c1d98829f111e623ec2", + "url": "https://api.github.com/repos/willdurand/Negotiation/zipball/03436ededa67c6e83b9b12defac15384cb399dc9", + "reference": "03436ededa67c6e83b9b12defac15384cb399dc9", "shasum": "" }, "require": { - "php": ">=7.1.0" + "php": ">=5.4.0" }, "require-dev": { - "symfony/phpunit-bridge": "^5.0" + "phpunit/phpunit": "~4.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -320,9 +513,9 @@ ], "support": { "issues": "https://github.com/willdurand/Negotiation/issues", - "source": "https://github.com/willdurand/Negotiation/tree/3.1.0" + "source": "https://github.com/willdurand/Negotiation/tree/2.x" }, - "time": "2022-01-30T20:08:53+00:00" + "time": "2017-05-14T17:21:12+00:00" } ], "packages-dev": [ @@ -473,16 +666,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.13.0", + "version": "1.13.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "024473a478be9df5fdaca2c793f2232fe788e414" + "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414", - "reference": "024473a478be9df5fdaca2c793f2232fe788e414", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/1720ddd719e16cf0db4eb1c6eca108031636d46c", + "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c", "shasum": "" }, "require": { @@ -521,7 +714,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.13.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.1" }, "funding": [ { @@ -529,7 +722,7 @@ "type": "tidelift" } ], - "time": "2025-02-12T12:17:51+00:00" + "time": "2025-04-29T12:36:36+00:00" }, { "name": "nikic/php-parser", @@ -855,16 +1048,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.17", + "version": "1.12.25", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "7027b3b0270bf392de0cfba12825979768d728bf" + "reference": "e310849a19e02b8bfcbb63147f495d8f872dd96f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7027b3b0270bf392de0cfba12825979768d728bf", - "reference": "7027b3b0270bf392de0cfba12825979768d728bf", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e310849a19e02b8bfcbb63147f495d8f872dd96f", + "reference": "e310849a19e02b8bfcbb63147f495d8f872dd96f", "shasum": "" }, "require": { @@ -909,7 +1102,7 @@ "type": "github" } ], - "time": "2025-02-07T15:01:57+00:00" + "time": "2025-04-27T12:20:45+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1234,16 +1427,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.45", + "version": "10.5.46", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "bd68a781d8e30348bc297449f5234b3458267ae8" + "reference": "8080be387a5be380dda48c6f41cee4a13aadab3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bd68a781d8e30348bc297449f5234b3458267ae8", - "reference": "bd68a781d8e30348bc297449f5234b3458267ae8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8080be387a5be380dda48c6f41cee4a13aadab3d", + "reference": "8080be387a5be380dda48c6f41cee4a13aadab3d", "shasum": "" }, "require": { @@ -1253,7 +1446,7 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.12.1", + "myclabs/deep-copy": "^1.13.1", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.1", @@ -1315,7 +1508,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.45" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.46" }, "funding": [ { @@ -1326,12 +1519,20 @@ "url": "https://github.com/sebastianbergmann", "type": "github" }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, { "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", "type": "tidelift" } ], - "time": "2025-02-06T16:08:12+00:00" + "time": "2025-05-02T06:46:24+00:00" }, { "name": "psr/container", @@ -2354,16 +2555,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.3", + "version": "3.12.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10" + "reference": "6d4cf6032d4b718f168c90a96e36c7d0eaacb2aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", - "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/6d4cf6032d4b718f168c90a96e36c7d0eaacb2aa", + "reference": "6d4cf6032d4b718f168c90a96e36c7d0eaacb2aa", "shasum": "" }, "require": { @@ -2430,42 +2631,42 @@ "type": "open_collective" }, { - "url": "https://thanks.dev/phpcsstandards", + "url": "https://thanks.dev/u/gh/phpcsstandards", "type": "thanks_dev" } ], - "time": "2025-01-23T17:04:15+00:00" + "time": "2025-04-13T04:10:18+00:00" }, { "name": "symfony/config", - "version": "v6.4.14", + "version": "v7.2.6", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "4e55e7e4ffddd343671ea972216d4509f46c22ef" + "reference": "e0b050b83ba999aa77a3736cb6d5b206d65b9d0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/4e55e7e4ffddd343671ea972216d4509f46c22ef", - "reference": "4e55e7e4ffddd343671ea972216d4509f46c22ef", + "url": "https://api.github.com/repos/symfony/config/zipball/e0b050b83ba999aa77a3736cb6d5b206d65b9d0d", + "reference": "e0b050b83ba999aa77a3736cb6d5b206d65b9d0d", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=8.2", "symfony/deprecation-contracts": "^2.5|^3", - "symfony/filesystem": "^5.4|^6.0|^7.0", + "symfony/filesystem": "^7.1", "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/finder": "<5.4", + "symfony/finder": "<6.4", "symfony/service-contracts": "<2.5" }, "require-dev": { - "symfony/event-dispatcher": "^5.4|^6.0|^7.0", - "symfony/finder": "^5.4|^6.0|^7.0", - "symfony/messenger": "^5.4|^6.0|^7.0", + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/finder": "^6.4|^7.0", + "symfony/messenger": "^6.4|^7.0", "symfony/service-contracts": "^2.5|^3", - "symfony/yaml": "^5.4|^6.0|^7.0" + "symfony/yaml": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -2493,7 +2694,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v6.4.14" + "source": "https://github.com/symfony/config/tree/v7.2.6" }, "funding": [ { @@ -2509,44 +2710,43 @@ "type": "tidelift" } ], - "time": "2024-11-04T11:33:53+00:00" + "time": "2025-04-03T21:14:15+00:00" }, { "name": "symfony/dependency-injection", - "version": "v6.4.16", + "version": "v7.2.6", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "7a379d8871f6a36f01559c14e11141cc02eb8dc8" + "reference": "2ca85496cde37f825bd14f7e3548e2793ca90712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/7a379d8871f6a36f01559c14e11141cc02eb8dc8", - "reference": "7a379d8871f6a36f01559c14e11141cc02eb8dc8", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/2ca85496cde37f825bd14f7e3548e2793ca90712", + "reference": "2ca85496cde37f825bd14f7e3548e2793ca90712", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=8.2", "psr/container": "^1.1|^2.0", "symfony/deprecation-contracts": "^2.5|^3", - "symfony/service-contracts": "^2.5|^3.0", - "symfony/var-exporter": "^6.2.10|^7.0" + "symfony/service-contracts": "^3.5", + "symfony/var-exporter": "^6.4.20|^7.2.5" }, "conflict": { "ext-psr": "<1.1|>=2", - "symfony/config": "<6.1", - "symfony/finder": "<5.4", - "symfony/proxy-manager-bridge": "<6.3", - "symfony/yaml": "<5.4" + "symfony/config": "<6.4", + "symfony/finder": "<6.4", + "symfony/yaml": "<6.4" }, "provide": { "psr/container-implementation": "1.1|2.0", "symfony/service-implementation": "1.1|2.0|3.0" }, "require-dev": { - "symfony/config": "^6.1|^7.0", - "symfony/expression-language": "^5.4|^6.0|^7.0", - "symfony/yaml": "^5.4|^6.0|^7.0" + "symfony/config": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/yaml": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -2574,7 +2774,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v6.4.16" + "source": "https://github.com/symfony/dependency-injection/tree/v7.2.6" }, "funding": [ { @@ -2590,7 +2790,7 @@ "type": "tidelift" } ], - "time": "2024-11-25T14:52:46+00:00" + "time": "2025-04-27T13:37:55+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2661,25 +2861,25 @@ }, { "name": "symfony/filesystem", - "version": "v6.4.13", + "version": "v7.2.0", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "4856c9cf585d5a0313d8d35afd681a526f038dd3" + "reference": "b8dce482de9d7c9fe2891155035a7248ab5c7fdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/4856c9cf585d5a0313d8d35afd681a526f038dd3", - "reference": "4856c9cf585d5a0313d8d35afd681a526f038dd3", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/b8dce482de9d7c9fe2891155035a7248ab5c7fdb", + "reference": "b8dce482de9d7c9fe2891155035a7248ab5c7fdb", "shasum": "" }, "require": { - "php": ">=8.1", + "php": ">=8.2", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.8" }, "require-dev": { - "symfony/process": "^5.4|^6.4|^7.0" + "symfony/process": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -2707,7 +2907,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.13" + "source": "https://github.com/symfony/filesystem/tree/v7.2.0" }, "funding": [ { @@ -2723,7 +2923,7 @@ "type": "tidelift" } ], - "time": "2024-10-25T15:07:50+00:00" + "time": "2024-10-25T15:15:23+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2806,19 +3006,20 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", "shasum": "" }, "require": { + "ext-iconv": "*", "php": ">=7.2" }, "provide": { @@ -2866,7 +3067,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0" }, "funding": [ { @@ -2882,7 +3083,7 @@ "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2024-12-23T08:48:59+00:00" }, { "name": "symfony/service-contracts", @@ -2969,26 +3170,25 @@ }, { "name": "symfony/var-exporter", - "version": "v6.4.13", + "version": "v7.2.6", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "0f605f72a363f8743001038a176eeb2a11223b51" + "reference": "422b8de94c738830a1e071f59ad14d67417d7007" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/0f605f72a363f8743001038a176eeb2a11223b51", - "reference": "0f605f72a363f8743001038a176eeb2a11223b51", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/422b8de94c738830a1e071f59ad14d67417d7007", + "reference": "422b8de94c738830a1e071f59ad14d67417d7007", "shasum": "" }, "require": { - "php": ">=8.1", - "symfony/deprecation-contracts": "^2.5|^3" + "php": ">=8.2" }, "require-dev": { "symfony/property-access": "^6.4|^7.0", "symfony/serializer": "^6.4|^7.0", - "symfony/var-dumper": "^5.4|^6.0|^7.0" + "symfony/var-dumper": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -3026,7 +3226,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v6.4.13" + "source": "https://github.com/symfony/var-exporter/tree/v7.2.6" }, "funding": [ { @@ -3042,7 +3242,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:18:03+00:00" + "time": "2025-05-02T08:36:00+00:00" }, { "name": "theseer/tokenizer", From 4bf390ede6ab22b73e1b3047ffe30720e2b051d1 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Fri, 2 May 2025 12:50:40 +0100 Subject: [PATCH 6/7] ci: upgrade workflows, fix security issue --- .github/workflows/ci.yml | 34 ++++++++++++++++++++-------------- composer.json | 2 +- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dff0d36..a06a079 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,18 @@ name: CI -on: [push] +on: [push, pull_request] + +permissions: + contents: read + actions: read + id-token: none jobs: composer: runs-on: ubuntu-latest strategy: matrix: - php: [ 8.1, 8.2, 8.3, 8.4 ] + php: [ 8.3, 8.4 ] steps: - uses: actions/checkout@v4 @@ -24,7 +29,7 @@ jobs: php_version: ${{ matrix.php }} - name: Archive build - run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./ + run: mkdir /tmp/github-actions/ && tar --exclude=".git" -cvf /tmp/github-actions/build.tar ./ - name: Upload build archive for test runners uses: actions/upload-artifact@v4 @@ -37,7 +42,7 @@ jobs: needs: [ composer ] strategy: matrix: - php: [ 8.1, 8.2, 8.3, 8.4 ] + php: [ 8.3, 8.4 ] outputs: coverage: ${{ steps.store-coverage.outputs.coverage_text }} @@ -56,7 +61,6 @@ jobs: env: XDEBUG_MODE: cover with: - version: 10 php_version: ${{ matrix.php }} php_extensions: xdebug coverage_text: _coverage/coverage.txt @@ -73,9 +77,11 @@ jobs: needs: [ phpunit ] strategy: matrix: - php: [ 8.1, 8.2, 8.3, 8.4 ] + php: [ 8.3, 8.4 ] steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: code-coverage-${{ matrix.php }}-${{ github.run_number }} @@ -85,16 +91,14 @@ jobs: run: cat "_coverage/coverage.txt" - name: Upload to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} + uses: codecov/codecov-action@v5 phpstan: runs-on: ubuntu-latest needs: [ composer ] strategy: matrix: - php: [ 8.1, 8.2, 8.3, 8.4 ] + php: [ 8.3, 8.4 ] steps: - uses: actions/download-artifact@v4 @@ -110,14 +114,13 @@ jobs: with: php_version: ${{ matrix.php }} path: src/ - level: 6 phpmd: runs-on: ubuntu-latest needs: [ composer ] strategy: matrix: - php: [ 8.1, 8.2, 8.3, 8.4 ] + php: [ 8.3, 8.4 ] steps: - uses: actions/download-artifact@v4 @@ -141,7 +144,7 @@ jobs: needs: [ composer ] strategy: matrix: - php: [ 8.1, 8.2, 8.3, 8.4 ] + php: [ 8.3, 8.4 ] steps: - uses: actions/download-artifact@v4 @@ -162,12 +165,15 @@ jobs: remove_old_artifacts: runs-on: ubuntu-latest + permissions: + actions: write + 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 + gh api "/repos/${{ github.repository }}/actions/artifacts" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt while read id do echo -n "Deleting artifact ID $id ... " diff --git a/composer.json b/composer.json index ad1334b..1d3a171 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "MIT", "require": { - "php": ">=8.1", + "php": ">=8.3", "phpgt/http": "1.*", "phpgt/json": "^2.1" }, From d16f38b1dfbbafa69e2c7e8a432435c474a7b1f7 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Mon, 5 May 2025 14:57:28 +0100 Subject: [PATCH 7/7] test: when with kvp closes #18 --- test/phpunit/Trigger/TriggerTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/phpunit/Trigger/TriggerTest.php b/test/phpunit/Trigger/TriggerTest.php index 598cea3..6ca290f 100644 --- a/test/phpunit/Trigger/TriggerTest.php +++ b/test/phpunit/Trigger/TriggerTest.php @@ -25,6 +25,28 @@ public function testWhenNotMatchesInput(Input $input):void { self::assertFalse($trigger->fire()); } + public function testWhenWithKVP_missing():void { + $sut = new Trigger(new Input([ + "name" => "Cody", + "colour" => "orange", + ])); + $sut->when([ + "colour" => "white", + ]); + self::assertFalse($sut->fire()); + } + + public function testWhenWithKVP():void { + $sut = new Trigger(new Input([ + "name" => "Cody", + "colour" => "orange", + ])); + $sut->when([ + "colour" => "orange", + ]); + self::assertTrue($sut->fire()); + } + /** @dataProvider dataInput */ public function testWithSingleKey(Input $input):void { $keys = Helper::getKeysFromInput($input, 1);