File tree 5 files changed +193
-2
lines changed
5 files changed +193
-2
lines changed Original file line number Diff line number Diff line change 75
75
76
76
- name : Run ESLint
77
77
run : npm run eslint -- eslint/rules
78
+ rector :
79
+ runs-on : ubuntu-latest
80
+ name : Rector tests
81
+
82
+ steps :
83
+ - name : Setup node
84
+ uses : actions/setup-node@v2
85
+ with :
86
+ node-version : ' 16'
87
+
88
+ - uses : actions/checkout@v2
89
+
90
+ - name : Install dependencies
91
+ run : composer install
92
+
93
+ - name : Run rector
94
+ run : vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php
Original file line number Diff line number Diff line change @@ -112,6 +112,25 @@ You can execute ESLint as follows:
112
112
npm run eslint -- path/to/analyze
113
113
```
114
114
115
+ ### RECTOR PHP
116
+ From ` 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 ` displays errors found, but code is not automatically fixed.
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
+
115
134
## License
116
135
117
136
Each Magento source file included in this distribution is licensed under the OSL-3.0 license.
Original file line number Diff line number Diff line change 13
13
"ext-simplexml" : " *" ,
14
14
"ext-dom" : " *" ,
15
15
"phpcompatibility/php-compatibility" : " ^9.3" ,
16
- "squizlabs/php_codesniffer" : " ^3.6"
16
+ "squizlabs/php_codesniffer" : " ^3.6" ,
17
+ "rector/rector" : " ^0.12.4"
17
18
},
18
19
"require-dev" : {
19
20
"phpunit/phpunit" : " ^9.5.8"
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ use Rector \Core \Configuration \Option ;
6
+ use Rector \Core \ValueObject \PhpVersion ;
7
+ use Rector \Php80 \Rector \Class_ \StringableForToStringRector ;
8
+ use Rector \Php80 \Rector \ClassMethod \FinalPrivateToPrivateVisibilityRector ;
9
+ use Rector \Php80 \Rector \ClassMethod \OptionalParametersAfterRequiredRector ;
10
+ use Rector \Php80 \Rector \ClassMethod \SetStateToStaticRector ;
11
+ use Rector \Php81 \Rector \FuncCall \Php81ResourceReturnToObjectRector ;
12
+ use Symfony \Component \DependencyInjection \Loader \Configurator \ContainerConfigurator ;
13
+
14
+ return static function (ContainerConfigurator $ containerConfigurator ): void {
15
+ // get parameters
16
+ $ parameters = $ containerConfigurator ->parameters ();
17
+
18
+ $ parameters ->set (Option::PHP_VERSION_FEATURES , PhpVersion::PHP_80 );
19
+ $ parameters ->set (Option::PHP_VERSION_FEATURES , PhpVersion::PHP_81 );
20
+
21
+ // get services (needed for register a single rule)
22
+ $ services = $ containerConfigurator ->services ();
23
+
24
+ // register a single rule
25
+ $ services ->set (FinalPrivateToPrivateVisibilityRector::class);
26
+ $ services ->set (OptionalParametersAfterRequiredRector::class);
27
+ $ services ->set (SetStateToStaticRector::class);
28
+ $ services ->set (StringableForToStringRector::class);
29
+ $ services ->set (Php81ResourceReturnToObjectRector::class);
30
+ };
You can’t perform that action at this time.
0 commit comments