Skip to content

Commit

Permalink
Prepare to Rector next 2.0 with PHPStan 2 and PHPParser 5 (#302)
Browse files Browse the repository at this point in the history
* Prepare to Rector 2.0 with PHPStan 2 and PHPParser 5
* rector config
* clean up upgrade process
* Fix cs
* try require php-parser 5 for phpunit conflict
* bump to phpunit ^10.5.38 for latest phpunit 10
* try require preload
* clean up composer.json
* bump to rector 2
  • Loading branch information
samsonasik authored Dec 12, 2024
1 parent 8ae2a46 commit 1c7d8de
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DEV_DEPENDENCIES = cakephp/cakephp:5.x-dev \
cakephp/cakephp-codesniffer:^5.0 \
mikey179/vfsstream:^1.6.8 \
phpunit/phpunit:^10.1
phpunit/phpunit:^10.5.38

install-dev:
composer require --dev $(DEV_DEPENDENCIES)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"php": "^8.1",
"cakephp/console": "^5.0",
"nette/utils": "^4.0",
"rector/rector": "~1.2.0",
"rector/rector": "~2.0.0",
"symfony/string": "^6.0 || ^7.0"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Rector/Rector/MethodCall/ArrayToFluentCallRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private function replaceArrayToFluentMethodCalls(
}

/**
* @param array<(\PhpParser\Node\Expr\ArrayItem|null)> $originalArrayItems
* @param array<(\PhpParser\Node\ArrayItem | null)> $originalArrayItems
* @param array<string, string> $arrayMap
*/
private function extractFluentMethods(array $originalArrayItems, array $arrayMap): ArrayItemsAndFluentClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use PhpParser\Node\Stmt\Declare_;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\Node\Stmt\Use_;
use PhpParser\Node\Stmt\UseUse;
use PhpParser\Node\UseItem;
use PhpParser\NodeTraverser;
use PHPStan\Type\ObjectType;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function refactor(Node $node): ?Node
$names = $this->resolveNamesFromStaticCalls($appUsesStaticCalls);
$uses = [];
foreach ($names as $name) {
$useUse = new UseUse(new Name($name));
$useUse = new UseItem(new Name($name));
$uses[] = new Use_([$useUse]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

use Cake\Utility\Inflector;
use PhpParser\Node;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\PropertyItem;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\Stmt\PropertyProperty;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand Down Expand Up @@ -76,7 +76,7 @@ public function refactor(Node $node): ?Node
return $node;
}

private function refactorPropertyWithArrayDefault(PropertyProperty $propertyProperty): void
private function refactorPropertyWithArrayDefault(PropertyItem $propertyProperty): void
{
if (! $propertyProperty->default instanceof Array_) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Rector/ValueObject/ArrayItemsAndFluentClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
final class ArrayItemsAndFluentClass
{
/**
* @param array<\PhpParser\Node\Expr\ArrayItem> $arrayItems
* @param array<\PhpParser\Node\ArrayItem> $arrayItems
* @param array<string, \PhpParser\Node\Expr> $fluentCalls
*/
public function __construct(
Expand All @@ -16,7 +16,7 @@ public function __construct(
}

/**
* @return array<\PhpParser\Node\Expr\ArrayItem>
* @return array<\PhpParser\Node\ArrayItem>
*/
public function getArrayItems(): array
{
Expand Down
2 changes: 2 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
error_reporting(-1);
date_default_timezone_set('UTC');

require dirname(__DIR__) . '/vendor/rector/rector/preload.php';

require dirname(__DIR__) . '/vendor/autoload.php';

require dirname(__DIR__) . '/config/bootstrap.php';
Expand Down

0 comments on commit 1c7d8de

Please sign in to comment.