Skip to content

Commit

Permalink
Make phpstan happier (a bit) (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann authored Dec 6, 2021
1 parent f754f85 commit f2984cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Analysers/AttributeAnnotationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function setGenerator(Generator $generator): void

public function build(\Reflector $reflector, Context $context): array
{
if (\PHP_VERSION_ID < 80100) {
if (\PHP_VERSION_ID < 80100 || !method_exists($reflector, 'getAttributes')) {
return [];
}

Expand All @@ -45,7 +45,7 @@ public function build(\Reflector $reflector, Context $context): array
foreach ($rp->getAttributes(PathParameter::class) as $attribute) {
$instance = $attribute->newInstance();
$instance->name = $rp->getName();
if ($rnt = $rp->getType()) {
if (($rnt = $rp->getType()) && $rnt instanceof \ReflectionNamedType) {
$instance->schema = new Schema(['type' => $rnt->getName(), '_context' => new Context(['nested' => $this], $context)]);
}
$annotations[] = $instance;
Expand Down
4 changes: 2 additions & 2 deletions src/Analysers/DocBlockAnnotationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function setGenerator(Generator $generator): void
public function build(\Reflector $reflector, Context $context): array
{
$aliases = $this->generator ? $this->generator->getAliases() : [];
if (method_exists($reflector, 'getShortName')) {
if (method_exists($reflector, 'getShortName') && method_exists($reflector, 'getName')) {
$aliases[strtolower($reflector->getShortName())] = $reflector->getName();
}

Expand All @@ -44,7 +44,7 @@ public function build(\Reflector $reflector, Context $context): array
}
$this->docBlockParser->setAliases($aliases);

if ($comment = $reflector->getDocComment()) {
if (method_exists($reflector, 'getDocComment') && ($comment = $reflector->getDocComment())) {
return $this->docBlockParser->fromComment($comment, $context);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Serializer

public static function isValidAnnotationClass($className)
{
return in_array($className, static::$VALID_ANNOTATIONS);
return in_array($className, self::$VALID_ANNOTATIONS);
}

/**
Expand Down

0 comments on commit f2984cb

Please sign in to comment.