Skip to content

Commit f5118ce

Browse files
jrfnljaapio
authored andcommitted
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.
1 parent 155efd6 commit f5118ce

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/DocBlock/Tags/Author.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __toString(): string
7979
$authorEmail = '';
8080
}
8181

82-
$authorName = (string) $this->authorName;
82+
$authorName = $this->authorName;
8383

8484
return $authorName . ($authorEmail !== '' ? ($authorName !== '' ? ' ' : '') . $authorEmail : '');
8585
}

src/DocBlock/Tags/Example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function getFilePath(): string
148148
*/
149149
public function __toString(): string
150150
{
151-
$filePath = (string) $this->filePath;
151+
$filePath = $this->filePath;
152152
$isDefaultLine = $this->startingLine === 1 && $this->lineCount === 0;
153153
$startingLine = !$isDefaultLine ? (string) $this->startingLine : '';
154154
$lineCount = !$isDefaultLine ? (string) $this->lineCount : '';

src/DocBlock/Tags/Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __toString(): string
7171
$description = '';
7272
}
7373

74-
$link = (string) $this->link;
74+
$link = $this->link;
7575

7676
return $link . ($description !== '' ? ($link !== '' ? ' ' : '') . $description : '');
7777
}

src/DocBlock/Tags/Method.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function __toString(): string
228228

229229
$returnType = (string) $this->returnType;
230230

231-
$methodName = (string) $this->methodName;
231+
$methodName = $this->methodName;
232232

233233
return $static
234234
. ($returnType !== '' ? ($static !== '' ? ' ' : '') . $returnType : '')

0 commit comments

Comments
 (0)