Skip to content

Commit

Permalink
Use instanceof to be explicit about type (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanDelMar authored Apr 17, 2024
1 parent c593230 commit 97a1e36
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private function postProcessNode(Node $node): void

$newDocComment = $this->addTags($name, $docComment);

if ($newDocComment !== null) {
if ($newDocComment instanceof Doc) {
$node->setDocComment($newDocComment);
}

Expand All @@ -399,7 +399,7 @@ private function postProcessNode(Node $node): void

$newDocComment = $this->addStringTags($name, $docComment);

if ($newDocComment !== null) {
if ($newDocComment instanceof Doc) {
$node->setDocComment($newDocComment);
}
}
Expand Down Expand Up @@ -434,23 +434,23 @@ private function generateAdditionalTagsFromDoc(Doc $docComment): array
foreach ($params as $param) {
$addition = self::getAdditionFromParam($param);

if ($addition !== null) {
if ($addition instanceof WordPressTag) {
$additions[] = $addition;
}
}

foreach ($returns as $return) {
$addition = self::getAdditionFromReturn($return);

if ($addition !== null) {
if ($addition instanceof WordPressTag) {
$additions[] = $addition;
}
}

foreach ($vars as $var) {
$addition = self::getAdditionFromVar($var);

if ($addition !== null) {
if ($addition instanceof WordPressTag) {
$additions[] = $addition;
}
}
Expand Down Expand Up @@ -549,7 +549,7 @@ private function getInheritedTagsForParam(Param $param): array
{
$type = $param->getType();

if ($type === null) {
if (!$type instanceof Type) {
return [];
}

Expand All @@ -561,7 +561,7 @@ private function getInheritedTagsForParam(Param $param): array

$paramDescription = $param->getDescription();

if ($paramDescription === null) {
if (!$paramDescription instanceof Description) {
return [];
}

Expand All @@ -587,7 +587,7 @@ private function getInheritedTagsForParam(Param $param): array

$match = self::getMatchingInheritedTag($param, $tags, $symbolName);

if ($match !== null) {
if ($match instanceof WordPressTag) {
$additions[] = $match;
}
}
Expand Down Expand Up @@ -698,7 +698,7 @@ private function getAdditionFromParam(Param $tag): ?WordPressTag
$tagVariableType = $tag->getType();

// Skip if information we need is missing.
if (!$tagDescription || !$tagVariableName || !$tagVariableType) {
if (!$tagDescription instanceof Description || !$tagVariableName || !$tagVariableType instanceof Type) {
return null;
}

Expand Down Expand Up @@ -744,7 +744,7 @@ private function getAdditionFromReturn(Return_ $tag): ?WordPressTag
$tagVariableType = $tag->getType();

// Skip if information we need is missing.
if (!$tagDescription || !$tagVariableType) {
if (!$tagDescription instanceof Description || !$tagVariableType instanceof Type) {
return null;
}

Expand Down Expand Up @@ -784,7 +784,7 @@ private static function getAdditionFromVar(Var_ $tag): ?WordPressTag
$tagVariableType = $tag->getType();

// Skip if information we need is missing.
if (!$tagDescription || !$tagVariableType) {
if (!$tagDescription instanceof Description || !$tagVariableType instanceof Type) {
return null;
}

Expand Down Expand Up @@ -1008,7 +1008,7 @@ private function voidOrNever(Node $node): string
static function (Node $node): bool {
return isset($node->expr);
}
) !== null
) instanceof Node
) {
return '';
}
Expand Down

0 comments on commit 97a1e36

Please sign in to comment.