From ab0d448655b2e1c09cb9936e763f96b5f9891cbd Mon Sep 17 00:00:00 2001 From: Remko Silvis Date: Wed, 28 Jan 2026 15:07:31 +0100 Subject: [PATCH 1/5] [AZEM2-1972] Loosen the PHPMD rules a bit to be more inline with Magento usage --- CHANGELOG.md | 4 ++++ config/magento2/phpmd.xml | 31 +++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2485ba..e237424 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ 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). +## [3.0.3] +### Changed +- Magento phpmd.xml loosened some rules to be more inline with what is 'normal' in Magento. + ## [3.0.2] ### Changed - Constraint for `bitexpert/phpstan-magento` from '~0.30' to '>=0.30' to allow for installing newer PHPStan versions when needed. diff --git a/config/magento2/phpmd.xml b/config/magento2/phpmd.xml index 51e4c08..b0be3be 100644 --- a/config/magento2/phpmd.xml +++ b/config/magento2/phpmd.xml @@ -18,10 +18,23 @@ - + + + + + - - + + + + + + + + + + + @@ -29,9 +42,16 @@ + + + + + + + - + @@ -41,5 +61,4 @@ - - \ No newline at end of file + From 672f578a821af69aee8dc42c2352f96cce1694d4 Mon Sep 17 00:00:00 2001 From: Remko Silvis Date: Fri, 30 Jan 2026 14:23:22 +0100 Subject: [PATCH 2/5] [AZEM2-1972] Update phpcs config to fit Magento projects and add placeholders for drupal and pimcore --- config/default/phpcs.xml | 12 +++++++++ config/default/phpmd.xml | 4 ++- config/drupal/phpcs.xml | 9 +++++++ config/magento2/phpcs.xml | 41 ++++++++++++++++++++++++++++++ config/magento2/phpmd.xml | 10 +------- config/pimcore/phpcs.xml | 9 +++++++ templates/files/default/phpcs.xml | 4 +-- templates/files/drupal/phpcs.xml | 6 ++--- templates/files/magento2/phpcs.xml | 9 +------ templates/files/pimcore/phpcs.xml | 11 ++++++++ 10 files changed, 90 insertions(+), 25 deletions(-) create mode 100644 config/default/phpcs.xml create mode 100644 config/drupal/phpcs.xml create mode 100644 config/magento2/phpcs.xml create mode 100644 config/pimcore/phpcs.xml create mode 100644 templates/files/pimcore/phpcs.xml diff --git a/config/default/phpcs.xml b/config/default/phpcs.xml new file mode 100644 index 0000000..e9e9d00 --- /dev/null +++ b/config/default/phpcs.xml @@ -0,0 +1,12 @@ + + + PHPCS + ../vendor + + + + diff --git a/config/default/phpmd.xml b/config/default/phpmd.xml index e5b0135..3b4f75f 100644 --- a/config/default/phpmd.xml +++ b/config/default/phpmd.xml @@ -16,6 +16,8 @@ + + @@ -30,4 +32,4 @@ - \ No newline at end of file + diff --git a/config/drupal/phpcs.xml b/config/drupal/phpcs.xml new file mode 100644 index 0000000..9392a49 --- /dev/null +++ b/config/drupal/phpcs.xml @@ -0,0 +1,9 @@ + + + PHPCS + + diff --git a/config/magento2/phpcs.xml b/config/magento2/phpcs.xml new file mode 100644 index 0000000..dd72c59 --- /dev/null +++ b/config/magento2/phpcs.xml @@ -0,0 +1,41 @@ + + + PHPCS + *.phtml + ./magento-vars.php + ./app/etc/registration_globlist.php + ./app/etc/NonComposerComponentRegistration.php + ./app/etc/config.php + .ddev/* + ./env-dev.php + ./deploy.php + ./pub/sgtm.php + ./tests/* + + + + + + + + + + + + + + + + + + + + diff --git a/config/magento2/phpmd.xml b/config/magento2/phpmd.xml index b0be3be..967e288 100644 --- a/config/magento2/phpmd.xml +++ b/config/magento2/phpmd.xml @@ -18,11 +18,6 @@ - - - - - @@ -52,13 +47,10 @@ - - - - + diff --git a/config/pimcore/phpcs.xml b/config/pimcore/phpcs.xml new file mode 100644 index 0000000..9392a49 --- /dev/null +++ b/config/pimcore/phpcs.xml @@ -0,0 +1,9 @@ + + + PHPCS + + diff --git a/templates/files/default/phpcs.xml b/templates/files/default/phpcs.xml index 96885a2..d7f6e8b 100644 --- a/templates/files/default/phpcs.xml +++ b/templates/files/default/phpcs.xml @@ -5,9 +5,7 @@ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> PHPCS - - - + diff --git a/templates/files/drupal/phpcs.xml b/templates/files/drupal/phpcs.xml index 5b89341..995dc09 100644 --- a/templates/files/drupal/phpcs.xml +++ b/templates/files/drupal/phpcs.xml @@ -5,9 +5,7 @@ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> PHPCS - - - + - \ No newline at end of file + diff --git a/templates/files/magento2/phpcs.xml b/templates/files/magento2/phpcs.xml index fdaf1b5..297689b 100644 --- a/templates/files/magento2/phpcs.xml +++ b/templates/files/magento2/phpcs.xml @@ -5,14 +5,7 @@ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> PHPCS - + - - - app/etc/config.php - env-dev.php - deploy.php - pub/errors/* - .ddev diff --git a/templates/files/pimcore/phpcs.xml b/templates/files/pimcore/phpcs.xml new file mode 100644 index 0000000..dbc6c06 --- /dev/null +++ b/templates/files/pimcore/phpcs.xml @@ -0,0 +1,11 @@ + + + PHPCS + + + + From 671b6adf2f6c93f87e62da8bee0bbebbdc41c40d Mon Sep 17 00:00:00 2001 From: Remko Silvis Date: Mon, 2 Feb 2026 13:15:51 +0100 Subject: [PATCH 3/5] Update for PR comments, use the default ruleset.xml again --- config/default/phpcs.xml | 12 --------- config/drupal/phpcs.xml | 9 ------- config/magento2/phpcs.xml | 41 ------------------------------ config/magento2/ruleset.xml | 8 ++++++ config/pimcore/phpcs.xml | 9 ------- templates/files/default/phpcs.xml | 4 ++- templates/files/drupal/phpcs.xml | 4 ++- templates/files/magento2/phpcs.xml | 2 +- templates/files/pimcore/phpcs.xml | 11 -------- 9 files changed, 15 insertions(+), 85 deletions(-) delete mode 100644 config/default/phpcs.xml delete mode 100644 config/drupal/phpcs.xml delete mode 100644 config/magento2/phpcs.xml delete mode 100644 config/pimcore/phpcs.xml delete mode 100644 templates/files/pimcore/phpcs.xml diff --git a/config/default/phpcs.xml b/config/default/phpcs.xml deleted file mode 100644 index e9e9d00..0000000 --- a/config/default/phpcs.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - PHPCS - ../vendor - - - - diff --git a/config/drupal/phpcs.xml b/config/drupal/phpcs.xml deleted file mode 100644 index 9392a49..0000000 --- a/config/drupal/phpcs.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - PHPCS - - diff --git a/config/magento2/phpcs.xml b/config/magento2/phpcs.xml deleted file mode 100644 index dd72c59..0000000 --- a/config/magento2/phpcs.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - PHPCS - *.phtml - ./magento-vars.php - ./app/etc/registration_globlist.php - ./app/etc/NonComposerComponentRegistration.php - ./app/etc/config.php - .ddev/* - ./env-dev.php - ./deploy.php - ./pub/sgtm.php - ./tests/* - - - - - - - - - - - - - - - - - - - - diff --git a/config/magento2/ruleset.xml b/config/magento2/ruleset.xml index 1222edc..db63003 100644 --- a/config/magento2/ruleset.xml +++ b/config/magento2/ruleset.xml @@ -2,12 +2,20 @@ Youwe coding standard extensions for sniffing code in Magento 2 projects. + *.phtml + ./app/etc/config.php + .ddev/* + ./env-dev.php + ./tests/* + + + + diff --git a/templates/files/drupal/phpcs.xml b/templates/files/drupal/phpcs.xml index 995dc09..a30dea4 100644 --- a/templates/files/drupal/phpcs.xml +++ b/templates/files/drupal/phpcs.xml @@ -5,7 +5,9 @@ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> PHPCS - + + + diff --git a/templates/files/magento2/phpcs.xml b/templates/files/magento2/phpcs.xml index 297689b..d8159f5 100644 --- a/templates/files/magento2/phpcs.xml +++ b/templates/files/magento2/phpcs.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> PHPCS - + diff --git a/templates/files/pimcore/phpcs.xml b/templates/files/pimcore/phpcs.xml deleted file mode 100644 index dbc6c06..0000000 --- a/templates/files/pimcore/phpcs.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - PHPCS - - - - From d0164b06dafd46abbcccfac45879ac954ccb9e2b Mon Sep 17 00:00:00 2001 From: Remko Silvis Date: Tue, 3 Feb 2026 11:56:27 +0100 Subject: [PATCH 4/5] [AZEM2-1972] Update changelog, added exclude for UnusedFormalParameter --- CHANGELOG.md | 8 ++++++++ config/magento2/phpmd.xml | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e237424..7b88825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [3.0.3] ### Changed - Magento phpmd.xml loosened some rules to be more inline with what is 'normal' in Magento. + - Added exclude patterns for *.phtml + - Added exclude for UnusedFormalParameter to allow unused parameters in a function + - Added exception for short variable name for $id + Magento phpcs.xml loosened some rules to be more inline with what is 'normal' in Magento. + - Excluded Magento2.Annotation.MethodAnnotationStructure.MethodAnnotation + - Moved exclude paths for: *.phtml, ./app/etc/config.php, ddev/*, ./env-dev.php, ./tests/* to default ruleset. +### Fixed +- Updated property for LongVariable did not work. ## [3.0.2] ### Changed diff --git a/config/magento2/phpmd.xml b/config/magento2/phpmd.xml index 967e288..aa93efa 100644 --- a/config/magento2/phpmd.xml +++ b/config/magento2/phpmd.xml @@ -21,7 +21,6 @@ - From 286797614eaf5a8836f2da0ec5f4ebaf8d68364b Mon Sep 17 00:00:00 2001 From: Remko Silvis Date: Tue, 3 Feb 2026 12:33:44 +0100 Subject: [PATCH 5/5] [AZEM2-1972] Update changelog, added exclude for UnusedFormalParameter --- CHANGELOG.md | 4 +--- config/magento2/ruleset.xml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b88825..d55e72f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added exclude patterns for *.phtml - Added exclude for UnusedFormalParameter to allow unused parameters in a function - Added exception for short variable name for $id - Magento phpcs.xml loosened some rules to be more inline with what is 'normal' in Magento. - - Excluded Magento2.Annotation.MethodAnnotationStructure.MethodAnnotation - - Moved exclude paths for: *.phtml, ./app/etc/config.php, ddev/*, ./env-dev.php, ./tests/* to default ruleset. + - PHPCS Excluded Magento2.Annotation.MethodAnnotationStructure.MethodAnnotation ### Fixed - Updated property for LongVariable did not work. diff --git a/config/magento2/ruleset.xml b/config/magento2/ruleset.xml index db63003..0e07ddf 100644 --- a/config/magento2/ruleset.xml +++ b/config/magento2/ruleset.xml @@ -4,7 +4,7 @@ *.phtml ./app/etc/config.php - .ddev/* + /.ddev/* ./env-dev.php ./tests/*