Skip to content

Commit

Permalink
[PHPStan] Fix PHPStan notice Attribute must have all names explicitly…
Browse files Browse the repository at this point in the history
… defined (#54)

* [PHPStan] Fix PHPStan notice explicit

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
samsonasik and actions-user committed May 4, 2023
1 parent 23e55c6 commit 3209c44
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
6 changes: 0 additions & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,3 @@ parameters:

# class-string
- '#Parameter \#2 \$expectedClass of method Rector\\NodeAnalyzer\\MethodCallTypeAnalyzer\:\:isInstanceOf\(\) expects class\-string, string given#'

-
message: '#Attribute must have all names explicitly defined#'
paths:
- tests
- rules-tests
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ public function refactor(Node $node): ?Node

// add conditional ternary
$nullIdentical = new Identical($associativeValue, $this->nodeFactory->createNull());
$ternary = new Ternary($nullIdentical, null, $associativeValue);
$args[1]->value = $ternary;
$args[1]->value = new Ternary($nullIdentical, null, $associativeValue);

return $node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ private function removeNamedArguments(MethodCall | StaticCall | New_ | FuncCall
return null;
}

$unnamedArgs = $this->unnamedArgumentResolver->resolveFromReflection($functionLikeReflection, $args);
$node->args = $unnamedArgs;
$node->args = $this->unnamedArgumentResolver->resolveFromReflection($functionLikeReflection, $args);

return $node;
}
Expand Down
6 changes: 4 additions & 2 deletions src/PhpDocDecorator/PhpDocFromTypeDeclarationDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ public function decorateReturn(ClassMethod|Function_|Closure|ArrowFunction $func

// if nullable is supported, downgrade to that one
if ($this->isNullableSupportedAndPossible($returnType)) {
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, TypeKind::RETURN);
$functionLike->returnType = $returnTypeNode;
$functionLike->returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode(
$returnType,
TypeKind::RETURN
);

return;
}
Expand Down

0 comments on commit 3209c44

Please sign in to comment.