Skip to content

Commit

Permalink
Explicitly check for enum type when enum literal is met
Browse files Browse the repository at this point in the history
  • Loading branch information
peldax authored Aug 30, 2024
1 parent 94ce372 commit 6f73b19
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Value/ConvertParserValueVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Graphpinator\Parser\Value\ValueVisitor;
use Graphpinator\Parser\Value\VariableRef;
use Graphpinator\Typesystem\Contract\Inputable;
use Graphpinator\Typesystem\EnumType;
use Graphpinator\Typesystem\InputType;
use Graphpinator\Typesystem\ListType;
use Graphpinator\Typesystem\NotNullType;
Expand All @@ -40,6 +41,16 @@ public function visitLiteral(Literal $literal) : InputedValue

public function visitEnumLiteral(EnumLiteral $enumLiteral) : InputedValue
{
if ($this->type instanceof NotNullType) {
$this->type = $this->type->getInnerType();

Check failure on line 45 in src/Value/ConvertParserValueVisitor.php

View workflow job for this annotation

GitHub Actions / phpstan

Property Graphpinator\Value\ConvertParserValueVisitor::$type (Graphpinator\Typesystem\Contract\Inputable) does not accept Graphpinator\Typesystem\Contract\Type.

return $enumLiteral->accept($this);
}

if (!$this->type instanceof EnumType) {
throw new InvalidValue($this->type->printName(), $enumLiteral->getRawValue(), true);
}

return $this->type->accept(new ConvertRawValueVisitor($enumLiteral->getRawValue(), $this->path));
}

Expand Down

0 comments on commit 6f73b19

Please sign in to comment.