Skip to content

Commit 97a1e36

Browse files
authored
Use instanceof to be explicit about type (#169)
1 parent c593230 commit 97a1e36

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Diff for: visitor.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private function postProcessNode(Node $node): void
383383

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

386-
if ($newDocComment !== null) {
386+
if ($newDocComment instanceof Doc) {
387387
$node->setDocComment($newDocComment);
388388
}
389389

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

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

402-
if ($newDocComment !== null) {
402+
if ($newDocComment instanceof Doc) {
403403
$node->setDocComment($newDocComment);
404404
}
405405
}
@@ -434,23 +434,23 @@ private function generateAdditionalTagsFromDoc(Doc $docComment): array
434434
foreach ($params as $param) {
435435
$addition = self::getAdditionFromParam($param);
436436

437-
if ($addition !== null) {
437+
if ($addition instanceof WordPressTag) {
438438
$additions[] = $addition;
439439
}
440440
}
441441

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

445-
if ($addition !== null) {
445+
if ($addition instanceof WordPressTag) {
446446
$additions[] = $addition;
447447
}
448448
}
449449

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

453-
if ($addition !== null) {
453+
if ($addition instanceof WordPressTag) {
454454
$additions[] = $addition;
455455
}
456456
}
@@ -549,7 +549,7 @@ private function getInheritedTagsForParam(Param $param): array
549549
{
550550
$type = $param->getType();
551551

552-
if ($type === null) {
552+
if (!$type instanceof Type) {
553553
return [];
554554
}
555555

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

562562
$paramDescription = $param->getDescription();
563563

564-
if ($paramDescription === null) {
564+
if (!$paramDescription instanceof Description) {
565565
return [];
566566
}
567567

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

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

590-
if ($match !== null) {
590+
if ($match instanceof WordPressTag) {
591591
$additions[] = $match;
592592
}
593593
}
@@ -698,7 +698,7 @@ private function getAdditionFromParam(Param $tag): ?WordPressTag
698698
$tagVariableType = $tag->getType();
699699

700700
// Skip if information we need is missing.
701-
if (!$tagDescription || !$tagVariableName || !$tagVariableType) {
701+
if (!$tagDescription instanceof Description || !$tagVariableName || !$tagVariableType instanceof Type) {
702702
return null;
703703
}
704704

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

746746
// Skip if information we need is missing.
747-
if (!$tagDescription || !$tagVariableType) {
747+
if (!$tagDescription instanceof Description || !$tagVariableType instanceof Type) {
748748
return null;
749749
}
750750

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

786786
// Skip if information we need is missing.
787-
if (!$tagDescription || !$tagVariableType) {
787+
if (!$tagDescription instanceof Description || !$tagVariableType instanceof Type) {
788788
return null;
789789
}
790790

@@ -1008,7 +1008,7 @@ private function voidOrNever(Node $node): string
10081008
static function (Node $node): bool {
10091009
return isset($node->expr);
10101010
}
1011-
) !== null
1011+
) instanceof Node
10121012
) {
10131013
return '';
10141014
}

0 commit comments

Comments
 (0)