Skip to content

Commit

Permalink
Bump to Rector 0.18.8 and update to use DocblockUpdater (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Nov 16, 2023
1 parent 0daa1d7 commit ad5bfe8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 13 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/Rule/v65/MigrateCaptchaAnnotationToRouteRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
{
}

Expand Down Expand Up @@ -101,6 +105,8 @@ public function refactor(Node $node)

$this->phpDocTagRemover->removeByName($phpDocInfo, 'Captcha');

$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);

return $node;
}
}
5 changes: 4 additions & 1 deletion src/Rule/v65/MigrateLoginRequiredAnnotationToRouteRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -87,6 +88,8 @@ public function refactor(Node $node)

$this->phpDocTagRemover->removeByName($phpDocInfo, 'LoginRequired');

$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);

return $node;
}
}
5 changes: 4 additions & 1 deletion src/Rule/v65/MigrateRouteScopeToRouteDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -97,6 +98,8 @@ public function refactor(Node $node)

$this->phpDocTagRemover->removeByName($phpDocInfo, 'RouteScope');

$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);

return $node;
}
}

0 comments on commit ad5bfe8

Please sign in to comment.