From 6a22c38f3626ac1075ed3f24540c70d437c208c1 Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Fri, 10 Oct 2025 12:14:42 +0200 Subject: [PATCH 01/14] Add php cs fixer action --- .github/actions/php-cs-fixer.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/actions/php-cs-fixer.yml diff --git a/.github/actions/php-cs-fixer.yml b/.github/actions/php-cs-fixer.yml new file mode 100644 index 0000000..d4fbafa --- /dev/null +++ b/.github/actions/php-cs-fixer.yml @@ -0,0 +1,32 @@ +name: PHP CS Fixer + +on: + push: + branches: [ main ] + pull_request: + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Pull a Craftzing owned image + run: docker pull ghcr.io/craftzing/docker-images/php:8.4 + + - name: Run php-cs-fixer inside the container + run: | + docker run --rm \ + -v ${{ github.workspace }}:/app \ + -w /app \ + ghcr.io/craftzing/docker-images/php:8.4 \ + bash -c " + VERSION=3.88.2 && \ + wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v\$VERSION/php-cs-fixer.phar -O php-cs-fixer && \ + chmod a+x php-cs-fixer && \ + mv php-cs-fixer /usr/local/bin/php-cs-fixer && \ + php-cs-fixer --version && \ + php-cs-fixer fix --allow-risky=yes + " From c0c06e3c6c42a213eb0abf83a5bbf2b022513b32 Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Fri, 10 Oct 2025 12:36:35 +0200 Subject: [PATCH 02/14] Use action in workflow --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 4f8a391..29a78a6 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -19,7 +19,7 @@ jobs: with: ref: ${{ github.head_ref }} - name: Run PHP CS fixer - uses: docker://oskarstark/php-cs-fixer-ga + uses: ./.github/actions/php-cs-fixer.yml with: args: --config=.php-cs-fixer.dist.php --allow-risky=yes - name: Commit CS fixes From 452a0bfc5ee77353dce8d0a62e7d64e2413865b7 Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Fri, 10 Oct 2025 12:36:51 +0200 Subject: [PATCH 03/14] Use commit hash instead of version --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 29a78a6..272ca34 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -23,6 +23,6 @@ jobs: with: args: --config=.php-cs-fixer.dist.php --allow-risky=yes - name: Commit CS fixes - uses: craftzing/git-auto-commit-action@v5 + uses: craftzing/git-auto-commit-action@778341a with: commit_message: Fix code style violations From 325a516921dcc7fa3f2523a5011ee42aa5234542 Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Fri, 10 Oct 2025 12:39:47 +0200 Subject: [PATCH 04/14] Replace commit hash with full hash --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 272ca34..103d9ee 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -23,6 +23,6 @@ jobs: with: args: --config=.php-cs-fixer.dist.php --allow-risky=yes - name: Commit CS fixes - uses: craftzing/git-auto-commit-action@778341a + uses: craftzing/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 with: commit_message: Fix code style violations From c7bc46295a2064a6c65a051aa67028730d6f1a9b Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Fri, 10 Oct 2025 12:41:48 +0200 Subject: [PATCH 05/14] Fix action --- .github/actions/{php-cs-fixer.yml => php-cs-fixer/action.yml} | 0 .github/workflows/static-analysis.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/actions/{php-cs-fixer.yml => php-cs-fixer/action.yml} (100%) diff --git a/.github/actions/php-cs-fixer.yml b/.github/actions/php-cs-fixer/action.yml similarity index 100% rename from .github/actions/php-cs-fixer.yml rename to .github/actions/php-cs-fixer/action.yml diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 103d9ee..a155b51 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -19,7 +19,7 @@ jobs: with: ref: ${{ github.head_ref }} - name: Run PHP CS fixer - uses: ./.github/actions/php-cs-fixer.yml + uses: ./.github/actions/php-cs-fixer with: args: --config=.php-cs-fixer.dist.php --allow-risky=yes - name: Commit CS fixes From 9472f480a5c882de1f3fde104c31514243728d1c Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Fri, 10 Oct 2025 13:00:20 +0200 Subject: [PATCH 06/14] Replace workspace with working-directory --- .github/actions/php-cs-fixer/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/php-cs-fixer/action.yml b/.github/actions/php-cs-fixer/action.yml index d4fbafa..db7e4f3 100644 --- a/.github/actions/php-cs-fixer/action.yml +++ b/.github/actions/php-cs-fixer/action.yml @@ -19,7 +19,7 @@ jobs: - name: Run php-cs-fixer inside the container run: | docker run --rm \ - -v ${{ github.workspace }}:/app \ + -v ${{ github.working-directory }}:/app \ -w /app \ ghcr.io/craftzing/docker-images/php:8.4 \ bash -c " From 11c320c3266d20f43f6440b1d6516bccb3078908 Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Fri, 10 Oct 2025 13:04:52 +0200 Subject: [PATCH 07/14] Replace working-directory with workplace and quotes --- .github/actions/php-cs-fixer/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/php-cs-fixer/action.yml b/.github/actions/php-cs-fixer/action.yml index db7e4f3..3dc56b2 100644 --- a/.github/actions/php-cs-fixer/action.yml +++ b/.github/actions/php-cs-fixer/action.yml @@ -19,7 +19,7 @@ jobs: - name: Run php-cs-fixer inside the container run: | docker run --rm \ - -v ${{ github.working-directory }}:/app \ + -v "${{ github.workspace }}:/app" \ -w /app \ ghcr.io/craftzing/docker-images/php:8.4 \ bash -c " From da7e245cc03cfa6eaab7f80ebc83ce283645dd49 Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Fri, 10 Oct 2025 13:07:30 +0200 Subject: [PATCH 08/14] Pass workspace value via workflow --- .github/workflows/static-analysis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index a155b51..bf99566 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -21,6 +21,7 @@ jobs: - name: Run PHP CS fixer uses: ./.github/actions/php-cs-fixer with: + workspace: ${{ github.workspace }} args: --config=.php-cs-fixer.dist.php --allow-risky=yes - name: Commit CS fixes uses: craftzing/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 From df738eba60d7883bd626bf5e34693570d69ea7a3 Mon Sep 17 00:00:00 2001 From: ppelgrims Date: Fri, 10 Oct 2025 13:08:24 +0200 Subject: [PATCH 09/14] Replace github with inputs --- .github/actions/php-cs-fixer/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/php-cs-fixer/action.yml b/.github/actions/php-cs-fixer/action.yml index 3dc56b2..ca3f150 100644 --- a/.github/actions/php-cs-fixer/action.yml +++ b/.github/actions/php-cs-fixer/action.yml @@ -19,7 +19,7 @@ jobs: - name: Run php-cs-fixer inside the container run: | docker run --rm \ - -v "${{ github.workspace }}:/app" \ + -v "${{ inputs.workspace }}:/app" \ -w /app \ ghcr.io/craftzing/docker-images/php:8.4 \ bash -c " From 73e6a78d9121c9f983e304325d1497427c45749a Mon Sep 17 00:00:00 2001 From: Bart Van Thillo Date: Mon, 13 Oct 2025 14:17:27 +0200 Subject: [PATCH 10/14] Try and fix action --- .github/actions/php-cs-fixer/action.yml | 58 +++++++++++++------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/.github/actions/php-cs-fixer/action.yml b/.github/actions/php-cs-fixer/action.yml index ca3f150..68a3c8e 100644 --- a/.github/actions/php-cs-fixer/action.yml +++ b/.github/actions/php-cs-fixer/action.yml @@ -1,32 +1,34 @@ name: PHP CS Fixer +description: Run PHP CS Fixer in a Docker container -on: - push: - branches: [ main ] - pull_request: +inputs: + workspace: + description: 'The workspace directory to mount in the container' + required: true + args: + description: 'Additional arguments to pass to php-cs-fixer' + required: false + default: '--allow-risky=yes' -jobs: - php-cs-fixer: - runs-on: ubuntu-latest +runs: + using: composite + steps: + - name: Pull a Craftzing owned image + shell: bash + run: docker pull ghcr.io/craftzing/docker-images/php:8.4 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Pull a Craftzing owned image - run: docker pull ghcr.io/craftzing/docker-images/php:8.4 - - - name: Run php-cs-fixer inside the container - run: | - docker run --rm \ - -v "${{ inputs.workspace }}:/app" \ - -w /app \ - ghcr.io/craftzing/docker-images/php:8.4 \ - bash -c " - VERSION=3.88.2 && \ - wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v\$VERSION/php-cs-fixer.phar -O php-cs-fixer && \ - chmod a+x php-cs-fixer && \ - mv php-cs-fixer /usr/local/bin/php-cs-fixer && \ - php-cs-fixer --version && \ - php-cs-fixer fix --allow-risky=yes - " + - name: Run php-cs-fixer inside the container + shell: bash + run: | + docker run --rm \ + -v "${{ inputs.workspace }}:/app" \ + -w /app \ + ghcr.io/craftzing/docker-images/php:8.4 \ + bash -c " + VERSION=3.88.2 && \ + wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v\$VERSION/php-cs-fixer.phar -O php-cs-fixer && \ + chmod a+x php-cs-fixer && \ + mv php-cs-fixer /usr/local/bin/php-cs-fixer && \ + php-cs-fixer --version && \ + php-cs-fixer fix ${{ inputs.args }} + " From e0664764146ddefaab4caac9109396f22dc0eb39 Mon Sep 17 00:00:00 2001 From: Bart Van Thillo Date: Mon, 13 Oct 2025 14:23:37 +0200 Subject: [PATCH 11/14] Try and fix action pt 2 --- .github/actions/php-cs-fixer/action.yml | 7 +++++++ .github/workflows/static-analysis.yml | 1 + 2 files changed, 8 insertions(+) diff --git a/.github/actions/php-cs-fixer/action.yml b/.github/actions/php-cs-fixer/action.yml index 68a3c8e..2b6cbee 100644 --- a/.github/actions/php-cs-fixer/action.yml +++ b/.github/actions/php-cs-fixer/action.yml @@ -9,10 +9,17 @@ inputs: description: 'Additional arguments to pass to php-cs-fixer' required: false default: '--allow-risky=yes' + github-token: + description: 'GitHub token for authenticating with GHCR' + required: true runs: using: composite steps: + - name: Login to GitHub Container Registry + shell: bash + run: echo "${{ inputs.github-token }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Pull a Craftzing owned image shell: bash run: docker pull ghcr.io/craftzing/docker-images/php:8.4 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index bf99566..3e320bf 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -23,6 +23,7 @@ jobs: with: workspace: ${{ github.workspace }} args: --config=.php-cs-fixer.dist.php --allow-risky=yes + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Commit CS fixes uses: craftzing/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 with: From 9a7fbad0c436fac20a384942d5258150cd9557c6 Mon Sep 17 00:00:00 2001 From: Bart Van Thillo Date: Mon, 13 Oct 2025 14:30:11 +0200 Subject: [PATCH 12/14] take stab at fixing stan issues --- src/Factories/ImmutableFactory.php | 2 +- src/Factories/InstanceFactory.php | 2 +- src/PHPUnit/DataProviders/EnumCase.php | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Factories/ImmutableFactory.php b/src/Factories/ImmutableFactory.php index b6303f5..a12ba18 100644 --- a/src/Factories/ImmutableFactory.php +++ b/src/Factories/ImmutableFactory.php @@ -13,7 +13,7 @@ use function iterator_to_array; /** - * @template TClass + * @template TClass of object */ abstract class ImmutableFactory { diff --git a/src/Factories/InstanceFactory.php b/src/Factories/InstanceFactory.php index 36371b2..21b414d 100644 --- a/src/Factories/InstanceFactory.php +++ b/src/Factories/InstanceFactory.php @@ -8,7 +8,7 @@ use ReflectionProperty; /** - * @template TClass + * @template TClass of object */ final readonly class InstanceFactory { diff --git a/src/PHPUnit/DataProviders/EnumCase.php b/src/PHPUnit/DataProviders/EnumCase.php index b2c7101..9d0c146 100644 --- a/src/PHPUnit/DataProviders/EnumCase.php +++ b/src/PHPUnit/DataProviders/EnumCase.php @@ -77,6 +77,7 @@ public static function cases(string $enumFQCN): iterable public static function options(UnitEnum ...$options): iterable { foreach ($options as $case) { + // @phpstan-ignore generator.valueType yield "$case->name" => [new self($case, ...$options)]; } } From 4a87d7dc75924407a14216c9cc2163639dc77a6b Mon Sep 17 00:00:00 2001 From: Bart Van Thillo Date: Mon, 13 Oct 2025 14:32:59 +0200 Subject: [PATCH 13/14] Last try --- src/Factories/ImmutableFactory.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Factories/ImmutableFactory.php b/src/Factories/ImmutableFactory.php index a12ba18..32d84dc 100644 --- a/src/Factories/ImmutableFactory.php +++ b/src/Factories/ImmutableFactory.php @@ -31,6 +31,7 @@ final public function __construct( /** * @param array $state * @return static + * @phpstan-return static */ public function state(array $state): static { @@ -39,6 +40,7 @@ public function state(array $state): static /** * @return static + * @phpstan-return static */ public function times(int $count): static { @@ -87,7 +89,7 @@ public function raw(array $attributes = []): array /** * @param array $attributes - * @return array + * @return array> */ public function rawMany(array $attributes = []): array { From 53724606e841640e6d7a8df21dbc9b8f3f4d4c91 Mon Sep 17 00:00:00 2001 From: Bart Van Thillo Date: Mon, 13 Oct 2025 14:34:48 +0200 Subject: [PATCH 14/14] Revert that --- src/Factories/ImmutableFactory.php | 6 ++---- src/Factories/InstanceFactory.php | 2 +- src/PHPUnit/DataProviders/EnumCase.php | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Factories/ImmutableFactory.php b/src/Factories/ImmutableFactory.php index 32d84dc..b6303f5 100644 --- a/src/Factories/ImmutableFactory.php +++ b/src/Factories/ImmutableFactory.php @@ -13,7 +13,7 @@ use function iterator_to_array; /** - * @template TClass of object + * @template TClass */ abstract class ImmutableFactory { @@ -31,7 +31,6 @@ final public function __construct( /** * @param array $state * @return static - * @phpstan-return static */ public function state(array $state): static { @@ -40,7 +39,6 @@ public function state(array $state): static /** * @return static - * @phpstan-return static */ public function times(int $count): static { @@ -89,7 +87,7 @@ public function raw(array $attributes = []): array /** * @param array $attributes - * @return array> + * @return array */ public function rawMany(array $attributes = []): array { diff --git a/src/Factories/InstanceFactory.php b/src/Factories/InstanceFactory.php index 21b414d..36371b2 100644 --- a/src/Factories/InstanceFactory.php +++ b/src/Factories/InstanceFactory.php @@ -8,7 +8,7 @@ use ReflectionProperty; /** - * @template TClass of object + * @template TClass */ final readonly class InstanceFactory { diff --git a/src/PHPUnit/DataProviders/EnumCase.php b/src/PHPUnit/DataProviders/EnumCase.php index 9d0c146..b2c7101 100644 --- a/src/PHPUnit/DataProviders/EnumCase.php +++ b/src/PHPUnit/DataProviders/EnumCase.php @@ -77,7 +77,6 @@ public static function cases(string $enumFQCN): iterable public static function options(UnitEnum ...$options): iterable { foreach ($options as $case) { - // @phpstan-ignore generator.valueType yield "$case->name" => [new self($case, ...$options)]; } }