Skip to content

Commit

Permalink
Add TypeKind::Tentative
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Aug 1, 2024
1 parent bf37fb3 commit 23948b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions Internal/Data/TypeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function get(TypeKind $kind = TypeKind::Resolved): ?Type
return match ($kind) {
TypeKind::Resolved => $this->annotated ?? $this->inferred ?? $this->tentative ?? $this->native ?? types::mixed,
TypeKind::Native => $this->native,
TypeKind::Tentative => $this->tentative,
TypeKind::Inferred => $this->inferred,
TypeKind::Annotated => $this->annotated,
};
Expand Down
5 changes: 2 additions & 3 deletions Internal/NativeAdapter/FunctionAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Typhoon\DeclarationId\AnonymousFunctionId;
use Typhoon\DeclarationId\NamedFunctionId;
use Typhoon\Reflection\FunctionReflection;
use Typhoon\Reflection\Internal\Data;
use Typhoon\Reflection\ParameterReflection;
use Typhoon\Reflection\TypeKind;

Expand Down Expand Up @@ -199,7 +198,7 @@ public function getStaticVariables(): array

public function getTentativeReturnType(): ?\ReflectionType
{
return $this->reflection->data[Data::Type]->tentative?->accept(new ToNativeTypeConverter());
return $this->reflection->returnType(TypeKind::Tentative)?->accept(new ToNativeTypeConverter());
}

public function hasReturnType(): bool
Expand All @@ -209,7 +208,7 @@ public function hasReturnType(): bool

public function hasTentativeReturnType(): bool
{
return $this->reflection->data[Data::Type]->tentative !== null;
return $this->reflection->returnType(TypeKind::Tentative) !== null;
}

public function inNamespace(): bool
Expand Down
4 changes: 2 additions & 2 deletions Internal/NativeAdapter/MethodAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function getStaticVariables(): array

public function getTentativeReturnType(): ?\ReflectionType
{
return $this->reflection->data[Data::Type]->tentative?->accept(new ToNativeTypeConverter());
return $this->reflection->returnType(TypeKind::Tentative)?->accept(new ToNativeTypeConverter());
}

/**
Expand All @@ -238,7 +238,7 @@ public function hasReturnType(): bool

public function hasTentativeReturnType(): bool
{
return $this->reflection->data[Data::Type]->tentative !== null;
return $this->reflection->returnType(TypeKind::Tentative) !== null;
}

public function inNamespace(): bool
Expand Down
3 changes: 2 additions & 1 deletion TypeKind.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
*/
enum TypeKind
{
case Resolved;
case Native;
case Tentative;
case Inferred;
case Annotated;
case Resolved;
}

0 comments on commit 23948b1

Please sign in to comment.