From d3dc3f4ebc67f6d97a535854faf7ffe5de7d3276 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 16 Nov 2021 15:04:43 +0100 Subject: [PATCH 01/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- .github/workflows/php.yml | 4 ++ composer.json | 3 +- composer.lock | 126 +++++++++++++++++++++++++++++++++++++- 3 files changed, 131 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index a22f59c2..eaafb162 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -58,6 +58,10 @@ jobs: - name: Run framework suite run: vendor/bin/phpcs --standard=Magento2Framework Magento2/Helpers Magento2/Sniffs Magento2Framework/Sniffs + + - name: Run rector + run: vendor/bin/rector process --dry-run + js: runs-on: ubuntu-latest name: Javascript tests diff --git a/composer.json b/composer.json index 36a71bbf..a913150c 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ "squizlabs/php_codesniffer": "^3.6", "webonyx/graphql-php": "^14.9", "ext-simplexml": "*", - "ext-dom": "*" + "ext-dom": "*", + "rector/rector": "^0.12.4" }, "require-dev": { "phpunit/phpunit": "^9.5.8" diff --git a/composer.lock b/composer.lock index 8346f504..d7cbfb9d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,132 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ccc9b708a197fb981876af4623ec26a3", + "content-hash": "d86f5662d65e6586d8e61e5e0aad77c0", "packages": [ + { + "name": "phpstan/phpstan", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "bcea0ae85868a89d5789c75f012c93129f842934" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/bcea0ae85868a89d5789c75f012c93129f842934", + "reference": "bcea0ae85868a89d5789c75f012c93129f842934", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.1.2" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2021-11-09T12:41:09+00:00" + }, + { + "name": "rector/rector", + "version": "0.12.4", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "d7d4659acae85a9ba5b8b75d4dadb998ffed2a48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/d7d4659acae85a9ba5b8b75d4dadb998ffed2a48", + "reference": "d7d4659acae85a9ba5b8b75d4dadb998ffed2a48", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0", + "phpstan/phpstan": "^1.1.1" + }, + "conflict": { + "phpstan/phpdoc-parser": "<1.2", + "rector/rector-cakephp": "*", + "rector/rector-doctrine": "*", + "rector/rector-laravel": "*", + "rector/rector-nette": "*", + "rector/rector-phpoffice": "*", + "rector/rector-phpunit": "*", + "rector/rector-prefixed": "*", + "rector/rector-symfony": "*" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.12-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Prefixed and PHP 7.1 downgraded version of rector/rector", + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/0.12.4" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2021-11-15T14:06:50+00:00" + }, { "name": "squizlabs/php_codesniffer", "version": "3.6.1", From 874884f45c6cbff7ef22f792ef0c1a4257db6b59 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 16 Nov 2021 15:20:50 +0100 Subject: [PATCH 02/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index eaafb162..00f2bcbc 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -60,7 +60,7 @@ jobs: run: vendor/bin/phpcs --standard=Magento2Framework Magento2/Helpers Magento2/Sniffs Magento2Framework/Sniffs - name: Run rector - run: vendor/bin/rector process --dry-run + run: vendor/bin/rector process . --dry-run js: runs-on: ubuntu-latest From cdf641edb8736981159098f20adf9da98e116fcb Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 16 Nov 2021 15:42:25 +0100 Subject: [PATCH 03/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- rector.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 rector.php diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..c156f125 --- /dev/null +++ b/rector.php @@ -0,0 +1,28 @@ +parameters(); + $parameters->set(Option::PATHS, [ + __DIR__ . '/src' + ]); + + // Define what rule sets will be applied + $containerConfigurator->import(SetList::PHP_73); + $containerConfigurator->import(SetList::PHP_74); + $containerConfigurator->import(SetList::PHP_80); + $containerConfigurator->import(SetList::PHP_81); + + // get services (needed for register a single rule) + // $services = $containerConfigurator->services(); + + // register a single rule + // $services->set(TypedPropertyRector::class); +}; From b669d8c22c4af75a6ef67a6335bf1c047b81467c Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 16 Nov 2021 15:51:02 +0100 Subject: [PATCH 04/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- rector.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/rector.php b/rector.php index c156f125..cae6fba3 100644 --- a/rector.php +++ b/rector.php @@ -15,8 +15,6 @@ ]); // Define what rule sets will be applied - $containerConfigurator->import(SetList::PHP_73); - $containerConfigurator->import(SetList::PHP_74); $containerConfigurator->import(SetList::PHP_80); $containerConfigurator->import(SetList::PHP_81); From 372da919ecda7a7e2f277590f61266506596020d Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 16 Nov 2021 16:07:37 +0100 Subject: [PATCH 05/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- .github/workflows/php.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 00f2bcbc..9f9e1496 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -58,9 +58,6 @@ jobs: - name: Run framework suite run: vendor/bin/phpcs --standard=Magento2Framework Magento2/Helpers Magento2/Sniffs Magento2Framework/Sniffs - - - name: Run rector - run: vendor/bin/rector process . --dry-run js: runs-on: ubuntu-latest @@ -79,3 +76,11 @@ jobs: - name: Run ESLint run: npm run eslint -- eslint/rules + + rector: + runs-on: ubuntu-latest + name: Rector tests + + steps: + - name: Run rector + run: vendor/bin/rector process . --dry-run From 503878b47656843bd8cd677230e20acdc46ef67f Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 16 Nov 2021 16:22:58 +0100 Subject: [PATCH 06/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- .github/workflows/php.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 9f9e1496..fdfff385 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -82,5 +82,15 @@ jobs: name: Rector tests steps: + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: '16' + + - uses: actions/checkout@v2 + + - name: Install dependencies + run: composer install + - name: Run rector run: vendor/bin/rector process . --dry-run From 01e243e228e4659aba438f52deb4c8380389b1aa Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 16 Nov 2021 16:25:53 +0100 Subject: [PATCH 07/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- .github/workflows/php.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index fdfff385..7d676673 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -58,7 +58,6 @@ jobs: - name: Run framework suite run: vendor/bin/phpcs --standard=Magento2Framework Magento2/Helpers Magento2/Sniffs Magento2Framework/Sniffs - js: runs-on: ubuntu-latest name: Javascript tests @@ -76,7 +75,6 @@ jobs: - name: Run ESLint run: npm run eslint -- eslint/rules - rector: runs-on: ubuntu-latest name: Rector tests From cda190fcd03333274dd3880c189c251777b2ea0a Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 16 Nov 2021 17:00:26 +0100 Subject: [PATCH 08/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- .github/workflows/php.yml | 2 +- rector.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 7d676673..9caefb77 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -91,4 +91,4 @@ jobs: run: composer install - name: Run rector - run: vendor/bin/rector process . --dry-run + run: vendor/bin/rector process --dry-run diff --git a/rector.php b/rector.php index cae6fba3..10dff94c 100644 --- a/rector.php +++ b/rector.php @@ -3,7 +3,7 @@ declare(strict_types=1); use Rector\Core\Configuration\Option; -use Rector\Php74\Rector\Property\TypedPropertyRector; +use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\SetList; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; @@ -11,8 +11,11 @@ // get parameters $parameters = $containerConfigurator->parameters(); $parameters->set(Option::PATHS, [ - __DIR__ . '/src' + __DIR__ . '/Magento2', + __DIR__ . '/Magento2Framework', + __DIR__ . '/PHP_CodeSniffer', ]); + $parameters->set(Option::BOOTSTRAP_FILES, [__DIR__ . '/vendor/squizlabs/php_codesniffer/autoload.php']); // Define what rule sets will be applied $containerConfigurator->import(SetList::PHP_80); From a4595dfde20da30f446cf5532e12b47136628abb Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Wed, 17 Nov 2021 10:30:17 +0100 Subject: [PATCH 09/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- rector.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rector.php b/rector.php index 10dff94c..3350f685 100644 --- a/rector.php +++ b/rector.php @@ -17,6 +17,9 @@ ]); $parameters->set(Option::BOOTSTRAP_FILES, [__DIR__ . '/vendor/squizlabs/php_codesniffer/autoload.php']); + $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80); + $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81); + // Define what rule sets will be applied $containerConfigurator->import(SetList::PHP_80); $containerConfigurator->import(SetList::PHP_81); From f7fdb0278f44166d305a0a6fb0f895a948524911 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Wed, 17 Nov 2021 10:35:30 +0100 Subject: [PATCH 10/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- rector.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/rector.php b/rector.php index 3350f685..10dff94c 100644 --- a/rector.php +++ b/rector.php @@ -17,9 +17,6 @@ ]); $parameters->set(Option::BOOTSTRAP_FILES, [__DIR__ . '/vendor/squizlabs/php_codesniffer/autoload.php']); - $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80); - $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81); - // Define what rule sets will be applied $containerConfigurator->import(SetList::PHP_80); $containerConfigurator->import(SetList::PHP_81); From a18b7f2a5be7209d0cd0895e8844b9e7fd5ee565 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Thu, 18 Nov 2021 12:13:12 +0100 Subject: [PATCH 11/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard --- rector.php | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 10dff94c..83195b31 100644 --- a/rector.php +++ b/rector.php @@ -4,6 +4,23 @@ use Rector\Core\Configuration\Option; use Rector\Core\ValueObject\PhpVersion; +use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector; +use Rector\Php80\Rector\FuncCall\ClassOnObjectRector; +use Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector; +use Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector; +use Rector\Php80\Rector\FunctionLike\UnionTypesRector; +use Rector\Php80\Rector\Identical\StrEndsWithRector; +use Rector\Php80\Rector\Identical\StrStartsWithRector; +use Rector\Php80\Rector\NotIdentical\StrContainsRector; +use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector; +use Rector\Php80\Rector\Ternary\GetDebugTypeRector; +use Rector\Php81\Rector\Class_\MyCLabsClassToEnumRector; +use Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector; +use Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector; +use Rector\Php81\Rector\ClassMethod\NewInInitializerRector; +use Rector\Php81\Rector\FunctionLike\IntersectionTypesRector; +use Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector; +use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; use Rector\Set\ValueObject\SetList; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; @@ -13,10 +30,33 @@ $parameters->set(Option::PATHS, [ __DIR__ . '/Magento2', __DIR__ . '/Magento2Framework', - __DIR__ . '/PHP_CodeSniffer', + __DIR__ . '/PHP_CodeSniffer' ]); $parameters->set(Option::BOOTSTRAP_FILES, [__DIR__ . '/vendor/squizlabs/php_codesniffer/autoload.php']); + $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80); + $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81); + + $parameters->set(Option::SKIP, [ + ReadOnlyPropertyRector::class, + StrContainsRector::class, + UnionTypesRector::class, + StrStartsWithRector::class, + StrEndsWithRector::class, + FinalizePublicClassConstantRector::class, + RemoveUnusedVariableInCatchRector::class, + ClassOnObjectRector::class, + Php8ResourceReturnToObjectRector::class, + TokenGetAllToObjectRector::class, + GetDebugTypeRector::class, + ChangeSwitchToMatchRector::class, + NewInInitializerRector::class, + IntersectionTypesRector::class, + MyCLabsMethodCallToEnumConstRector::class, + MyCLabsClassToEnumRector::class, + SpatieEnumClassToEnumRector::class + ]); + // Define what rule sets will be applied $containerConfigurator->import(SetList::PHP_80); $containerConfigurator->import(SetList::PHP_81); From a5ad00bc074bf7d9c88a172970cff5b2c4dce3a5 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Fri, 19 Nov 2021 14:30:49 +0100 Subject: [PATCH 12/18] AC-1740 --- composer.json | 3 +- composer.lock | 126 +------------------------------------------------- 2 files changed, 2 insertions(+), 127 deletions(-) diff --git a/composer.json b/composer.json index a913150c..36a71bbf 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,7 @@ "squizlabs/php_codesniffer": "^3.6", "webonyx/graphql-php": "^14.9", "ext-simplexml": "*", - "ext-dom": "*", - "rector/rector": "^0.12.4" + "ext-dom": "*" }, "require-dev": { "phpunit/phpunit": "^9.5.8" diff --git a/composer.lock b/composer.lock index d7cbfb9d..8346f504 100644 --- a/composer.lock +++ b/composer.lock @@ -4,132 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d86f5662d65e6586d8e61e5e0aad77c0", + "content-hash": "ccc9b708a197fb981876af4623ec26a3", "packages": [ - { - "name": "phpstan/phpstan", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "bcea0ae85868a89d5789c75f012c93129f842934" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/bcea0ae85868a89d5789c75f012c93129f842934", - "reference": "bcea0ae85868a89d5789c75f012c93129f842934", - "shasum": "" - }, - "require": { - "php": "^7.1|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "support": { - "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.1.2" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://github.com/phpstan", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" - } - ], - "time": "2021-11-09T12:41:09+00:00" - }, - { - "name": "rector/rector", - "version": "0.12.4", - "source": { - "type": "git", - "url": "https://github.com/rectorphp/rector.git", - "reference": "d7d4659acae85a9ba5b8b75d4dadb998ffed2a48" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/d7d4659acae85a9ba5b8b75d4dadb998ffed2a48", - "reference": "d7d4659acae85a9ba5b8b75d4dadb998ffed2a48", - "shasum": "" - }, - "require": { - "php": "^7.1|^8.0", - "phpstan/phpstan": "^1.1.1" - }, - "conflict": { - "phpstan/phpdoc-parser": "<1.2", - "rector/rector-cakephp": "*", - "rector/rector-doctrine": "*", - "rector/rector-laravel": "*", - "rector/rector-nette": "*", - "rector/rector-phpoffice": "*", - "rector/rector-phpunit": "*", - "rector/rector-prefixed": "*", - "rector/rector-symfony": "*" - }, - "bin": [ - "bin/rector" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "0.12-dev" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Prefixed and PHP 7.1 downgraded version of rector/rector", - "support": { - "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.12.4" - }, - "funding": [ - { - "url": "https://github.com/tomasvotruba", - "type": "github" - } - ], - "time": "2021-11-15T14:06:50+00:00" - }, { "name": "squizlabs/php_codesniffer", "version": "3.6.1", From 5ebccb08c840c011d9c21863ae1b0caa8e35e9dd Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Fri, 19 Nov 2021 14:33:07 +0100 Subject: [PATCH 13/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard and run it as part of the GitHub actions --- composer.json | 3 +- composer.lock | 126 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 127 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3ad22f70..9b59a792 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "ext-simplexml": "*", "ext-dom": "*", "phpcompatibility/php-compatibility": "^9.3", - "squizlabs/php_codesniffer": "^3.6" + "squizlabs/php_codesniffer": "^3.6", + "rector/rector": "^0.12.4" }, "require-dev": { "phpunit/phpunit": "^9.5.8" diff --git a/composer.lock b/composer.lock index 47559dbd..0e07e918 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": "2e8abe33e655572c04bb6cdc53f88626", + "content-hash": "61cf9451f97627aeb7908e83b51a1d82", "packages": [ { "name": "phpcompatibility/php-compatibility", @@ -68,6 +68,130 @@ }, "time": "2019-12-27T09:44:58+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "cbe085f9fdead5b6d62e4c022ca52dc9427a10ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cbe085f9fdead5b6d62e4c022ca52dc9427a10ee", + "reference": "cbe085f9fdead5b6d62e4c022ca52dc9427a10ee", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.2.0" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2021-11-18T14:09:01+00:00" + }, + { + "name": "rector/rector", + "version": "0.12.4", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "d7d4659acae85a9ba5b8b75d4dadb998ffed2a48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/d7d4659acae85a9ba5b8b75d4dadb998ffed2a48", + "reference": "d7d4659acae85a9ba5b8b75d4dadb998ffed2a48", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0", + "phpstan/phpstan": "^1.1.1" + }, + "conflict": { + "phpstan/phpdoc-parser": "<1.2", + "rector/rector-cakephp": "*", + "rector/rector-doctrine": "*", + "rector/rector-laravel": "*", + "rector/rector-nette": "*", + "rector/rector-phpoffice": "*", + "rector/rector-phpunit": "*", + "rector/rector-prefixed": "*", + "rector/rector-symfony": "*" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.12-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Prefixed and PHP 7.1 downgraded version of rector/rector", + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/0.12.4" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2021-11-15T14:06:50+00:00" + }, { "name": "squizlabs/php_codesniffer", "version": "3.6.1", From d463a5aebf3b928da12a1ec6dd2721dedebd2930 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Fri, 19 Nov 2021 15:23:26 +0100 Subject: [PATCH 14/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard and run it as part of the GitHub actions --- rector.php | 55 +++++++++++------------------------------------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/rector.php b/rector.php index 83195b31..7ed6d2fe 100644 --- a/rector.php +++ b/rector.php @@ -4,24 +4,11 @@ use Rector\Core\Configuration\Option; use Rector\Core\ValueObject\PhpVersion; -use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector; -use Rector\Php80\Rector\FuncCall\ClassOnObjectRector; -use Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector; -use Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector; -use Rector\Php80\Rector\FunctionLike\UnionTypesRector; -use Rector\Php80\Rector\Identical\StrEndsWithRector; -use Rector\Php80\Rector\Identical\StrStartsWithRector; -use Rector\Php80\Rector\NotIdentical\StrContainsRector; -use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector; -use Rector\Php80\Rector\Ternary\GetDebugTypeRector; -use Rector\Php81\Rector\Class_\MyCLabsClassToEnumRector; -use Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector; -use Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector; -use Rector\Php81\Rector\ClassMethod\NewInInitializerRector; -use Rector\Php81\Rector\FunctionLike\IntersectionTypesRector; -use Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector; -use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; -use Rector\Set\ValueObject\SetList; +use Rector\Php80\Rector\Class_\StringableForToStringRector; +use Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector; +use Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector; +use Rector\Php80\Rector\ClassMethod\SetStateToStaticRector; +use Rector\Php81\Rector\FuncCall\Php81ResourceReturnToObjectRector; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { @@ -36,34 +23,14 @@ $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80); $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81); - - $parameters->set(Option::SKIP, [ - ReadOnlyPropertyRector::class, - StrContainsRector::class, - UnionTypesRector::class, - StrStartsWithRector::class, - StrEndsWithRector::class, - FinalizePublicClassConstantRector::class, - RemoveUnusedVariableInCatchRector::class, - ClassOnObjectRector::class, - Php8ResourceReturnToObjectRector::class, - TokenGetAllToObjectRector::class, - GetDebugTypeRector::class, - ChangeSwitchToMatchRector::class, - NewInInitializerRector::class, - IntersectionTypesRector::class, - MyCLabsMethodCallToEnumConstRector::class, - MyCLabsClassToEnumRector::class, - SpatieEnumClassToEnumRector::class - ]); - - // Define what rule sets will be applied - $containerConfigurator->import(SetList::PHP_80); - $containerConfigurator->import(SetList::PHP_81); // get services (needed for register a single rule) - // $services = $containerConfigurator->services(); + $services = $containerConfigurator->services(); // register a single rule - // $services->set(TypedPropertyRector::class); + $services->set(FinalPrivateToPrivateVisibilityRector::class); + $services->set(OptionalParametersAfterRequiredRector::class); + $services->set(SetStateToStaticRector::class); + $services->set(StringableForToStringRector::class); + $services->set(Php81ResourceReturnToObjectRector::class); }; From 4b3df3e6a690de4cddd3572387e2130d4cd99072 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Mon, 22 Nov 2021 16:11:36 +0100 Subject: [PATCH 15/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard and run it as part of the GitHub actions --- .github/workflows/php.yml | 2 +- README.md | 19 +++++++++++++++++++ rector.php | 6 ------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 9caefb77..db251e6f 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -91,4 +91,4 @@ jobs: run: composer install - name: Run rector - run: vendor/bin/rector process --dry-run + run: vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autload-file vendor/squizlabs/php_codesniffer/autoload.php diff --git a/README.md b/README.md index be9937d0..98dee90d 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,25 @@ You can execute ESLint as follows: npm run eslint -- path/to/analyze ``` +### RECTOR PHP +Inside `magento-condign-standard` project. You can execute rector php as follows: +```bash +vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php +``` +The rules from rector that are applied are set inside the config file: `rector.php` + +The option `--dry-run` allows that the errors are displayed, but the code is not automatically refactored. + +To run rector for `magento` projects you need to: +- 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 +``` +Example: +```bash +vendor/bin/rector process magento2ce/app/code/Magento/Cms/Model --dry-run --autoload-file magento2ce/vendor/autoload.php +``` + ## License Each Magento source file included in this distribution is licensed under the OSL-3.0 license. diff --git a/rector.php b/rector.php index 7ed6d2fe..502f7744 100644 --- a/rector.php +++ b/rector.php @@ -14,12 +14,6 @@ return static function (ContainerConfigurator $containerConfigurator): void { // get parameters $parameters = $containerConfigurator->parameters(); - $parameters->set(Option::PATHS, [ - __DIR__ . '/Magento2', - __DIR__ . '/Magento2Framework', - __DIR__ . '/PHP_CodeSniffer' - ]); - $parameters->set(Option::BOOTSTRAP_FILES, [__DIR__ . '/vendor/squizlabs/php_codesniffer/autoload.php']); $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80); $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81); From 692b23d62e763963f8a7502c552a230b723c82a9 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Mon, 22 Nov 2021 16:12:48 +0100 Subject: [PATCH 16/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard and run it as part of the GitHub actions --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index db251e6f..54a02483 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -91,4 +91,4 @@ jobs: run: composer install - name: Run rector - run: vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autload-file vendor/squizlabs/php_codesniffer/autoload.php + run: vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php From a10e77ce28e0f69a0517f6e1d011e847717c0a71 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 23 Nov 2021 09:28:26 +0100 Subject: [PATCH 17/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard and run it as part of the GitHub actions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 98dee90d..5a18833d 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run - ``` The rules from rector that are applied are set inside the config file: `rector.php` -The option `--dry-run` allows that the errors are displayed, but the code is not automatically refactored. +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: From 856d8ca15d7c561e1516d8095c51086b580697c8 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Tue, 23 Nov 2021 09:32:53 +0100 Subject: [PATCH 18/18] AC-1740: Add rectorphp as a dependency to magento-coding-standard and run it as part of the GitHub actions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a18833d..3cfd6c0a 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ npm run eslint -- path/to/analyze ``` ### RECTOR PHP -Inside `magento-condign-standard` project. You can execute rector php as follows: +From `magento-condign-standard` project, you can execute rector php as follows: ```bash vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php ```