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
6 changes: 0 additions & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,3 @@ parameters:
-
identifier: argument.type
message: '#Parameter \#1 \$expr of method Rector\\CodeQuality\\Rector\\BooleanOr\\RepeatedOrEqualToInArrayRector\:\:matchComparedExprAndValueExpr\(\) expects PhpParser\\Node\\Expr\\BinaryOp\\Equal\|PhpParser\\Node\\Expr\\BinaryOp\\Identical, PhpParser\\Node\\Expr given#'

-
path: rules/Renaming/Rector/Name/RenameClassRector.php
identifier: return.type

- '#Method Rector\\(.*?)Rector\:\:refactor\(\) never returns \d so it can be removed from the return type#'
12 changes: 10 additions & 2 deletions src/Contract/Rector/RectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Rector\Contract\Rector;

use PhpParser\Node;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor;
use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;

Expand All @@ -21,7 +20,16 @@ public function getNodeTypes(): array;

/**
* Process Node of matched type
* @return Node|Node[]|null|NodeTraverser::*
* @return Node|Node[]|null|int
*
* For int return, choose:
*
* ✔️ To decorate current node and its children to not be traversed on current rule, return one of:
* - NodeVisitor::DONT_TRAVERSE_CHILDREN
* - NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN
*
* ✔️ To remove node of Node\Stmt or Node\Param, return:
* - NodeVisitor::REMOVE_NODE
*/
Comment on lines +23 to 33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep original list, as now any int value can be returned by PHPStan, which is not true.
Could you revert this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the rule classes itself then need update to add @return for specific constant then, eg:

    /**
     * @param StmtsAwareInterface $node
+    * @return null|Node|NodeVisitor::DONT_TRAVERSE_CHILDREN
     */
    public function refactor(Node $node): null|Node|int

I will revert this and update rule classes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created PR to use NodeVisitor::* on RectorInterface::refactor(), then update its rules @return to use its constant at PR:

public function refactor(Node $node);
}