From e43bd7931720ff7face6814e1277f5649ce2cb55 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Wed, 20 Sep 2023 16:09:36 +0100 Subject: [PATCH] Use a composer plugin to register the standard --- README.md | 16 +--------------- composer.json | 7 ++----- composer.lock | 2 +- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8ca973e1..9e46c236 100644 --- a/README.md +++ b/README.md @@ -10,20 +10,6 @@ To use within your Magento 2 project you can use: composer require --dev magento/magento-coding-standard ``` -Due to security, when installed this way the Magento standard for phpcs cannot be added automatically. -You can achieve this by adding the following to your project's `composer.json`: - -```json -"scripts": { - "post-install-cmd": [ - "([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)" - ], - "post-update-cmd": [ - "([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)" - ] -} -``` - ### Installation for development You can install Magento Coding Standard by cloning this GitHub repo: @@ -122,7 +108,7 @@ The rules from rector that are applied are set inside the config file: `rector.p The option `--dry-run` displays errors found, but code is not automatically fixed. To run rector for `magento` projects you need to: -- Specify the magento path and the autoload file for the magento project: +- Specify the magento path and the autoload file for the magento project: ```bash vendor/bin/rector process MAGENTO_PATH --dry-run --autoload-file MAGENTO_AUTOLOAD_FILE ``` diff --git a/composer.json b/composer.json index 36eabf64..67899921 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "version": "33", "require": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2 || ^1.0", "webonyx/graphql-php": "^15.0", "ext-simplexml": "*", "ext-dom": "*", @@ -35,13 +36,9 @@ "Magento2Framework\\": "Magento2Framework/" } }, - "scripts": { - "post-install-cmd": "vendor/bin/phpcs --config-set installed_paths ../../..,../../magento/php-compatibility-fork/PHPCompatibility", - "post-update-cmd": "vendor/bin/phpcs --config-set installed_paths ../../..,../../magento/php-compatibility-fork/PHPCompatibility" - }, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": false + "dealerdirect/phpcodesniffer-composer-installer": true } } } diff --git a/composer.lock b/composer.lock index bac99425..334ccb71 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2538347534e520207948a130ccd78862", + "content-hash": "eb76f91be26c872c1f30436de62676aa", "packages": [ { "name": "dealerdirect/phpcodesniffer-composer-installer",