From 7afc016b442763e6f1b0c185900e0655f8cec54e Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Thu, 20 Mar 2025 10:20:58 +0000 Subject: [PATCH 1/7] PLUG-160: Make cache adapter compatible with older versions of psr cache adapter --- .github/workflows/setup-di-compile.yml | 2 ++ Service/Cache/Psr16CacheAdapter.php | 13 ++++++------- Service/Cache/Test.php | 0 3 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 Service/Cache/Test.php diff --git a/.github/workflows/setup-di-compile.yml b/.github/workflows/setup-di-compile.yml index 8e505b9..d30c9d4 100644 --- a/.github/workflows/setup-di-compile.yml +++ b/.github/workflows/setup-di-compile.yml @@ -7,6 +7,8 @@ jobs: fail-fast: false matrix: include: + - PHP_VERSION: php81-fpm + MAGENTO_VERSION: 2.4.5-p11 - PHP_VERSION: php82-fpm MAGENTO_VERSION: 2.4.6 runs-on: ubuntu-latest diff --git a/Service/Cache/Psr16CacheAdapter.php b/Service/Cache/Psr16CacheAdapter.php index e52d5d9..c46138e 100644 --- a/Service/Cache/Psr16CacheAdapter.php +++ b/Service/Cache/Psr16CacheAdapter.php @@ -18,7 +18,7 @@ public function __construct(CacheType $cacheFrontend) /** * {@inheritdoc} */ - public function get(string $key, mixed $default = null): mixed + public function get($key, $default = null): mixed { $item = $this->cacheFrontend->load($key); @@ -32,7 +32,7 @@ public function get(string $key, mixed $default = null): mixed /** * {@inheritdoc} */ - public function set(string $key, $value, $ttl = null): bool + public function set($key, $value, $ttl = null): bool { $value = serialize($value); return $this->cacheFrontend->save( @@ -62,7 +62,7 @@ public function clear(): bool /** * {@inheritdoc} */ - public function getMultiple(iterable $keys, mixed $default = null): iterable + public function getMultiple($keys, $default = null): iterable { if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); @@ -76,9 +76,8 @@ public function getMultiple(iterable $keys, mixed $default = null): iterable /** * {@inheritdoc} - * @param iterable $values */ - public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool + public function setMultiple($values, $ttl = null): bool { $stringKeyedValues = []; foreach ($values as $key => $value) { @@ -103,7 +102,7 @@ public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null /** * {@inheritdoc} */ - public function deleteMultiple(iterable $keys): bool + public function deleteMultiple($keys): bool { if ($keys instanceof \Traversable) { $keys = iterator_to_array($keys, false); @@ -118,7 +117,7 @@ public function deleteMultiple(iterable $keys): bool /** * {@inheritdoc} */ - public function has(string $key): bool + public function has($key): bool { return $this->cacheFrontend->test($key); } diff --git a/Service/Cache/Test.php b/Service/Cache/Test.php new file mode 100644 index 0000000..e69de29 From 0c393119a79e0512c3270704562728901436d44a Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Thu, 20 Mar 2025 10:23:10 +0000 Subject: [PATCH 2/7] PLUG-160: Update version --- CHANGELOG.md | 6 ++++++ etc/config.xml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b487f..8bf3bd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2.4.2] - 2025-03-20 + +### Fixed + +- Make cache adapter compatible with older PSR cache adapter + ## [v2.4.1] - 2025-02-24 ### Fixed diff --git a/etc/config.xml b/etc/config.xml index a920cbc..9be13cb 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -10,7 +10,7 @@ - 2.4.1 + 2.4.2 TrueLayerFacade TrueLayer Make a direct payment securely from your bank app - no card needed From b859589ae3a2b1c36e94a06354098b7998fedb57 Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Thu, 20 Mar 2025 10:32:17 +0000 Subject: [PATCH 3/7] PLUG-160: Fix docblocks --- Service/Client/ClientFactory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Service/Client/ClientFactory.php b/Service/Client/ClientFactory.php index 1fa6450..1c31a08 100644 --- a/Service/Client/ClientFactory.php +++ b/Service/Client/ClientFactory.php @@ -27,6 +27,7 @@ class ClientFactory /** * @param ConfigRepository $configProvider * @param LogServiceInterface $logger + * @param Psr16CacheAdapter $cacheAdapter */ public function __construct( ConfigRepository $configProvider, @@ -42,7 +43,7 @@ public function __construct( * @param int $storeId * @param array|null $data * @return ClientInterface|null - * @throws SignerException + * @throws SignerException|InvalidArgumentException */ public function create(int $storeId = 0, ?array $data = []): ?ClientInterface { From 44daa2b062403ef5952b4a1cb1b8077266d5b313 Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Thu, 20 Mar 2025 10:59:25 +0000 Subject: [PATCH 4/7] PLUG-160: Simplify pipeline --- .github/workflows/phpstan.yml | 41 -------------------------- .github/workflows/setup-di-compile.yml | 5 +++- Service/Cache/Test.php | 0 3 files changed, 4 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/phpstan.yml delete mode 100644 Service/Cache/Test.php diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml deleted file mode 100644 index accd7d7..0000000 --- a/.github/workflows/phpstan.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: phpstan -on: [pull_request] - -jobs: - build: - strategy: - matrix: - include: - - PHP_VERSION: php82-fpm - MAGENTO_VERSION: 2.4.6 - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Start Docker - run: docker run --detach --name magento-project-community-edition michielgerritsen/magento-project-community-edition:${{ matrix.PHP_VERSION }}-magento${{ matrix.MAGENTO_VERSION }} - - - name: Create branch for Composer and remove version from composer.json - run: git checkout -b continuous-integration-test-branch && sed -i '/version/d' ./composer.json - - - name: Remove PHPStan duplicate include - run: sed -i '/vendor\/bitexpert/d' ./phpstan.neon - - - name: Upload our code into the docker container - run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ - - - name: Set minimum-stability for composer (temp) - run: docker exec magento-project-community-edition composer config minimum-stability dev - - - name: Configure composer to mirror repository - run: docker exec magento-project-community-edition composer config repositories.truelayer \{\"type\":\"path\",\"url\":\"/data/extensions/$(basename $(pwd))\",\"options\":\{\"symlink\":false\}\} - - - name: Install the extensions in Magento - run: docker exec magento-project-community-edition composer require truelayer/magento2:@dev --no-plugins --with-all-dependencies - - - name: Activate the extension - run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable TrueLayer_Connect && php bin/magento setup:upgrade && php bin/magento setup:di:compile" - - - name: Run PHPStan - run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions" \ No newline at end of file diff --git a/.github/workflows/setup-di-compile.yml b/.github/workflows/setup-di-compile.yml index d30c9d4..de94006 100644 --- a/.github/workflows/setup-di-compile.yml +++ b/.github/workflows/setup-di-compile.yml @@ -9,7 +9,7 @@ jobs: include: - PHP_VERSION: php81-fpm MAGENTO_VERSION: 2.4.5-p11 - - PHP_VERSION: php82-fpm + - PHP_VERSION: php81-fpm MAGENTO_VERSION: 2.4.6 runs-on: ubuntu-latest steps: @@ -32,3 +32,6 @@ jobs: - name: Activate the extension and run setup:upgrade and setup:di:compile run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable TrueLayer_Connect && php bin/magento setup:upgrade && php bin/magento setup:di:compile" + + - name: Run PHPStan + run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions" diff --git a/Service/Cache/Test.php b/Service/Cache/Test.php deleted file mode 100644 index e69de29..0000000 From cf759302679c387bfa702ae4ff624abdf512ccc0 Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Thu, 20 Mar 2025 11:03:59 +0000 Subject: [PATCH 5/7] PLUG-160: Pipeline --- .github/workflows/phpstan.yml | 41 ++++++++++++++++++++++++++ .github/workflows/setup-di-compile.yml | 5 +--- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/phpstan.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..6ef6368 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,41 @@ +name: phpstan +on: [pull_request] + +jobs: + build: + strategy: + matrix: + include: + - PHP_VERSION: php81-fpm + MAGENTO_VERSION: 2.4.6 + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Start Docker + run: docker run --detach --name magento-project-community-edition michielgerritsen/magento-project-community-edition:${{ matrix.PHP_VERSION }}-magento${{ matrix.MAGENTO_VERSION }} + + - name: Create branch for Composer and remove version from composer.json + run: git checkout -b continuous-integration-test-branch && sed -i '/version/d' ./composer.json + + - name: Remove PHPStan duplicate include + run: sed -i '/vendor\/bitexpert/d' ./phpstan.neon + + - name: Upload our code into the docker container + run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ + + - name: Set minimum-stability for composer (temp) + run: docker exec magento-project-community-edition composer config minimum-stability dev + + - name: Configure composer to mirror repository + run: docker exec magento-project-community-edition composer config repositories.truelayer \{\"type\":\"path\",\"url\":\"/data/extensions/$(basename $(pwd))\",\"options\":\{\"symlink\":false\}\} + + - name: Install the extensions in Magento + run: docker exec magento-project-community-edition composer require truelayer/magento2:@dev --no-plugins --with-all-dependencies + + - name: Activate the extension + run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable TrueLayer_Connect && php bin/magento setup:upgrade && php bin/magento setup:di:compile" + + - name: Run PHPStan + run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions" \ No newline at end of file diff --git a/.github/workflows/setup-di-compile.yml b/.github/workflows/setup-di-compile.yml index de94006..d30c9d4 100644 --- a/.github/workflows/setup-di-compile.yml +++ b/.github/workflows/setup-di-compile.yml @@ -9,7 +9,7 @@ jobs: include: - PHP_VERSION: php81-fpm MAGENTO_VERSION: 2.4.5-p11 - - PHP_VERSION: php81-fpm + - PHP_VERSION: php82-fpm MAGENTO_VERSION: 2.4.6 runs-on: ubuntu-latest steps: @@ -32,6 +32,3 @@ jobs: - name: Activate the extension and run setup:upgrade and setup:di:compile run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable TrueLayer_Connect && php bin/magento setup:upgrade && php bin/magento setup:di:compile" - - - name: Run PHPStan - run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions" From c811f269e38b746f328445e66afe7a2d981958ae Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Thu, 20 Mar 2025 11:09:57 +0000 Subject: [PATCH 6/7] PLUG-160: Specify bitexpert version --- .github/workflows/phpstan.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 6ef6368..accd7d7 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: include: - - PHP_VERSION: php81-fpm + - PHP_VERSION: php82-fpm MAGENTO_VERSION: 2.4.6 runs-on: ubuntu-latest diff --git a/composer.json b/composer.json index 3975042..9189334 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "require-dev": { "phpstan/phpstan": "*", "friendsofphp/php-cs-fixer": "^3.64", - "bitexpert/phpstan-magento": "*" + "bitexpert/phpstan-magento": "^0.32.0" }, "autoload": { "files": [ From a9214d97c3909c3ab58b98882c612affaadb6f40 Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Thu, 20 Mar 2025 11:15:25 +0000 Subject: [PATCH 7/7] PLUG-160: Exclude ClientFactory --- phpstan.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon b/phpstan.neon index b27f7e2..e45a909 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -12,5 +12,6 @@ parameters: excludePaths: - docker/* - vendor/* + - Service/Client/ClientFactory.php includes: - vendor/bitexpert/phpstan-magento/extension.neon