From 4dd83639bb3cff0b11d7d6f0fdcd4905390e9d22 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 12 Sep 2022 16:44:06 +0100 Subject: [PATCH 01/12] Update branding in documentation --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9621d7c..717a531 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Introduction -This is the MediaCT coding standard for Magento 2 projects. It is based on -the default MediaCT coding standard but some tests have been removed to create +This is the Youwe coding standard for Magento 2 projects. It is based on +the default Youwe coding standard but some tests have been removed to create a workable and fast standard. # Installation @@ -9,7 +9,7 @@ a workable and fast standard. Use composer to require the standard in a project. ```shell -composer require --dev mediact/coding-standard-magento2 +composer require --dev youwe/coding-standard-magento2 ``` To let PHPCS know that this standard should be used add a phpcs.xml file in the @@ -18,20 +18,20 @@ root of the project. ```xml - + ``` # Integration with PHPStorm and automatic testing The recommended way to enable the coding standard in PHPStorm and automatic -testing is by requiring the MediaCT testing suite in a project. +testing is by requiring the Youwe testing suite in a project. ```shell -composer require --dev mediact/testing-suite +composer require --dev youwe/testing-suite ``` -For more information go to [MediaCT Testing Suite](https://github.com/mediact/testing-suite). +For more information go to [Youwe Testing Suite](https://github.com/YouweGit/testing-suite). # Contribution guidelines From d25d7712d03bb5f44ba2b092e5251649a53bd183 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 12 Sep 2022 16:47:17 +0100 Subject: [PATCH 02/12] Rename Magento2 coding standard to YouweMagento2 This is to avoid collision with upstream Magento2 coding standard. This is a breaking change and will require a new major version number when it is released. --- README.md | 2 +- composer.json | 2 +- src/MediactMagento2/phpmd.xml | 2 +- src/MediactMagento2/ruleset.xml | 2 +- src/{Magento2 => YouweMagento2}/phpmd.xml | 0 src/{Magento2 => YouweMagento2}/ruleset.xml | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename src/{Magento2 => YouweMagento2}/phpmd.xml (100%) rename src/{Magento2 => YouweMagento2}/ruleset.xml (98%) diff --git a/README.md b/README.md index 717a531..937b3fa 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ root of the project. ```xml - + ``` diff --git a/composer.json b/composer.json index c7d6552..bbf4b4c 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "autoload": { "psr-0": { "MediactMagento2": "src/MediactMagento2", - "Magento2": "src/Magento2" + "YouweMagento2": "src/YouweMagento2" } } } diff --git a/src/MediactMagento2/phpmd.xml b/src/MediactMagento2/phpmd.xml index 2f9b695..399c9d3 100644 --- a/src/MediactMagento2/phpmd.xml +++ b/src/MediactMagento2/phpmd.xml @@ -13,5 +13,5 @@ xsi:noNamespaceSchemaLocation=" http://pmd.sf.net/ruleset_xml_schema.xsd"> Mediact coding standards for Magento2 is deprecated please use Magento2. - + diff --git a/src/MediactMagento2/ruleset.xml b/src/MediactMagento2/ruleset.xml index 4561c7a..7ad4bf7 100644 --- a/src/MediactMagento2/ruleset.xml +++ b/src/MediactMagento2/ruleset.xml @@ -7,5 +7,5 @@ --> Mediact coding standards for Magento2 is deprecated please use Magento2. - + diff --git a/src/Magento2/phpmd.xml b/src/YouweMagento2/phpmd.xml similarity index 100% rename from src/Magento2/phpmd.xml rename to src/YouweMagento2/phpmd.xml diff --git a/src/Magento2/ruleset.xml b/src/YouweMagento2/ruleset.xml similarity index 98% rename from src/Magento2/ruleset.xml rename to src/YouweMagento2/ruleset.xml index bf45a16..85e708a 100644 --- a/src/Magento2/ruleset.xml +++ b/src/YouweMagento2/ruleset.xml @@ -5,7 +5,7 @@ * https://www.youweagency.com */ --> - + Youwe coding standards for Magento2. From 937105507d2c2484bdeaf2c0f6a2eebfb2ab4322 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 12 Sep 2022 16:49:19 +0100 Subject: [PATCH 03/12] Remove deprecated standards This is feasible as we are releasing the next major version of this pacakge anyway. (See previous commit.) --- composer.json | 1 - src/MediactMagento2/phpmd.xml | 17 ----------------- src/MediactMagento2/ruleset.xml | 11 ----------- 3 files changed, 29 deletions(-) delete mode 100644 src/MediactMagento2/phpmd.xml delete mode 100644 src/MediactMagento2/ruleset.xml diff --git a/composer.json b/composer.json index bbf4b4c..2094f1e 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,6 @@ }, "autoload": { "psr-0": { - "MediactMagento2": "src/MediactMagento2", "YouweMagento2": "src/YouweMagento2" } } diff --git a/src/MediactMagento2/phpmd.xml b/src/MediactMagento2/phpmd.xml deleted file mode 100644 index 399c9d3..0000000 --- a/src/MediactMagento2/phpmd.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - Mediact coding standards for Magento2 is deprecated please use Magento2. - - diff --git a/src/MediactMagento2/ruleset.xml b/src/MediactMagento2/ruleset.xml deleted file mode 100644 index 7ad4bf7..0000000 --- a/src/MediactMagento2/ruleset.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Mediact coding standards for Magento2 is deprecated please use Magento2. - - From cac15ca929a0c197365557fb08f6bed22bcc07ad Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 12 Sep 2022 17:31:06 +0100 Subject: [PATCH 04/12] Import official Magento2 coding standard --- README.md | 2 +- composer.json | 12 ++++++++++++ src/YouweMagento2/ruleset.xml | 19 +++++++++++++------ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 937b3fa..d007faa 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Introduction This is the Youwe coding standard for Magento 2 projects. It is based on -the default Youwe coding standard but some tests have been removed to create +the default Magento2 coding standard but some tests have been removed to create a workable and fast standard. # Installation diff --git a/composer.json b/composer.json index 2094f1e..f94b8f1 100644 --- a/composer.json +++ b/composer.json @@ -11,11 +11,23 @@ } ], "require": { + "magento/magento-coding-standard": "*", "youwe/coding-standard": ">=3.3.0" }, "autoload": { "psr-0": { "YouweMagento2": "src/YouweMagento2" } + }, + "scripts": { + "post-install-cmd": [ + "@phpcs-set-paths" + ], + "post-update-cmd": [ + "@phpcs-set-paths" + ], + "phpcs-set-paths": [ + "vendor/bin/phpcs --config-set installed_paths src/,../../magento/magento-coding-standard/,../../phpcompatibility/php-compatibility/" + ] } } diff --git a/src/YouweMagento2/ruleset.xml b/src/YouweMagento2/ruleset.xml index 85e708a..7d7a07f 100644 --- a/src/YouweMagento2/ruleset.xml +++ b/src/YouweMagento2/ruleset.xml @@ -6,22 +6,29 @@ */ --> - Youwe coding standards for Magento2. + Youwe coding standards for Magento2 websites and modules + - - - + - + + + + + + + + + - *.phtml + *.phtml,*.xml From 714920696bfe31b3bec4f19ec376697932c7c399 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 12 Sep 2022 17:31:48 +0100 Subject: [PATCH 05/12] Avoid unbounded version constraints where possible --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f94b8f1..5bff46b 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "require": { "magento/magento-coding-standard": "*", - "youwe/coding-standard": ">=3.3.0" + "youwe/coding-standard": "^3.3.0" }, "autoload": { "psr-0": { From d8ef3ffc4ec6898947ec45fe228cb11f03e65e7a Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 12 Sep 2022 17:32:16 +0100 Subject: [PATCH 06/12] composer normalize --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5bff46b..1be8832 100644 --- a/composer.json +++ b/composer.json @@ -1,15 +1,15 @@ { "name": "youwe/coding-standard-magento2", "description": "Youwe PHP Coding Standard for Magento2", - "type": "phpcs-sniffs", - "homepage": "https://github.com/YouweGit/coding-standard-magento2", "license": "proprietary", + "type": "phpcs-sniffs", "authors": [ { "name": "Youwe B.V.", "email": "info@youweagency.com" } ], + "homepage": "https://github.com/YouweGit/coding-standard-magento2", "require": { "magento/magento-coding-standard": "*", "youwe/coding-standard": "^3.3.0" From f2435713ba5766897413e7ea89e510c7808624c5 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 12 Sep 2022 17:38:40 +0100 Subject: [PATCH 07/12] Correct minimum version of upstream standard --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1be8832..7ea2e14 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "homepage": "https://github.com/YouweGit/coding-standard-magento2", "require": { "magento/magento-coding-standard": "*", - "youwe/coding-standard": "^3.3.0" + "youwe/coding-standard": "^3.5.0" }, "autoload": { "psr-0": { From 094be807493c264b41e7a5574dd5a44ec7931569 Mon Sep 17 00:00:00 2001 From: Leon Helmus Date: Wed, 21 Sep 2022 17:08:43 +0200 Subject: [PATCH 08/12] Update command which needs to be run otherwise Youwe & YouweMagento2 are not declared. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7ea2e14..ee5f0e3 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "@phpcs-set-paths" ], "phpcs-set-paths": [ - "vendor/bin/phpcs --config-set installed_paths src/,../../magento/magento-coding-standard/,../../phpcompatibility/php-compatibility/" + "vendor/bin/phpcs --config-set installed_paths ../../youwe/coding-standard/src/,../../youwe/coding-standard-magento2/src/,../../magento/magento-coding-standard/,../../phpcompatibility/php-compatibility/" ] } } From 061f546b164dc13ea52c94583169f1532990269d Mon Sep 17 00:00:00 2001 From: Leon Helmus Date: Mon, 26 Sep 2022 10:38:46 +0200 Subject: [PATCH 09/12] Added magento/magento-coding-standard to keep closer to Magento standards. * Added support for phtml templates. * Added Fisheye coding standards. * Updated current rules and added comments why it was added. --- CHANGELOG.md | 14 ++++++- README.md | 4 +- src/YouweMagento2/ruleset.xml | 76 ++++++++++++++++++++++++++++++----- 3 files changed, 81 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dbf41e..274b4a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,22 @@ 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). +## 2.0.0 +### Added +- Composer package youwe/coding-standard which is now included in the Youwe coding standards for Magento 2. +- Comments for why the ruleset was added. +- Coding standards for phtml templates. +- Package [magento/magento-coding-standard](https://github.com/magento/magento-coding-standard) as a requirement. + The version v25 is used as a base. If not compatible please update the `phpcs.xml` in project root. + +### Removed +- Rule PSR2.Methods.MethodDeclaration.Underscore since this is already excluded by Magento. +- Argument colors and added it in the common Youwe coding standards. + ## 1.7.0 - 2021-12-24 ### Changed - Vendor from MediactMagento2 to Magento2 - Copyrights. ### Removed -- Dependency squizlabs/php_codesniffer. \ No newline at end of file +- Dependency squizlabs/php_codesniffer. diff --git a/README.md b/README.md index d007faa..b58cb92 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ a workable and fast standard. Use composer to require the standard in a project. ```shell -composer require --dev youwe/coding-standard-magento2 +composer require --dev youwe/coding-standard-magento2 -W ``` To let PHPCS know that this standard should be used add a phpcs.xml file in the @@ -18,7 +18,7 @@ root of the project. ```xml - + ``` diff --git a/src/YouweMagento2/ruleset.xml b/src/YouweMagento2/ruleset.xml index 7d7a07f..bb4ba2e 100644 --- a/src/YouweMagento2/ruleset.xml +++ b/src/YouweMagento2/ruleset.xml @@ -3,47 +3,100 @@ /** * Copyright Youwe. All rights reserved. * https://www.youweagency.com + * + * TODO:: Create a separate ruleset for phtml files, since a lot of exceptions need to be made just for adding phtml to code sniffer. */ --> Youwe coding standards for Magento2 websites and modules - - - + + + - + + + + + + + + - - *.phtml,*.xml + + + *.phtml - + + *.phtml - + + *.phtml - + + + *.phtml + *.xml + + + + *.phtml + + *.phtml + + + + + *.phtml + + + + + *.phtml + + + + + *.phtml + + + + + *.phtml + + + + + *.phtml + + + + *.phtml @@ -53,5 +106,8 @@ - + + + *.phtml + From 549d1927fbb5c9945bd37a9fbd00b67c3a67e5cf Mon Sep 17 00:00:00 2001 From: Leon Helmus Date: Mon, 26 Sep 2022 10:54:11 +0200 Subject: [PATCH 10/12] Updated changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 274b4a2..bbdaa2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed - Rule PSR2.Methods.MethodDeclaration.Underscore since this is already excluded by Magento. - Argument colors and added it in the common Youwe coding standards. +- Old coding ruleset directories and migrated them to YouweMagento2. ## 1.7.0 - 2021-12-24 ### Changed From 5293cfb4ff2cad3775f79fb3f25f1159cd49ef59 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 29 Sep 2022 12:31:36 +0100 Subject: [PATCH 11/12] Automatically update/set installed_paths for phpcs --- composer.json | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index ee5f0e3..d236fd3 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ ], "homepage": "https://github.com/YouweGit/coding-standard-magento2", "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", "magento/magento-coding-standard": "*", "youwe/coding-standard": "^3.5.0" }, @@ -19,15 +20,10 @@ "YouweMagento2": "src/YouweMagento2" } }, - "scripts": { - "post-install-cmd": [ - "@phpcs-set-paths" - ], - "post-update-cmd": [ - "@phpcs-set-paths" - ], - "phpcs-set-paths": [ - "vendor/bin/phpcs --config-set installed_paths ../../youwe/coding-standard/src/,../../youwe/coding-standard-magento2/src/,../../magento/magento-coding-standard/,../../phpcompatibility/php-compatibility/" - ] + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + }, + "sort-packages": true } } From 5c294655af09f78d2c1d89e1fb8caf2252600e09 Mon Sep 17 00:00:00 2001 From: Leon Helmus Date: Wed, 12 Oct 2022 12:20:49 +0000 Subject: [PATCH 12/12] Type needs to be changed for dealerdirect/phpcodesniffer-composer-installer to add it to installed paths --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index d236fd3..01b3b0f 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "youwe/coding-standard-magento2", "description": "Youwe PHP Coding Standard for Magento2", "license": "proprietary", - "type": "phpcs-sniffs", + "type": "phpcodesniffer-standard", "authors": [ { "name": "Youwe B.V.", @@ -12,7 +12,7 @@ "homepage": "https://github.com/YouweGit/coding-standard-magento2", "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", - "magento/magento-coding-standard": "*", + "magento/magento-coding-standard": ">= 9", "youwe/coding-standard": "^3.5.0" }, "autoload": {