diff --git a/composer.json b/composer.json index 78b40396e5..56772ab075 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ "phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^9.5.4", - "rector/rector": "^0.12.10", + "rector/rector": "0.12.5", "vaimo/composer-patches": "^4.22" }, "config": { diff --git a/composer.lock b/composer.lock index 7a0d9736a8..1b630b62f6 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": "1f5c5bbc5eb03552f6eacb4a4031a38a", + "content-hash": "886b912d42d02d217110cf59cb654a08", "packages": [ { "name": "clue/block-react", @@ -5777,21 +5777,21 @@ }, { "name": "rector/rector", - "version": "0.12.10", + "version": "0.12.5", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "8c823197becb3905e42b9d7f7849f1174e8b47cf" + "reference": "e50e40e0fe73b88a46f27e086441e1998ceeca3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/8c823197becb3905e42b9d7f7849f1174e8b47cf", - "reference": "8c823197becb3905e42b9d7f7849f1174e8b47cf", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/e50e40e0fe73b88a46f27e086441e1998ceeca3c", + "reference": "e50e40e0fe73b88a46f27e086441e1998ceeca3c", "shasum": "" }, "require": { "php": "^7.1|^8.0", - "phpstan/phpstan": "^1.3" + "phpstan/phpstan": "^1.1.1" }, "conflict": { "phpstan/phpdoc-parser": "<1.2", @@ -5825,7 +5825,7 @@ "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.10" + "source": "https://github.com/rectorphp/rector/tree/0.12.5" }, "funding": [ { @@ -5833,7 +5833,7 @@ "type": "github" } ], - "time": "2021-12-31T12:57:22+00:00" + "time": "2021-11-23T17:38:29+00:00" }, { "name": "sebastian/cli-parser", diff --git a/patches/AnonymousFunctionFactory.patch b/patches/AnonymousFunctionFactory.patch new file mode 100644 index 0000000000..0362229621 --- /dev/null +++ b/patches/AnonymousFunctionFactory.patch @@ -0,0 +1,44 @@ +@package rector/rector + +--- rules/Php72/NodeFactory/AnonymousFunctionFactory.php 2021-11-23 18:38:29.000000000 +0100 ++++ rules/Php72/NodeFactory/AnonymousFunctionFactory.php 2021-12-17 18:06:56.000000000 +0100 +@@ -174,13 +174,19 @@ + */ + private function cleanClosureUses(array $uses) : array + { +- $variableNames = \array_map(function ($use) : string { +- return (string) $this->nodeNameResolver->getName($use->var); +- }, $uses, []); +- $variableNames = \array_unique($variableNames); +- return \array_map(static function ($variableName) : ClosureUse { +- return new \PhpParser\Node\Expr\ClosureUse(new \PhpParser\Node\Expr\Variable($variableName)); +- }, $variableNames, []); ++ $uniqueUses = []; ++ foreach ($uses as $use) { ++ if (!\is_string($use->var->name)) { ++ continue; ++ } ++ $variableName = $use->var->name; ++ if (\array_key_exists($variableName, $uniqueUses)) { ++ continue; ++ } ++ ++ $uniqueUses[$variableName] = $use; ++ } ++ return \array_values($uniqueUses); + } + private function applyNestedUses(\PhpParser\Node\Expr\Closure $anonymousFunctionNode, \PhpParser\Node\Expr\Variable $useVariable) : \PhpParser\Node\Expr\Closure + { +@@ -269,7 +275,11 @@ + } + $parentArrowFunction = $this->betterNodeFinder->findParentType($subNode, \PhpParser\Node\Expr\ArrowFunction::class); + if ($parentArrowFunction instanceof \PhpParser\Node\Expr\ArrowFunction) { +- return !(bool) $this->betterNodeFinder->findParentType($parentArrowFunction, \PhpParser\Node\Expr\ArrowFunction::class); ++ $parentCallLike = $this->betterNodeFinder->findParentType($subNode, \PhpParser\Node\Expr\CallLike::class); ++ ++ if (! $parentCallLike instanceof \PhpParser\Node\Expr\CallLike) { ++ return ! (bool) $this->betterNodeFinder->findParentType($parentArrowFunction, \PhpParser\Node\Expr\ArrowFunction::class); ++ } + } + return \true; + }); diff --git a/patches/BooleanTypeMapper.patch b/patches/BooleanTypeMapper.patch deleted file mode 100644 index dfb247bb93..0000000000 --- a/patches/BooleanTypeMapper.patch +++ /dev/null @@ -1,13 +0,0 @@ -@package rector/rector - ---- packages/PHPStanStaticTypeMapper/TypeMapper/BooleanTypeMapper.php 2021-12-31 13:57:22.000000000 +0100 -+++ packages/PHPStanStaticTypeMapper/TypeMapper/BooleanTypeMapper.php 2022-01-05 00:05:20.000000000 +0100 -@@ -45,7 +45,7 @@ - } - if ($type instanceof \PHPStan\Type\Constant\ConstantBooleanType) { - // cannot be parent of union -- return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('true'); -+ return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('false'); - } - return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('bool'); - } diff --git a/patches/DowngradeTrailingCommasInFunctionCallsRector.patch b/patches/DowngradeTrailingCommasInFunctionCallsRector.patch new file mode 100644 index 0000000000..b29bf9a108 --- /dev/null +++ b/patches/DowngradeTrailingCommasInFunctionCallsRector.patch @@ -0,0 +1,13 @@ +@package rector/rector + +--- rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php 2021-12-17 08:20:27.000000000 +0100 ++++ rules/DowngradePhp73/Rector/FuncCall/DowngradeTrailingCommasInFunctionCallsRector.php 2021-12-17 08:20:45.000000000 +0100 +@@ -58,7 +58,7 @@ + */ + public function getNodeTypes() : array + { +- return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class]; ++ return [\PhpParser\Node\Expr\FuncCall::class, \PhpParser\Node\Expr\MethodCall::class, \PhpParser\Node\Expr\StaticCall::class, Node\Expr\New_::class]; + } + /** + * @param FuncCall|MethodCall|StaticCall $node diff --git a/patches/PHPStanNodeScopeResolver.patch b/patches/PHPStanNodeScopeResolver.patch new file mode 100644 index 0000000000..29413cdf88 --- /dev/null +++ b/patches/PHPStanNodeScopeResolver.patch @@ -0,0 +1,21 @@ +@package rector/rector + +--- packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php 2021-12-16 21:10:20.000000000 +0100 ++++ packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php 2021-12-16 21:10:27.000000000 +0100 +@@ -226,12 +226,12 @@ + { + // 1. get PHPStan locator + /** @var ClassReflector $classReflector */ +- $classReflector = $this->privatesAccessor->getPrivateProperty($nodeScopeResolver, 'classReflector'); ++ //$classReflector = $this->privatesAccessor->getPrivateProperty($nodeScopeResolver, 'classReflector'); + /** @var SourceLocator $sourceLocator */ +- $sourceLocator = $this->privatesAccessor->getPrivateProperty($classReflector, 'sourceLocator'); ++ //$sourceLocator = $this->privatesAccessor->getPrivateProperty($classReflector, 'sourceLocator'); + // 2. get Rector locator +- $aggregateSourceLocator = new \PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator([$sourceLocator, $this->renamedClassesSourceLocator, $this->parentAttributeSourceLocator]); +- $this->privatesAccessor->setPrivateProperty($classReflector, 'sourceLocator', $aggregateSourceLocator); ++ //$aggregateSourceLocator = new \PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator([$sourceLocator, $this->renamedClassesSourceLocator, $this->parentAttributeSourceLocator]); ++ //$this->privatesAccessor->setPrivateProperty($classReflector, 'sourceLocator', $aggregateSourceLocator); + } + private function createDummyClassScopeContext(\PHPStan\Analyser\MutatingScope $mutatingScope) : \PHPStan\Analyser\ScopeContext + { diff --git a/patches/TypeFactory.patch b/patches/TypeFactory.patch new file mode 100644 index 0000000000..2c61d1adda --- /dev/null +++ b/patches/TypeFactory.patch @@ -0,0 +1,14 @@ +@package rector/rector + +--- packages/NodeTypeResolver/PHPStan/Type/TypeFactory.php 2021-11-23 18:38:29.000000000 +0100 ++++ packages/NodeTypeResolver/PHPStan/Type/TypeFactory.php 2021-12-18 22:49:01.000000000 +0100 +@@ -122,9 +122,6 @@ + if ($type instanceof \PHPStan\Type\Constant\ConstantIntegerType) { + return new \PHPStan\Type\IntegerType(); + } +- if ($type instanceof \PHPStan\Type\Constant\ConstantBooleanType) { +- return new \PHPStan\Type\BooleanType(); +- } + return $type; + } + /**