From ad5bfe80942bbcdf5a40f22a9e45750bf8a448b3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 16 Nov 2023 18:48:20 +0700 Subject: [PATCH] Bump to Rector 0.18.8 and update to use DocblockUpdater (#25) --- composer.json | 2 +- composer.lock | 26 +++++++++---------- .../MigrateCaptchaAnnotationToRouteRector.php | 8 +++++- ...teLoginRequiredAnnotationToRouteRector.php | 5 +++- .../v65/MigrateRouteScopeToRouteDefaults.php | 5 +++- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index d0e42cc..50fad51 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "require-dev": { "phpunit/phpunit": "^9.5", "phpstan/phpstan": "~1.10.26", - "rector/rector": "^0.16 || ^0.17 || ^0.18", + "rector/rector": "0.18.8", "symplify/easy-coding-standard": "~11.2", "friendsofphp/php-cs-fixer": "~3.22.0", "tracy/tracy": "^2.9", diff --git a/composer.lock b/composer.lock index 5165d3d..574b6fd 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": "46d1d38aff7f31b58174aae1d1897bbf", + "content-hash": "c9aaf436d1da525458d2ba442203a79b", "packages": [], "packages-dev": [ { @@ -773,16 +773,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.31", + "version": "1.10.41", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c0eb159b598e2b637cbd52840e3d08f28d25dd47" + "reference": "c6174523c2a69231df55bdc65b61655e72876d76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c0eb159b598e2b637cbd52840e3d08f28d25dd47", - "reference": "c0eb159b598e2b637cbd52840e3d08f28d25dd47", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6174523c2a69231df55bdc65b61655e72876d76", + "reference": "c6174523c2a69231df55bdc65b61655e72876d76", "shasum": "" }, "require": { @@ -831,7 +831,7 @@ "type": "tidelift" } ], - "time": "2023-08-24T14:26:09+00:00" + "time": "2023-11-05T12:57:57+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1459,21 +1459,21 @@ }, { "name": "rector/rector", - "version": "0.18.0", + "version": "0.18.8", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "758ada29b5c80d933f906735d3026520390a2a1d" + "reference": "374bab157a41f6849556edc53125f856eb6c1c8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/758ada29b5c80d933f906735d3026520390a2a1d", - "reference": "758ada29b5c80d933f906735d3026520390a2a1d", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/374bab157a41f6849556edc53125f856eb6c1c8c", + "reference": "374bab157a41f6849556edc53125f856eb6c1c8c", "shasum": "" }, "require": { "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.10.26" + "phpstan/phpstan": "^1.10.35" }, "conflict": { "rector/rector-doctrine": "*", @@ -1503,7 +1503,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.18.0" + "source": "https://github.com/rectorphp/rector/tree/0.18.8" }, "funding": [ { @@ -1511,7 +1511,7 @@ "type": "github" } ], - "time": "2023-08-17T12:53:22+00:00" + "time": "2023-11-14T15:30:19+00:00" }, { "name": "sebastian/cli-parser", diff --git a/src/Rule/v65/MigrateCaptchaAnnotationToRouteRector.php b/src/Rule/v65/MigrateCaptchaAnnotationToRouteRector.php index fd9db4b..00809f6 100644 --- a/src/Rule/v65/MigrateCaptchaAnnotationToRouteRector.php +++ b/src/Rule/v65/MigrateCaptchaAnnotationToRouteRector.php @@ -12,13 +12,17 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; class MigrateCaptchaAnnotationToRouteRector extends AbstractRector { - public function __construct(private PhpDocTagRemover $phpDocTagRemover, private PhpDocInfoFactory $phpDocFactory) + public function __construct( + private PhpDocTagRemover $phpDocTagRemover, private PhpDocInfoFactory $phpDocFactory, + private readonly DocBlockUpdater $docBlockUpdater + ) { } @@ -101,6 +105,8 @@ public function refactor(Node $node) $this->phpDocTagRemover->removeByName($phpDocInfo, 'Captcha'); + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); + return $node; } } diff --git a/src/Rule/v65/MigrateLoginRequiredAnnotationToRouteRector.php b/src/Rule/v65/MigrateLoginRequiredAnnotationToRouteRector.php index 677f5ec..46b8d5b 100644 --- a/src/Rule/v65/MigrateLoginRequiredAnnotationToRouteRector.php +++ b/src/Rule/v65/MigrateLoginRequiredAnnotationToRouteRector.php @@ -12,13 +12,14 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; class MigrateLoginRequiredAnnotationToRouteRector extends AbstractRector { - public function __construct(private PhpDocTagRemover $phpDocTagRemover, private PhpDocInfoFactory $phpDocFactory) + public function __construct(private PhpDocTagRemover $phpDocTagRemover, private PhpDocInfoFactory $phpDocFactory, private DocBlockUpdater $docBlockUpdater) { } @@ -87,6 +88,8 @@ public function refactor(Node $node) $this->phpDocTagRemover->removeByName($phpDocInfo, 'LoginRequired'); + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); + return $node; } } diff --git a/src/Rule/v65/MigrateRouteScopeToRouteDefaults.php b/src/Rule/v65/MigrateRouteScopeToRouteDefaults.php index 5266364..3b2855b 100644 --- a/src/Rule/v65/MigrateRouteScopeToRouteDefaults.php +++ b/src/Rule/v65/MigrateRouteScopeToRouteDefaults.php @@ -14,13 +14,14 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover; use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; class MigrateRouteScopeToRouteDefaults extends AbstractRector { - public function __construct(private PhpDocTagRemover $phpDocTagRemover, private PhpDocInfoFactory $phpDocFactory) + public function __construct(private PhpDocTagRemover $phpDocTagRemover, private PhpDocInfoFactory $phpDocFactory, private DocBlockUpdater $docBlockUpdater) { } @@ -97,6 +98,8 @@ public function refactor(Node $node) $this->phpDocTagRemover->removeByName($phpDocInfo, 'RouteScope'); + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); + return $node; } }