Skip to content

Commit

Permalink
[ci-review] Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 12, 2024
1 parent a6da1ae commit b5f8c05
Show file tree
Hide file tree
Showing 46 changed files with 92 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\CodeQuality\Rector\Empty_;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
Expand Down Expand Up @@ -78,7 +79,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($node instanceof BooleanNot) {
if ($node->expr instanceof Empty_ && $this->isAllowedExpr($node->expr->expr, $scope)) {
return new NotIdentical($node->expr->expr, new Array_());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\CodeQuality\Rector\Expression;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Ternary;
Expand Down Expand Up @@ -68,7 +69,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
ScopeFetcher::fetch($node);
if (! $node->expr instanceof Ternary) {
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\DeadCode\Rector\Assign;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Closure;
Expand Down Expand Up @@ -69,7 +70,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
$stmts = $node->stmts;
if ($stmts === null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\DeadCode\Rector\ClassMethod;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
Expand Down Expand Up @@ -76,7 +77,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
$classMethods = $node->getMethods();

if ($classMethods === []) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Rector\DeadCode\Rector\ClassMethod;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\TraitUse;
use PHPStan\Analyser\Scope;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\Reflection\ClassReflection;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
Expand Down Expand Up @@ -98,7 +98,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
ScopeFetcher::fetch($node);
$constructClassMethod = $node->getMethod(MethodName::CONSTRUCT);
if (! $constructClassMethod instanceof ClassMethod) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\DeadCode\Rector\Property;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Stmt\Class_;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
ScopeFetcher::fetch($node);
if ($this->shouldSkipClass($node)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Php55\Rector\FuncCall;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use Rector\Enum\ObjectReference;
Expand Down Expand Up @@ -58,7 +59,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if (! $this->isName($node, 'get_called_class')) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Php70\Rector\MethodCall;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
Expand Down Expand Up @@ -92,7 +93,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if (! $scope->isInClass()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Php70\Rector\StaticCall;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\MethodCall;
Expand Down Expand Up @@ -102,7 +103,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($node->name instanceof Expr) {
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion rules/Php72/Rector/FuncCall/GetClassOnNullRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Php72\Rector\FuncCall;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
Expand Down Expand Up @@ -70,7 +71,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
ScopeFetcher::fetch($node);
$hasChanged = false;

$this->traverseNodesWithCallable($node, function (Node $node) use (&$hasChanged): int|null|Ternary {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Php80\Rector\ClassConstFetch;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\Variable;
Expand Down Expand Up @@ -67,7 +68,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
ScopeFetcher::fetch($node);
$className = $node->isFinal() ? 'self' : 'static';

$hasChanged = false;
Expand Down
3 changes: 2 additions & 1 deletion rules/Php81/Rector/Property/ReadOnlyPropertyRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Php81\Rector\Property;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Assign;
Expand Down Expand Up @@ -101,7 +102,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($this->shouldSkip($node)) {
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion rules/Php82/Rector/Class_/ReadOnlyClassRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Php82\Rector\Class_;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Param;
Expand Down Expand Up @@ -81,7 +82,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($this->shouldSkip($node, $scope)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Privatization\Rector\ClassMethod;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt\Class_;
Expand Down Expand Up @@ -71,7 +72,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if (! $node->isFinal()) {
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion rules/Renaming/Rector/MethodCall/RenameMethodRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Renaming\Rector\MethodCall;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\BuilderHelpers;
use PhpParser\Node;
use PhpParser\Node\Expr\ArrayDimFetch;
Expand Down Expand Up @@ -77,7 +78,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($node instanceof Class_ || $node instanceof Interface_) {
return $this->refactorClass($node, $scope);
}
Expand Down
3 changes: 2 additions & 1 deletion rules/Transform/Rector/Class_/AddInterfaceByTraitRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Transform\Rector\Class_;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
Expand Down Expand Up @@ -63,7 +64,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
$classReflection = $scope->getClassReflection();
if (! $classReflection instanceof ClassReflection) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Transform\Rector\StaticCall;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
Expand Down Expand Up @@ -97,7 +98,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
ScopeFetcher::fetch($node);
$class = $node;
$hasChanged = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\TypeDeclaration\Rector\ClassMethod;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\ConstFetch;
Expand Down Expand Up @@ -84,7 +85,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($this->shouldSkip($node, $scope)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\TypeDeclaration\Rector\ClassMethod;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
Expand Down Expand Up @@ -94,7 +95,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($this->shouldSkip($node, $scope)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\TypeDeclaration\Rector\ClassMethod;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\UnaryMinus;
Expand Down Expand Up @@ -76,7 +77,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($this->shouldSkip($node, $scope)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\TypeDeclaration\Rector\ClassMethod;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\UnaryMinus;
use PhpParser\Node\Identifier;
Expand Down Expand Up @@ -74,7 +75,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($this->shouldSkip($node, $scope)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\TypeDeclaration\Rector\ClassMethod;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
Expand Down Expand Up @@ -104,7 +105,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
$hasChanged = false;

foreach ($node->getMethods() as $classMethod) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\TypeDeclaration\Rector\ClassMethod;

use Rector\PHPStan\ScopeFetcher;
use PhpParser\Node;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Param;
Expand Down Expand Up @@ -85,7 +86,7 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$scope = \Rector\PHPStan\ScopeFetcher::fetch($node);
$scope = ScopeFetcher::fetch($node);
if ($this->shouldSkip($node)) {
return null;
}
Expand Down
Loading

0 comments on commit b5f8c05

Please sign in to comment.