From 629197465c739bb3262657d0b714885654387e14 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Tue, 4 Feb 2020 15:45:32 +0100 Subject: [PATCH 1/6] mirror phpstan scoper.php.inc change --- compiler/build/scoper.inc.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/build/scoper.inc.php b/compiler/build/scoper.inc.php index 648f6d91bcb..b33814df164 100644 --- a/compiler/build/scoper.inc.php +++ b/compiler/build/scoper.inc.php @@ -17,6 +17,11 @@ ->in(__DIR__ . '/../../vendor/jetbrains/phpstorm-stubs'); foreach ($stubFinder->getIterator() as $fileInfo) { + // mirrors https://github.com/phpstan/phpstan-src/commit/04f777bc4445725d17dac65c989400485454b145 + if ($file->getPathName() === '../../vendor/jetbrains/phpstorm-stubs/PhpStormStubsMap.php') { + continue; + } + /** @var SplFileInfo $fileInfo */ $stubs[] = $fileInfo->getPathName(); } From 51a5b21315e22b98a2424a670bf0544383ebf88d Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Tue, 4 Feb 2020 15:46:00 +0100 Subject: [PATCH 2/6] composer: use phpstan 0.12.8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 09d6753f866..28b6c6e4bac 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "nikic/php-parser": "^4.3", "ondram/ci-detector": "^3.1", "phpstan/phpdoc-parser": "^0.4", - "phpstan/phpstan": "0.12.7", + "phpstan/phpstan": "^0.12.8", "phpstan/phpstan-phpunit": "^0.12", "sebastian/diff": "^3.0", "symfony/console": "^4.4|^5.0", From 1b45b08196d0f12475f1bb50c22cbdbb45b1e6d6 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Tue, 4 Feb 2020 15:56:49 +0100 Subject: [PATCH 3/6] update to phpstan 0.12.9 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 28b6c6e4bac..c966ee89de7 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "nikic/php-parser": "^4.3", "ondram/ci-detector": "^3.1", "phpstan/phpdoc-parser": "^0.4", - "phpstan/phpstan": "^0.12.8", + "phpstan/phpstan": "^0.12.9", "phpstan/phpstan-phpunit": "^0.12", "sebastian/diff": "^3.0", "symfony/console": "^4.4|^5.0", From e706559d1f7322e42628e2e3b2cd192faa0cc06a Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Thu, 6 Feb 2020 00:54:50 +0100 Subject: [PATCH 4/6] add missing deps --- tests/bootstrap.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ab8d962f86e..4a94eea31d9 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -6,6 +6,8 @@ require_once __DIR__ . '/../vendor/autoload.php'; +require_once 'phar://vendor/phpstan/phpstan/phpstan.phar/vendor/jetbrains/phpstorm-stubs/PhpStormStubsMap.php'; + // silent deprecations, since we test them error_reporting(E_ALL ^ E_DEPRECATED); From 3b2cfbf2c7533285807f155bf75dfc951ff6a70f Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Thu, 6 Feb 2020 01:15:14 +0100 Subject: [PATCH 5/6] fix array expr --- .github/workflows/test_with_doctrine.yaml | 1 + bin/rector | 3 ++- .../ChangeSnakedFixtureNameToCamelRector.php | 24 +++++++++++++------ rector-ci.yaml | 6 ++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test_with_doctrine.yaml b/.github/workflows/test_with_doctrine.yaml index c1e5ce9e88f..34b2200de67 100644 --- a/.github/workflows/test_with_doctrine.yaml +++ b/.github/workflows/test_with_doctrine.yaml @@ -27,6 +27,7 @@ jobs: # remove phsptan config to prevent rector loading configs rm phpstan.neon + rm orm/phpstan.neon.dist # do not intall doctrine/orm phpstan, it conflicts with Retor's one composer install -d orm --no-dev diff --git a/bin/rector b/bin/rector index c2ce52bf3df..00538738dfc 100755 --- a/bin/rector +++ b/bin/rector @@ -19,7 +19,8 @@ error_reporting(E_ALL); ini_set('display_errors', 'stderr'); gc_disable(); -define('__RECTOR_RUNNING__', true); +// temporary hackaround +@include_once 'phar://vendor/phpstan/phpstan/phpstan.phar/vendor/jetbrains/phpstorm-stubs/PhpStormStubsMap.php'; // Require Composer autoload.php $autoloadIncluder = new AutoloadIncluder(); diff --git a/packages/CakePHP/src/Rector/Name/ChangeSnakedFixtureNameToCamelRector.php b/packages/CakePHP/src/Rector/Name/ChangeSnakedFixtureNameToCamelRector.php index e6ef88e9891..d9f08261ab5 100644 --- a/packages/CakePHP/src/Rector/Name/ChangeSnakedFixtureNameToCamelRector.php +++ b/packages/CakePHP/src/Rector/Name/ChangeSnakedFixtureNameToCamelRector.php @@ -5,6 +5,7 @@ namespace Rector\CakePHP\Rector\Name; use PhpParser\Node; +use PhpParser\Node\Expr\Array_; use PhpParser\Node\Scalar\String_; use PhpParser\Node\Stmt\Property; use Rector\NodeTypeResolver\Node\AttributeKey; @@ -13,6 +14,8 @@ use Rector\RectorDefinition\RectorDefinition; /** + * @see \Rector\CakePHP\Tests\Rector\Name\ChangeSnakedFixtureNameToCamel\ChangeSnakedFixtureNameToCamelTest + * * @see https://book.cakephp.org/3.0/en/appendices/3-7-migration-guide.html */ final class ChangeSnakedFixtureNameToCamelRector extends AbstractRector @@ -62,21 +65,27 @@ public function refactor(Node $node): ?Node return null; } - foreach ($node->props as $i => $prop) { - if (! isset($prop->default->items)) { + foreach ($node->props as $prop) { + if (! $prop->default instanceof Array_) { continue; } - foreach ($prop->default->items as $j => $item) { - $node->props[$i]->default->items[$j]->value = $this->renameFixtureName($item->value); + + foreach ($prop->default->items as $item) { + if (! $item->value instanceof String_) { + continue; + } + + $this->renameFixtureName($item->value); } } return $node; } - private function renameFixtureName(String_ $name): String_ + private function renameFixtureName(String_ $string): void { - [$prefix, $table] = explode('.', $name->value); + [$prefix, $table] = explode('.', $string->value); + $table = array_map( function ($token): string { $tokens = explode('_', $token); @@ -85,8 +94,9 @@ function ($token): string { }, explode('/', $table) ); + $table = implode('/', $table); - return new String_(sprintf('%s.%s', $prefix, $table), $name->getAttributes()); + $string->value = sprintf('%s.%s', $prefix, $table); } } diff --git a/rector-ci.yaml b/rector-ci.yaml index 57c537c26c2..d3097981a84 100644 --- a/rector-ci.yaml +++ b/rector-ci.yaml @@ -6,9 +6,9 @@ parameters: - 'nette-utils-code-quality' paths: - - 'src' - - 'packages' - - 'tests' + - 'src/Application' +# - 'packages' +# - 'tests' exclude_paths: - '/Fixture/' From 9e0ca0f2340d7eb250cca78d7117e4f23a6dcfb3 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Thu, 6 Feb 2020 17:09:57 +0100 Subject: [PATCH 6/6] skip doctrine for now, impossible to fix --- .../test_with_doctrine.yaml | 2 ++ bin/rector | 2 +- rector-ci.yaml | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) rename .github/{workflows => inactive_workflows}/test_with_doctrine.yaml (92%) diff --git a/.github/workflows/test_with_doctrine.yaml b/.github/inactive_workflows/test_with_doctrine.yaml similarity index 92% rename from .github/workflows/test_with_doctrine.yaml rename to .github/inactive_workflows/test_with_doctrine.yaml index 34b2200de67..81deb3d2a01 100644 --- a/.github/workflows/test_with_doctrine.yaml +++ b/.github/inactive_workflows/test_with_doctrine.yaml @@ -1,3 +1,5 @@ +# temporary disabled till PHPStan autolaod bug is fixed +# https://github.com/rectorphp/rector/pull/2800 name: Test With Doctrine on: diff --git a/bin/rector b/bin/rector index 00538738dfc..6b718da19af 100755 --- a/bin/rector +++ b/bin/rector @@ -20,7 +20,7 @@ ini_set('display_errors', 'stderr'); gc_disable(); // temporary hackaround -@include_once 'phar://vendor/phpstan/phpstan/phpstan.phar/vendor/jetbrains/phpstorm-stubs/PhpStormStubsMap.php'; +include_once 'phar://vendor/phpstan/phpstan/phpstan.phar/vendor/jetbrains/phpstorm-stubs/PhpStormStubsMap.php'; // Require Composer autoload.php $autoloadIncluder = new AutoloadIncluder(); diff --git a/rector-ci.yaml b/rector-ci.yaml index d3097981a84..57c537c26c2 100644 --- a/rector-ci.yaml +++ b/rector-ci.yaml @@ -6,9 +6,9 @@ parameters: - 'nette-utils-code-quality' paths: - - 'src/Application' -# - 'packages' -# - 'tests' + - 'src' + - 'packages' + - 'tests' exclude_paths: - '/Fixture/'