Skip to content

Commit

Permalink
[automated] Apply Coding Standard (#5031)
Browse files Browse the repository at this point in the history
* [automated] Apply Coding Standard

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

---------

Co-authored-by: TomasVotruba <TomasVotruba@users.noreply.github.com>
Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
3 people committed Sep 17, 2023
1 parent 0acf4bd commit 780c5af
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
namespace Rector\CodeQuality\Rector\Equal;

use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Equal;
use PhpParser\Node\Expr\BinaryOp\Identical;
use PhpParser\Node\Expr\BinaryOp\NotEqual;
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use Rector\Core\NodeAnalyzer\ExprAnalyzer;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand Down
1 change: 0 additions & 1 deletion rules/DeadCode/Rector/Cast/RecastingRemovalRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use PhpParser\Node\Expr\Cast\Object_;
use PhpParser\Node\Expr\Cast\String_;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Stmt\ClassMethod;
Expand Down
3 changes: 2 additions & 1 deletion rules/Naming/Matcher/ForeachMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Naming\Matcher;

use PhpParser\Node;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\ClassMethod;
Expand All @@ -23,7 +24,7 @@ public function __construct(
public function match(Foreach_ $foreach, ClassMethod|Closure|Function_ $functionLike): ?VariableAndCallForeach
{
$call = $this->callMatcher->matchCall($foreach);
if ($call === null) {
if (!$call instanceof Node) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion rules/Naming/Matcher/VariableAndCallAssignMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
public function match(Assign $assign, ClassMethod|Closure|Function_ $functionLike): ?VariableAndCallAssign
{
$call = $this->callMatcher->matchCall($assign);
if ($call === null) {
if (!$call instanceof Node) {
return null;
}

Expand Down
1 change: 0 additions & 1 deletion rules/Privatization/Guard/ParentPropertyLookupGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PhpParser\Node;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Class_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function refactor(Node $node): ?Node
}

$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::RETURN);
if ($returnTypeNode === null) {
if (!$returnTypeNode instanceof Node) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
$addPropertyTypeDeclaration->getType(),
TypeKind::PROPERTY
);
if ($typeNode === null) {
if (!$typeNode instanceof Node) {
// invalid configuration
throw new ShouldNotHappenException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function refactor(Node $node): ?Node

$inferredType = $this->decorateTypeWithNullableIfDefaultPropertyNull($property, $inferredType);
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferredType, TypeKind::PROPERTY);
if ($typeNode === null) {
if (!$typeNode instanceof Node) {
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion src/NodeDecorator/PropertyTypeDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Core\NodeDecorator;

use PhpParser\Node;
use PhpParser\Node\Stmt\Property;
use PHPStan\Type\Generic\GenericObjectType;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -35,7 +36,7 @@ public function decorate(Property $property, ?Type $type): void
if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::TYPED_PROPERTIES)) {
$phpParserType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PROPERTY);

if ($phpParserType !== null) {
if ($phpParserType instanceof Node) {
$property->type = $phpParserType;

if ($type instanceof GenericObjectType) {
Expand Down
4 changes: 2 additions & 2 deletions src/PhpParser/Node/NodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function createParamFromNameAndType(string $name, ?Type $type): Param

if ($type instanceof Type) {
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PARAM);
if ($typeNode !== null) {
if ($typeNode instanceof Node) {
$param->setType($typeNode);
}
}
Expand Down Expand Up @@ -299,7 +299,7 @@ public function createPromotedPropertyParam(PropertyMetadata $propertyMetadata):
if ($propertyType instanceof Type) {
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY);

if ($typeNode !== null) {
if ($typeNode instanceof Node) {
$paramBuilder->setType($typeNode);
}
}
Expand Down

0 comments on commit 780c5af

Please sign in to comment.