Skip to content

Commit 4b3df3e

Browse files
committed
AC-1740: Add rectorphp as a dependency to magento-coding-standard and run it as part of the GitHub actions
1 parent d463a5a commit 4b3df3e

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ jobs:
9191
run: composer install
9292

9393
- name: Run rector
94-
run: vendor/bin/rector process --dry-run
94+
run: vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autload-file vendor/squizlabs/php_codesniffer/autoload.php

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,25 @@ You can execute ESLint as follows:
112112
npm run eslint -- path/to/analyze
113113
```
114114

115+
### RECTOR PHP
116+
Inside `magento-condign-standard` project. You can execute rector php as follows:
117+
```bash
118+
vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php
119+
```
120+
The rules from rector that are applied are set inside the config file: `rector.php`
121+
122+
The option `--dry-run` allows that the errors are displayed, but the code is not automatically refactored.
123+
124+
To run rector for `magento` projects you need to:
125+
- Specify the magento path and the autoload file for the magento project:
126+
```bash
127+
vendor/bin/rector process MAGENTO_PATH --dry-run --autoload-file MAGENTO_AUTOLOAD_FILE
128+
```
129+
Example:
130+
```bash
131+
vendor/bin/rector process magento2ce/app/code/Magento/Cms/Model --dry-run --autoload-file magento2ce/vendor/autoload.php
132+
```
133+
115134
## License
116135

117136
Each Magento source file included in this distribution is licensed under the OSL-3.0 license.

rector.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
return static function (ContainerConfigurator $containerConfigurator): void {
1515
// get parameters
1616
$parameters = $containerConfigurator->parameters();
17-
$parameters->set(Option::PATHS, [
18-
__DIR__ . '/Magento2',
19-
__DIR__ . '/Magento2Framework',
20-
__DIR__ . '/PHP_CodeSniffer'
21-
]);
22-
$parameters->set(Option::BOOTSTRAP_FILES, [__DIR__ . '/vendor/squizlabs/php_codesniffer/autoload.php']);
2317

2418
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
2519
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81);

0 commit comments

Comments
 (0)