Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare to Rector next 2.0 with PHPStan 2 and PHPParser 5 #302

Merged
merged 9 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading