From cbc329e7b1cc3daa82a770bc63d0c08394006c94 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Mon, 1 Sep 2025 09:40:08 +0200 Subject: [PATCH 01/26] Added Emico Code Quality module --- .grumphpinclude | 3 + composer.json | 22 ++-- grumphp.yml | 27 +++-- phpcs.xml | 107 +----------------- phpstan.neon | 1 + ruleset.xml | 47 +------- src/Block/Adminhtml/System/Config/Version.php | 1 - src/Model/Api/Client.php | 4 +- src/Observer/AddPageAssets.php | 1 - src/Observer/ManageLayoutBlocks.php | 2 +- src/Plugin/Model/Autocomplete.php | 1 - src/ViewModel/Search.php | 5 +- 12 files changed, 41 insertions(+), 180 deletions(-) create mode 100644 .grumphpinclude mode change 100644 => 120000 phpcs.xml create mode 120000 phpstan.neon mode change 100644 => 120000 ruleset.xml diff --git a/.grumphpinclude b/.grumphpinclude new file mode 100644 index 0000000..a922fa6 --- /dev/null +++ b/.grumphpinclude @@ -0,0 +1,3 @@ +# Add all files which should be included in here. +# Patterns are equal to .gitignore +*.php diff --git a/composer.json b/composer.json index 7bb043f..0c3787f 100644 --- a/composer.json +++ b/composer.json @@ -9,11 +9,7 @@ }, "require-dev": { "magento/framework": "*", - "phpro/grumphp-shim": "^2.7", - "squizlabs/php_codesniffer": "^3.10", - "phpmd/phpmd": "^2.15", - "slevomat/coding-standard": "^8.15", - "magento-ecg/coding-standard": "^4.5" + "emico/code-quality": "^10.5" }, "autoload": { "files": [ @@ -23,17 +19,23 @@ "Tweakwise\\TweakwiseJs\\": "src/" } }, - "repositories": [ - { + "repositories": { + "magento": { "type": "composer", "url": "https://repo.magento.com/" + }, + "emico": { + "type": "composer", + "url": "https://git.emico.io/api/v4/group/239/-/packages/composer/" } - ], + }, "config": { "allow-plugins": { - "phpro/grumphp-shim": true, "magento/composer-dependency-version-audit-plugin": false, - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true, + "emico/code-quality": true, + "phpro/grumphp": true } } } diff --git a/grumphp.yml b/grumphp.yml index cc7b1f7..377615d 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -1,11 +1,16 @@ -grumphp: - tasks: - xmllint: - triggered_by: ['xml', 'xsd'] - scheme_validation: true - x_include: true - dtd_validation: true - phpcs: ~ - phpmd: - ruleset: - - "ruleset.xml" +# Don't edit below this line +# This GrumPHP File is copied to the project dir. And should be edited for custom overrides. +imports: +- { resource: vendor/emico/code-quality/grumphp.base.yml } +# Add project custom ignores like this +# parameters: +# ignore.phpcs: +# - "test" +# ignore.phpmd: +# - "test" +# ignore.phpstan: +# - "test" +# Edits below this line +parameters: + tasks: + git_commit_message: ~ diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index a4c8229..0000000 --- a/phpcs.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - Tweakwise coding standard ruleset for PHP. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - error - - - - - - - - - - - - - - - - - - - *.phtml - - - - - - - - - - - - - *.phtml - - - - - - - - - - - - - - - - - - - - - */tests/* - - diff --git a/phpcs.xml b/phpcs.xml new file mode 120000 index 0000000..7dc8705 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1 @@ +vendor/emico/code-quality/config-templates/magento/phpcs.dist.xml \ No newline at end of file diff --git a/phpstan.neon b/phpstan.neon new file mode 120000 index 0000000..e03af8b --- /dev/null +++ b/phpstan.neon @@ -0,0 +1 @@ +vendor/emico/code-quality/config-templates/phpstan.neon \ No newline at end of file diff --git a/ruleset.xml b/ruleset.xml deleted file mode 100644 index 84cda59..0000000 --- a/ruleset.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - Tweakwise Code Check Rules - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ruleset.xml b/ruleset.xml new file mode 120000 index 0000000..7aa9095 --- /dev/null +++ b/ruleset.xml @@ -0,0 +1 @@ +vendor/emico/code-quality/config-templates/magento/ruleset.dist.xml \ No newline at end of file diff --git a/src/Block/Adminhtml/System/Config/Version.php b/src/Block/Adminhtml/System/Config/Version.php index be94647..240df52 100644 --- a/src/Block/Adminhtml/System/Config/Version.php +++ b/src/Block/Adminhtml/System/Config/Version.php @@ -28,7 +28,6 @@ public function __construct( * @param AbstractElement $element * @return string * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function _getElementHtml(AbstractElement $element): string { diff --git a/src/Model/Api/Client.php b/src/Model/Api/Client.php index 7afdede..c397c5c 100644 --- a/src/Model/Api/Client.php +++ b/src/Model/Api/Client.php @@ -56,7 +56,7 @@ private function getFeatures(): array { $cachedFeatures = $this->cache->load(self::FEATURES_CACHE_KEY); if ($cachedFeatures) { - return $this->jsonSerializer->unserialize($cachedFeatures); + return (array)$this->jsonSerializer->unserialize($cachedFeatures); } $instanceKey = $this->config->getInstanceKey(); @@ -122,7 +122,7 @@ private function doRequest(string $url, string $method = 'GET'): array } $contents = $response->getBody()->getContents(); - return $this->jsonSerializer->unserialize($contents); + return (array)$this->jsonSerializer->unserialize($contents); } /** diff --git a/src/Observer/AddPageAssets.php b/src/Observer/AddPageAssets.php index 63e7f5d..bb0c843 100644 --- a/src/Observer/AddPageAssets.php +++ b/src/Observer/AddPageAssets.php @@ -25,7 +25,6 @@ public function __construct( /** * @param Observer $observer * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute(Observer $observer): void { diff --git a/src/Observer/ManageLayoutBlocks.php b/src/Observer/ManageLayoutBlocks.php index 2e70af2..9a71e6a 100644 --- a/src/Observer/ManageLayoutBlocks.php +++ b/src/Observer/ManageLayoutBlocks.php @@ -78,7 +78,7 @@ private function shouldShowTweakwiseJsCategoryViewBlock(): bool } $currentCategory = $this->layerResolver->get()->getCurrentCategory(); - if (!$currentCategory) { + if (!$currentCategory->getId()) { return false; } diff --git a/src/Plugin/Model/Autocomplete.php b/src/Plugin/Model/Autocomplete.php index 5dfba32..0a9d51f 100644 --- a/src/Plugin/Model/Autocomplete.php +++ b/src/Plugin/Model/Autocomplete.php @@ -23,7 +23,6 @@ public function __construct( * @param Subject $subject * @param array $result * @return array - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterGetItems(Subject $subject, array $result): array { diff --git a/src/ViewModel/Search.php b/src/ViewModel/Search.php index 880813e..07b3a09 100644 --- a/src/ViewModel/Search.php +++ b/src/ViewModel/Search.php @@ -7,6 +7,7 @@ use Magento\Framework\App\Request\Http; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\UrlInterface; +use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use Tweakwise\TweakwiseJs\Helper\Data; use Tweakwise\TweakwiseJs\Model\Config; @@ -45,8 +46,10 @@ public function getSearchType(): SearchType public function getStoreRootCategory(): int { try { + /** @var Store $store */ + $store = $this->storeManager->getStore(); return (int)$this->dataHelper->getTweakwiseId( - (int)$this->storeManager->getStore()->getRootCategoryId() + (int)$store->getRootCategoryId() ); } catch (NoSuchEntityException $e) { return 0; From 898ad9ebb0f2910de76bc4e131f3fc72c79470e0 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Mon, 1 Sep 2025 09:53:59 +0200 Subject: [PATCH 02/26] Added Gitlab token --- .github/workflows/grumphp.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index a156f31..893a297 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -15,6 +15,7 @@ jobs: uses: actions/checkout@v3 - name: GrumPHP run: | + composer2 config --global --auth gitlab-token.gitlab.com ${{ secrets.GITLAB_TOKEN }} composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} composer2 install --dev --prefer-dist --no-scripts --no-progress --optimize-autoloader --no-interaction -vvv composer2 show From b72b88290eac3b3d78b16ee2ef231a509e3c9eca Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Mon, 1 Sep 2025 09:58:18 +0200 Subject: [PATCH 03/26] Added Gitlab token --- .github/workflows/grumphp.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index 893a297..10a13c9 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v3 - name: GrumPHP run: | - composer2 config --global --auth gitlab-token.gitlab.com ${{ secrets.GITLAB_TOKEN }} + composer2 config --global --auth http-basic.git.emico.io gitlab-ci-token ${{ secrets.GITLAB_TOKEN }} composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} composer2 install --dev --prefer-dist --no-scripts --no-progress --optimize-autoloader --no-interaction -vvv composer2 show From f617f87b5a26d65429fd791bafd8f962058e97a9 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Mon, 1 Sep 2025 10:50:18 +0200 Subject: [PATCH 04/26] Disable git_commit_message lint --- grumphp.yml | 154 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 139 insertions(+), 15 deletions(-) diff --git a/grumphp.yml b/grumphp.yml index 377615d..97c0909 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -1,16 +1,140 @@ -# Don't edit below this line -# This GrumPHP File is copied to the project dir. And should be edited for custom overrides. -imports: -- { resource: vendor/emico/code-quality/grumphp.base.yml } -# Add project custom ignores like this -# parameters: -# ignore.phpcs: -# - "test" -# ignore.phpmd: -# - "test" -# ignore.phpstan: -# - "test" -# Edits below this line -parameters: +grumphp: + process_timeout: 360 + extensions: + - Emico\CodeQuality\GrumPHP\Extension + parallel: + enabled: false tasks: - git_commit_message: ~ + phpstan: + triggered_by: + - php + level: 7 + ignore_patterns: + - "vendor" + - "generated" + - "setup" + - "update" + - "dev" + - "tests" + - "public" + - "backend/vendor" + - "backend/generated" + - "backend/setup" + - "backend/update" + - "backend/tests" + - "backend/dev" + - "deploy.php" + - "deploy" + - "magento/vendor" + - "magento/generated" + - "magento/setup" + - "magento/update" + - "magento/tests/_support/_generated" + - "magento/dev" + - "LocalValetDriver.php" + configuration: phpstan.neon + phpmd: + triggered_by: + - php + ruleset: + - "ruleset.xml" + exclude: + - "vendor" + - "generated" + - "setup" + - "update" + - "dev" + - "public" + - "deploy" + - "tests/_support/_generated" + - "app/etc/config.php" + - "backend/vendor" + - "backend/generated" + - "backend/setup" + - "backend/update" + - "backend/update" + - "backend/dev" + - "backend/tests/_support/_generated" + - "backend/app/etc/config.php" + - "magento/app/etc/config.php" + - "magento/vendor" + - "magento/generated" + - "magento/setup" + - "magento/update" + - "magento/tests/_support/_generated" + - "magento/dev" + phpcs: + triggered_by: + - php + ignore_patterns: + - "vendor" + - "generated" + - "setup" + - "update" + - "dev" + - "public" + - "deploy" + - "tests/_support/_generated" + - "app/etc/config.php" + - "backend/vendor" + - "backend/generated" + - "backend/setup" + - "backend/update" + - "backend/dev" + - "backend/tests/_support/_generated" + - "backend/app/etc/config.php" + - "magento/app/etc/config.php" + - "magento/vendor" + - "magento/generated" + - "magento/setup" + - "magento/update" + - "magento/tests/_support/_generated" + - "magento/dev" + + xmllint: + triggered_by: [ 'xml', 'xsd' ] + scheme_validation: true + x_include: true + dtd_validation: true + load_from_net: true + + phplint: + short_open_tag: true + ignore_patterns: + - "vendor" + - "generated" + - "setup" + - "update" + - "dev" + - "public" + - "deploy" + - "tests/_support/_generated" + - "app/etc/config.php" + - "backend/vendor" + - "backend/generated" + - "backend/setup" + - "backend/update" + - "backend/dev" + - "backend/tests/_support/_generated" + - "backend/app/etc/config.php" + - "magento/app/etc/config.php" + - "magento/vendor" + - "magento/generated" + - "magento/setup" + - "magento/update" + - "magento/tests/_support/_generated" + - "magento/dev" + + composer: + no_check_publish: true + with_dependencies: false + strict: false + + git_commit_message: + allow_empty_message: false + enforce_capitalized_subject: false + enforce_no_subject_punctuations: false + enforce_no_subject_trailing_period: false + enforce_single_lined_subject: true + max_body_width: 100 + max_subject_width: 100 From 4448f5fc5c8fc5b2ddc9f80fa1bcda8ab877dd79 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Mon, 1 Sep 2025 11:05:28 +0200 Subject: [PATCH 05/26] Test phpstan --- phpstan.neon | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) mode change 120000 => 100644 phpstan.neon diff --git a/phpstan.neon b/phpstan.neon deleted file mode 120000 index e03af8b..0000000 --- a/phpstan.neon +++ /dev/null @@ -1 +0,0 @@ -vendor/emico/code-quality/config-templates/phpstan.neon \ No newline at end of file diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..fb3ba23 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,27 @@ +services: + - class: Emico\CodeQuality\PHPStan\VarModelExtension + tags: + - phpstan.broker.methodsClassReflectionExtension + +parameters: + ignoreErrors: + - '/Call to an undefined method Mockery\\ExpectationInterface|Mockery\\HigherOrderMessage::andReturnUsing\(\)./' + - '/expects string, Magento\\Framework\\Phrase given/' + - identifier: missingType.iterableValue + - identifier: missingType.generics + - messages: + - '/::delete\(\) expects Magento\\Framework\\Model\\AbstractModel,/' + - '/::save\(\) expects Magento\\Framework\\Model\\AbstractModel,/' + - '/::load\(\) expects Magento\\Framework\\Model\\AbstractModel,/' + path: *Repository.php + stubFiles: + - ./vendor/emico/code-quality/phpstan/stubs/globalFunctions.stub + - ./vendor/emico/code-quality/phpstan/stubs/Magento/Catalog/Model/ResourceModel/Product/Collection.stub + - ./vendor/emico/code-quality/phpstan/stubs/Magento/Eav/Setup/EavSetup.stub + - ./vendor/emico/code-quality/phpstan/stubs/Magento/Framework/Api/Search/FilterGroupBuilder.stub + - ./vendor/emico/code-quality/phpstan/stubs/Magento/Framework/App/ActionFlag.stub + - ./vendor/emico/code-quality/phpstan/stubs/Magento/Framework/Escaper.stub + - ./vendor/emico/code-quality/phpstan/stubs/Magento/Framework/Serialize/SerializerInterface.stub + - ./vendor/emico/code-quality/phpstan/stubs/Magento/InventoryImportExport/Model/Import/Serializer/Json.stub + bootstrapFiles: + - ../../autoload.php From ac08196f435c1ea7dc6bf2f5cbd7d6ae5082f1f6 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Mon, 1 Sep 2025 11:36:23 +0200 Subject: [PATCH 06/26] Test phpstan --- .github/workflows/grumphp.yaml | 2 +- phpstan.neon | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index 10a13c9..73a0968 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -19,5 +19,5 @@ jobs: composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} composer2 install --dev --prefer-dist --no-scripts --no-progress --optimize-autoloader --no-interaction -vvv composer2 show - vendor/bin/grumphp run --no-interaction + vendor/bin/grumphp run --tasks=phpmd,phpcs,xmllint,phplint,composer --no-interaction shell: bash diff --git a/phpstan.neon b/phpstan.neon index fb3ba23..10cdaf9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -25,3 +25,4 @@ parameters: - ./vendor/emico/code-quality/phpstan/stubs/Magento/InventoryImportExport/Model/Import/Serializer/Json.stub bootstrapFiles: - ../../autoload.php + From b41cf35bccd449720f01f63e814450e8d92befec Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Mon, 1 Sep 2025 11:54:10 +0200 Subject: [PATCH 07/26] Fixed lint issues --- src/Block/Adminhtml/System/Config/Version.php | 1 + src/Observer/AddPageAssets.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Block/Adminhtml/System/Config/Version.php b/src/Block/Adminhtml/System/Config/Version.php index 240df52..9fdb267 100644 --- a/src/Block/Adminhtml/System/Config/Version.php +++ b/src/Block/Adminhtml/System/Config/Version.php @@ -28,6 +28,7 @@ public function __construct( * @param AbstractElement $element * @return string * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ protected function _getElementHtml(AbstractElement $element): string { diff --git a/src/Observer/AddPageAssets.php b/src/Observer/AddPageAssets.php index bb0c843..904ebd3 100644 --- a/src/Observer/AddPageAssets.php +++ b/src/Observer/AddPageAssets.php @@ -25,6 +25,7 @@ public function __construct( /** * @param Observer $observer * @return void + * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterface */ public function execute(Observer $observer): void { From 151c29b102b551b1f2c6a24ae099086e8720a849 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Mon, 1 Sep 2025 16:08:48 +0200 Subject: [PATCH 08/26] Changed Emico composer repository --- .gitignore | 3 ++- composer.json | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2462e66..de7710c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.idea /vendor /composer.lock +/auth.json /build/local.env -/build/data \ No newline at end of file +/build/data diff --git a/composer.json b/composer.json index 0c3787f..364e595 100644 --- a/composer.json +++ b/composer.json @@ -24,9 +24,9 @@ "type": "composer", "url": "https://repo.magento.com/" }, - "emico": { - "type": "composer", - "url": "https://git.emico.io/api/v4/group/239/-/packages/composer/" + "emico/code-quality": { + "type": "vcs", + "url": "git@git.emico.io:composer-packages/generic/codequality.git" } }, "config": { From de01363069fb5a0e51bf958734198f2f92dd4521 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Mon, 1 Sep 2025 16:44:14 +0200 Subject: [PATCH 09/26] Added ssh key step --- .github/workflows/grumphp.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index 73a0968..d6d6a03 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -13,6 +13,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Prepare SSH key + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} - name: GrumPHP run: | composer2 config --global --auth http-basic.git.emico.io gitlab-ci-token ${{ secrets.GITLAB_TOKEN }} From 57a402b01e827f8d159a1bbaf2b02156af97d7ba Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 09:51:47 +0200 Subject: [PATCH 10/26] Removed ssh key step --- .github/workflows/grumphp.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index d6d6a03..73a0968 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -13,10 +13,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Prepare SSH key - uses: webfactory/ssh-agent@v0.9.0 - with: - ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} - name: GrumPHP run: | composer2 config --global --auth http-basic.git.emico.io gitlab-ci-token ${{ secrets.GITLAB_TOKEN }} From 847b4cf04e02bc594f8c9402121c52aa6deb0e82 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 12:06:53 +0200 Subject: [PATCH 11/26] Added ssh key step --- .github/workflows/grumphp.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index 73a0968..d6d6a03 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -13,6 +13,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Prepare SSH key + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} - name: GrumPHP run: | composer2 config --global --auth http-basic.git.emico.io gitlab-ci-token ${{ secrets.GITLAB_TOKEN }} From 01b080de500d280b96ad56e45b4becc15cc084c1 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 12:13:22 +0200 Subject: [PATCH 12/26] Added keyscan step --- .github/workflows/grumphp.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index d6d6a03..9d89f7e 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -17,6 +17,10 @@ jobs: uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} + - name: Add GitLab to known_hosts + run: | + mkdir -p ~/.ssh + ssh-keyscan git.emico.io >> ~/.ssh/known_hosts - name: GrumPHP run: | composer2 config --global --auth http-basic.git.emico.io gitlab-ci-token ${{ secrets.GITLAB_TOKEN }} From 60dc64bf5580212be293c3b7f46f1e7077320873 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 12:21:22 +0200 Subject: [PATCH 13/26] Added keyscan step --- .github/workflows/grumphp.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index 9d89f7e..c58ca9f 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -14,16 +14,16 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Prepare SSH key - uses: webfactory/ssh-agent@v0.9.0 + uses: webfactory/ssh-agent@v0.9.1 with: ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} - name: Add GitLab to known_hosts run: | mkdir -p ~/.ssh ssh-keyscan git.emico.io >> ~/.ssh/known_hosts + chmod 644 ~/.ssh/known_hosts - name: GrumPHP run: | - composer2 config --global --auth http-basic.git.emico.io gitlab-ci-token ${{ secrets.GITLAB_TOKEN }} composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} composer2 install --dev --prefer-dist --no-scripts --no-progress --optimize-autoloader --no-interaction -vvv composer2 show From 210a83e898173822e9974b88d2acdac3c7d2002c Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 12:46:35 +0200 Subject: [PATCH 14/26] Debug --- .github/workflows/grumphp.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index c58ca9f..e46e967 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -22,6 +22,7 @@ jobs: mkdir -p ~/.ssh ssh-keyscan git.emico.io >> ~/.ssh/known_hosts chmod 644 ~/.ssh/known_hosts + cat ~/.ssh/known_hosts - name: GrumPHP run: | composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} From 6fa1b0962f49e6aa2e4dfd832208c1864f177538 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 12:57:42 +0200 Subject: [PATCH 15/26] Debug --- .github/workflows/grumphp.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index e46e967..f38c7cf 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -13,16 +13,13 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Prepare SSH key - uses: webfactory/ssh-agent@v0.9.1 - with: - ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} - - name: Add GitLab to known_hosts + - name: Setup SSH for GitLab run: | mkdir -p ~/.ssh + echo "${{ secrets.GITLAB_SSH_KEY }}" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 ssh-keyscan git.emico.io >> ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts - cat ~/.ssh/known_hosts + shell: bash - name: GrumPHP run: | composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} From 80282d2ac8119c22c9d09714c409a30e12b4bc54 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 12:59:34 +0200 Subject: [PATCH 16/26] Debug --- .github/workflows/grumphp.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index f38c7cf..b79f480 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -19,6 +19,7 @@ jobs: echo "${{ secrets.GITLAB_SSH_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 ssh-keyscan git.emico.io >> ~/.ssh/known_hosts + export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes" shell: bash - name: GrumPHP run: | From 33b05b82ec0df77a7cbdf22dc2ba93fcca934c3c Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 13:10:38 +0200 Subject: [PATCH 17/26] Debug --- .github/workflows/grumphp.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index b79f480..e0ba91e 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -13,14 +13,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Setup SSH for GitLab + - name: Setup SSH Agent + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} + - name: Add GitLab host key run: | mkdir -p ~/.ssh - echo "${{ secrets.GITLAB_SSH_KEY }}" > ~/.ssh/id_ed25519 - chmod 600 ~/.ssh/id_ed25519 - ssh-keyscan git.emico.io >> ~/.ssh/known_hosts - export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes" - shell: bash + ssh-keyscan -t rsa,ed25519,ecdsa git.emico.io >> ~/.ssh/known_hosts - name: GrumPHP run: | composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} From 56456866bb30213fad3a40227c641daaf31e6bea Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 14:17:09 +0200 Subject: [PATCH 18/26] Debug --- .github/workflows/grumphp.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index e0ba91e..09ae917 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -21,6 +21,11 @@ jobs: run: | mkdir -p ~/.ssh ssh-keyscan -t rsa,ed25519,ecdsa git.emico.io >> ~/.ssh/known_hosts + cat ~/.ssh/known_hosts + - name: Debug SSH key + run: ssh-add -l + - name: Test GitLab SSH + run: ssh -vvv git@git.emico.io || true - name: GrumPHP run: | composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} From a14330e31d9fb4a1e410c1b9301961080b380937 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 14:43:38 +0200 Subject: [PATCH 19/26] Debug --- .github/workflows/grumphp.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index 09ae917..c396f1b 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -20,7 +20,9 @@ jobs: - name: Add GitLab host key run: | mkdir -p ~/.ssh + chmod 700 ~/.ssh ssh-keyscan -t rsa,ed25519,ecdsa git.emico.io >> ~/.ssh/known_hosts + chmod 644 ~/.ssh/known_hosts cat ~/.ssh/known_hosts - name: Debug SSH key run: ssh-add -l From 6eede740160edd6188f87bafbcd1e1e9619f5a54 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 15:29:02 +0200 Subject: [PATCH 20/26] Debug --- .github/workflows/grumphp.yaml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index c396f1b..7beeedc 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -17,19 +17,9 @@ jobs: uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} - - name: Add GitLab host key - run: | - mkdir -p ~/.ssh - chmod 700 ~/.ssh - ssh-keyscan -t rsa,ed25519,ecdsa git.emico.io >> ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts - cat ~/.ssh/known_hosts - - name: Debug SSH key - run: ssh-add -l - - name: Test GitLab SSH - run: ssh -vvv git@git.emico.io || true - name: GrumPHP run: | + export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} composer2 install --dev --prefer-dist --no-scripts --no-progress --optimize-autoloader --no-interaction -vvv composer2 show From 999208d4e382cf67bdda8121f7bffb3f95fc9a26 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 19:53:25 +0200 Subject: [PATCH 21/26] Debug --- .github/workflows/grumphp.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index 7beeedc..b6b1e49 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -13,14 +13,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Setup SSH Agent - uses: webfactory/ssh-agent@v0.9.0 - with: - ssh-private-key: ${{ secrets.GITLAB_SSH_KEY }} - name: GrumPHP run: | - export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} + composer2 config --global gitlab-token.git.emico.io ${{ secrets.GITLAB_TOKEN }} composer2 install --dev --prefer-dist --no-scripts --no-progress --optimize-autoloader --no-interaction -vvv composer2 show vendor/bin/grumphp run --tasks=phpmd,phpcs,xmllint,phplint,composer --no-interaction From 07f587438c4aaded41a010d1c2267891e7fbc920 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 19:55:37 +0200 Subject: [PATCH 22/26] Debug --- .github/workflows/grumphp.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/grumphp.yaml b/.github/workflows/grumphp.yaml index b6b1e49..af31d25 100644 --- a/.github/workflows/grumphp.yaml +++ b/.github/workflows/grumphp.yaml @@ -16,7 +16,7 @@ jobs: - name: GrumPHP run: | composer2 config http-basic.repo.magento.com ${{ secrets.MAGENTO_USERNAME }} ${{ secrets.MAGENTO_PASSWORD }} - composer2 config --global gitlab-token.git.emico.io ${{ secrets.GITLAB_TOKEN }} + composer2 config gitlab-token.git.emico.io ${{ secrets.GITLAB_TOKEN }} composer2 install --dev --prefer-dist --no-scripts --no-progress --optimize-autoloader --no-interaction -vvv composer2 show vendor/bin/grumphp run --tasks=phpmd,phpcs,xmllint,phplint,composer --no-interaction From 2fe48e568327a9d6fc9c8bba5db00802be020b71 Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 19:58:13 +0200 Subject: [PATCH 23/26] Debug --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 364e595..636b8af 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ }, "emico/code-quality": { "type": "vcs", - "url": "git@git.emico.io:composer-packages/generic/codequality.git" + "url": "https://git.emico.io/composer-packages/generic/codequality.git" } }, "config": { From 0938dd1b82081196264c8c62ba75193d8a7c6e7c Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Tue, 2 Sep 2025 20:13:31 +0200 Subject: [PATCH 24/26] Debug --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 636b8af..d633ade 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,9 @@ "phpstan/extension-installer": true, "emico/code-quality": true, "phpro/grumphp": true + }, + "preferred-install": { + "emico/code-quality": "dist" } } } From 050507e4b74d4b213bfd93da85e32b50858eccae Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Thu, 4 Sep 2025 08:55:11 +0200 Subject: [PATCH 25/26] Ignore phpstan messages --- src/Controller/Adminhtml/Ajax/FacetAttributes.php | 1 + src/Model/Api/Client.php | 1 + src/Model/Config/Source/SearchType.php | 1 + src/Model/Config/Source/Template.php | 1 + src/Model/Config/Source/Yesno.php | 1 + src/Plugin/Model/Page/DataProvider.php | 1 - src/ViewModel/AttributeLanding.php | 1 + 7 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Controller/Adminhtml/Ajax/FacetAttributes.php b/src/Controller/Adminhtml/Ajax/FacetAttributes.php index 0988883..ecda089 100644 --- a/src/Controller/Adminhtml/Ajax/FacetAttributes.php +++ b/src/Controller/Adminhtml/Ajax/FacetAttributes.php @@ -75,6 +75,7 @@ public function execute() /** @var FacetAttributeResponseInterface $response */ $response = $this->client->request($facetAttributeRequest); + // @phpstan-ignore-next-line if (!$response) { return $result->setData([$otherAttributeOption]); } diff --git a/src/Model/Api/Client.php b/src/Model/Api/Client.php index 8c16cba..38402ac 100644 --- a/src/Model/Api/Client.php +++ b/src/Model/Api/Client.php @@ -131,6 +131,7 @@ private function doRequest(Request $request): Response sprintf( 'Invalid response received by Tweakwise server, xml load fails. Request "%s", XML Errors: %s', $url, + // @phpstan-ignore-next-line implode(PHP_EOL, $errors) ) ); diff --git a/src/Model/Config/Source/SearchType.php b/src/Model/Config/Source/SearchType.php index 7385cb7..7c2bfb2 100644 --- a/src/Model/Config/Source/SearchType.php +++ b/src/Model/Config/Source/SearchType.php @@ -46,6 +46,7 @@ public function toOptionArray(): array protected function isSuggestionsFeatureEnabled(): bool { $featureRequest = $this->requestFactory->create(); + // @phpstan-ignore-next-line return (bool)$this->apiClient->getFeatures($featureRequest)[Feature::SUGGESTIONS->value] ?? false; } } diff --git a/src/Model/Config/Source/Template.php b/src/Model/Config/Source/Template.php index 43464ec..7c364ab 100644 --- a/src/Model/Config/Source/Template.php +++ b/src/Model/Config/Source/Template.php @@ -39,6 +39,7 @@ protected function buildOptions(): array ['value' => null, 'label' => __('* Default template')], ]; + // @phpstan-ignore-next-line if (!is_array($response->getTemplates())) { return $result; } diff --git a/src/Model/Config/Source/Yesno.php b/src/Model/Config/Source/Yesno.php index 4165496..0ca78ae 100644 --- a/src/Model/Config/Source/Yesno.php +++ b/src/Model/Config/Source/Yesno.php @@ -39,6 +39,7 @@ public function toOptionArray(): array protected function isNavigationFeatureEnabled(): bool { $featureRequest = $this->requestFactory->create(); + // @phpstan-ignore-next-line return (bool)$this->apiClient->getFeatures($featureRequest)[Feature::NAVIGATION->value] ?? false; } } diff --git a/src/Plugin/Model/Page/DataProvider.php b/src/Plugin/Model/Page/DataProvider.php index c383429..d12e1ad 100644 --- a/src/Plugin/Model/Page/DataProvider.php +++ b/src/Plugin/Model/Page/DataProvider.php @@ -24,7 +24,6 @@ public function __construct( * @param Subject $subject * @param array $result * @return array - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterGetConfigData(Subject $subject, array $result): array { diff --git a/src/ViewModel/AttributeLanding.php b/src/ViewModel/AttributeLanding.php index 01629d8..3818fa4 100644 --- a/src/ViewModel/AttributeLanding.php +++ b/src/ViewModel/AttributeLanding.php @@ -55,6 +55,7 @@ protected function getFilterAttributes(string $filterAttributesSerialized, bool { $filterAttributes = $this->serializer->unserialize($filterAttributesSerialized); $filters = []; + // @phpstan-ignore-next-line foreach ($filterAttributes as $filterAttribute) { $filters[$this->getAttribute($filterAttribute, $addPrefix)] = $this->getValue($filterAttribute); } From dbbf35994cf11544f04ea3d83e0f5a755812a87b Mon Sep 17 00:00:00 2001 From: tjeujansen Date: Thu, 4 Sep 2025 08:58:18 +0200 Subject: [PATCH 26/26] Fixed lint issue --- src/Model/Api/Request.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Model/Api/Request.php b/src/Model/Api/Request.php index 7c89dc1..b1e84bd 100644 --- a/src/Model/Api/Request.php +++ b/src/Model/Api/Request.php @@ -26,7 +26,6 @@ public function __construct( */ protected array $parameters = []; - /** * @return string */