Skip to content

Commit afe826d

Browse files
committed
Use a composer plugin to register the standard
1 parent a0b6fc9 commit afe826d

File tree

3 files changed

+4
-21
lines changed

3 files changed

+4
-21
lines changed

README.md

+1-15
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@ To use within your Magento 2 project you can use:
1010
composer require --dev magento/magento-coding-standard
1111
```
1212

13-
Due to security, when installed this way the Magento standard for phpcs cannot be added automatically.
14-
You can achieve this by adding the following to your project's `composer.json`:
15-
16-
```json
17-
"scripts": {
18-
"post-install-cmd": [
19-
"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)"
20-
],
21-
"post-update-cmd": [
22-
"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)"
23-
]
24-
}
25-
```
26-
2713
### Installation for development
2814

2915
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
122108
The option `--dry-run` displays errors found, but code is not automatically fixed.
123109

124110
To run rector for `magento` projects you need to:
125-
- Specify the magento path and the autoload file for the magento project:
111+
- Specify the magento path and the autoload file for the magento project:
126112
```bash
127113
vendor/bin/rector process MAGENTO_PATH --dry-run --autoload-file MAGENTO_AUTOLOAD_FILE
128114
```

composer.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"version": "32",
1010
"require": {
1111
"php": "~8.1.0 || ~8.2.0",
12+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2 || ^1.0",
1213
"webonyx/graphql-php": "^15.0",
1314
"ext-simplexml": "*",
1415
"ext-dom": "*",
@@ -35,13 +36,9 @@
3536
"Magento2Framework\\": "Magento2Framework/"
3637
}
3738
},
38-
"scripts": {
39-
"post-install-cmd": "vendor/bin/phpcs --config-set installed_paths ../../..,../../phpcompatibility/php-compatibility/PHPCompatibility",
40-
"post-update-cmd": "vendor/bin/phpcs --config-set installed_paths ../../..,../../phpcompatibility/php-compatibility/PHPCompatibility"
41-
},
4239
"config": {
4340
"allow-plugins": {
44-
"dealerdirect/phpcodesniffer-composer-installer": false
41+
"dealerdirect/phpcodesniffer-composer-installer": true
4542
}
4643
}
4744
}

composer.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)