Tags::__toString(): remove redundant type casts

Psalm flags these type casts as redundant:
```
ERROR: RedundantCastGivenDocblockType - src/DocBlock/Tags/Author.php:80:23 - Redundant cast to string given docblock-provided type (see https://psalm.dev/263)
        $authorName = (string) $this->authorName;

ERROR: RedundantCastGivenDocblockType - src/DocBlock/Tags/Example.php:150:21 - Redundant cast to string given docblock-provided type (see https://psalm.dev/263)
        $filePath = (string) $this->filePath;

ERROR: RedundantCastGivenDocblockType - src/DocBlock/Tags/Link.php:74:17 - Redundant cast to string given docblock-provided type (see https://psalm.dev/263)
        $link = (string) $this->link;

ERROR: RedundantCastGivenDocblockType - src/DocBlock/Tags/Method.php:228:23 - Redundant cast to string given docblock-provided type (see https://psalm.dev/263)
        $methodName = (string) $this->methodName;
```

I have verified each and can confirm that these are redundant. They are probably a left-over from the time when the `__construct()` method in these classes did not yet have type declarations.
This commit is contained in:
jrfnl
2021-08-08 21:32:55 +02:00
committed by Jaapio
parent 155efd647f
commit f5118ce302
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
$authorEmail = '';
}
$authorName = (string) $this->authorName;
$authorName = $this->authorName;
return $authorName . ($authorEmail !== '' ? ($authorName !== '' ? ' ' : '') . $authorEmail : '');
}
+1 -1
View File
@@ -148,7 +148,7 @@ final class Example implements Tag, Factory\StaticMethod
*/
public function __toString(): string
{
$filePath = (string) $this->filePath;
$filePath = $this->filePath;
$isDefaultLine = $this->startingLine === 1 && $this->lineCount === 0;
$startingLine = !$isDefaultLine ? (string) $this->startingLine : '';
$lineCount = !$isDefaultLine ? (string) $this->lineCount : '';
+1 -1
View File
@@ -71,7 +71,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
$description = '';
}
$link = (string) $this->link;
$link = $this->link;
return $link . ($description !== '' ? ($link !== '' ? ' ' : '') . $description : '');
}
+1 -1
View File
@@ -228,7 +228,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
$returnType = (string) $this->returnType;
$methodName = (string) $this->methodName;
$methodName = $this->methodName;
return $static
. ($returnType !== '' ? ($static !== '' ? ' ' : '') . $returnType : '')