Skip to content

Commit

Permalink
[PHPStanStaticTypeMapper] Avoid double \ prefix on IntersectionTypeMa…
Browse files Browse the repository at this point in the history
…pper (#5656)

* [PHPStanStaticTypeMapper] Avoid double \ prefix on IntersectionTypeMapper

* [PHPStanStaticTypeMapper] Avoid double \ prefix on IntersectionTypeMapper

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Feb 22, 2024
1 parent 18a8aec commit fb312e0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,10 @@ private function findArgFromMethodCall(
CallLike $callLike
): ?Arg {
if (is_int($renameFunctionLikeParamWithinCallLikeArg->getCallLikePosition())) {
$arg = $this->processPositionalArg($callLike, $renameFunctionLikeParamWithinCallLikeArg);
} else {
$arg = $this->processNamedArg($callLike, $renameFunctionLikeParamWithinCallLikeArg);
return $this->processPositionalArg($callLike, $renameFunctionLikeParamWithinCallLikeArg);
}

return $arg;
return $this->processNamedArg($callLike, $renameFunctionLikeParamWithinCallLikeArg);
}

private function processPositionalArg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ final class FullyQualifiedIdentifierTypeNode extends IdentifierTypeNode implemen
{
public function __toString(): string
{
return '\\' . $this->name;
return '\\' . ltrim($this->name, '\\');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function mapToPHPStanPhpDocTypeNode(Type $type): TypeNode
'',
static function (AstNode $astNode): ?IdentifierTypeNode {
if ($astNode instanceof IdentifierTypeNode) {
$astNode->name = '\\' . $astNode->name;
$astNode->name = '\\' . ltrim($astNode->name, '\\');
return $astNode;
}

Expand Down

0 comments on commit fb312e0

Please sign in to comment.