Skip to content
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 .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
-
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
coverage: none

- uses: "ramsey/composer-install@v1"
Expand Down
21 changes: 5 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,16 @@
"license": "MIT",
"description": "Rector upgrades rules for PHP-Parser",
"require": {
"php": ">=8.1"
"php": ">=8.2"
},
"require-dev": {
"phpstan/extension-installer": "^1.1",
"phpunit/phpunit": "^10.0",
"rector/phpstan-rules": "^0.6",
"phpstan/phpstan": "^1.8.2",
"symplify/phpstan-rules": "^11.1",
"symplify/phpstan-extensions": "^11.1",
"phpstan/phpstan": "^2.0",
"symplify/easy-coding-standard": "^11.1",
"symplify/rule-doc-generator": "^11.1",
"rector/rector-src": "dev-main",
"phpstan/phpstan-strict-rules": "^1.3",
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpstan/phpstan-webmozart-assert": "^2.0",
"symplify/vendor-patches": "^11.1",
"rector/rector-debugging": "dev-main",
"rector/rector-generator": "^0.6.13",
"symplify/easy-ci": "11.2.0.72"
},
"autoload": {
Expand All @@ -34,13 +27,9 @@
}
},
"scripts": {
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify",
"phpstan": "vendor/bin/phpstan analyse --ansi",
"check-cs": "vendor/bin/ecs check --ansi",
"fix-cs": "vendor/bin/ecs check --fix --ansi",
"docs": [
"vendor/bin/rule-doc-generator generate src --output-file docs/rector_rules_overview.md --ansi",
"vendor/bin/ecs check-markdown docs/rector_rules_overview.md --ansi --fix"
]
"fix-cs": "vendor/bin/ecs check --fix --ansi"
},
"extra": {
"enable-patching": true,
Expand Down
9 changes: 0 additions & 9 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,4 @@
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$services = $rectorConfig->services();

$services->defaults()
->public()
->autowire()
->autoconfigure();

$services->load('Rector\\PhpParser\\', __DIR__ . '/../src')
->exclude([__DIR__ . '/../src/Set', __DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject']);
};
2 changes: 1 addition & 1 deletion easy-ci.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Contract\Rector\RectorInterface;
use Symplify\EasyCI\Config\EasyCIConfig;

return static function (EasyCIConfig $easyCIConfig): void {
Expand Down
9 changes: 2 additions & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- vendor/symplify/phpstan-rules/config/symplify-rules.neon
#includes:
# - vendor/symplify/phpstan-rules/config/symplify-rules.neon

parameters:
level: max
Expand All @@ -14,8 +14,3 @@ parameters:
- *Source/*

ignoreErrors:
- '#Parameter (.*?) of method (.*?)\:\:refactor\(\) should be contravariant with parameter \$node \(PhpParser\\Node\) of method Rector\\Core\\Contract\\Rector\\PhpRectorInterface\:\:refactor\(\)#'

-
message: '#Attribute must have all names explicitly defined#'
path: 'tests/*'
12 changes: 9 additions & 3 deletions src/Rector/MethodCall/ParserFactoryRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Rector\PhpParser\Node\Value\ValueResolver;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

Expand All @@ -23,6 +24,11 @@
*/
final class ParserFactoryRector extends AbstractRector
{
public function __construct(
private readonly ValueResolver $valueResolver
) {
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Upgrade ParserFactory create() method', [
Expand Down Expand Up @@ -71,14 +77,14 @@ public function refactor(Node $node): ?Node
$args = $node->getArgs();

$value = $this->valueResolver->getValue($args[0]->value);
if ($value === 1) {
if ($value === 1 || $value === 'PhpParser\ParserFactory::PREFER_PHP7') {
$node->name = new Identifier('createForNewestSupportedVersion');
$node->args = [];

return $node;
}

if ($value === 4) {
if ($value === 4 || $value === 'PhpParser\ParserFactory::ONLY_PHP5') {
$node->name = new Identifier('createForVersion');
$fullyQualified = new FullyQualified('PhpParser\PhpVersion');

Expand Down
Loading