mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
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:
@@ -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 : '');
|
||||
}
|
||||
|
||||
@@ -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 : '';
|
||||
|
||||
@@ -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 : '');
|
||||
}
|
||||
|
||||
@@ -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 : '')
|
||||
|
||||
Reference in New Issue
Block a user