Skip to content

Commit

Permalink
fix: allow callable type to be compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
romm committed Jan 8, 2024
1 parent 7f88ceb commit 4a9771f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Definition/Repository/Cache/Compiler/TypeCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use CuyZ\Valinor\Type\Types\ArrayKeyType;
use CuyZ\Valinor\Type\Types\ArrayType;
use CuyZ\Valinor\Type\Types\BooleanValueType;
use CuyZ\Valinor\Type\Types\CallableType;
use CuyZ\Valinor\Type\Types\ClassStringType;
use CuyZ\Valinor\Type\Types\NativeClassType;
use CuyZ\Valinor\Type\Types\FloatValueType;
Expand Down Expand Up @@ -66,6 +67,7 @@ public function compile(Type $type): string
case $type instanceof NonEmptyStringType:
case $type instanceof NumericStringType:
case $type instanceof UndefinedObjectType:
case $type instanceof CallableType:
case $type instanceof MixedType:
return "$class::get()";
case $type instanceof BooleanValueType:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use CuyZ\Valinor\Type\Types\ArrayKeyType;
use CuyZ\Valinor\Type\Types\ArrayType;
use CuyZ\Valinor\Type\Types\BooleanValueType;
use CuyZ\Valinor\Type\Types\CallableType;
use CuyZ\Valinor\Type\Types\ClassStringType;
use CuyZ\Valinor\Type\Types\NativeClassType;
use CuyZ\Valinor\Type\Types\FloatValueType;
Expand Down Expand Up @@ -134,6 +135,7 @@ public function type_is_compiled_correctly_data_provider(): iterable
yield [new ClassStringType()];
yield [new ClassStringType(new NativeClassType(stdClass::class))];
yield [new ClassStringType(new InterfaceType(DateTimeInterface::class))];
yield [new CallableType()];
yield [new UnresolvableType('some-type', 'some message')];
}

Expand Down

0 comments on commit 4a9771f

Please sign in to comment.