Skip to content

Commit

Permalink
Redesign follow-up
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Feb 23, 2024
1 parent e9eaf11 commit 497e735
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/DefaultTypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function objectShape(Type $type, array $properties): mixed
return $this->default($type);
}

public function offsetOf(Type $type, Type $innerType, Type $offset): mixed
public function offset(Type $type, Type $innerType, Type $offset): mixed
{
return $this->default($type);
}
Expand Down
4 changes: 2 additions & 2 deletions src/OffsetOfType.php → src/OffsetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @psalm-internal Typhoon\Type
* @implements Type<mixed>
*/
final class OffsetOfType implements Type
final class OffsetType implements Type
{
public function __construct(
private readonly Type $type,
Expand All @@ -18,6 +18,6 @@ public function __construct(

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->offsetOf($this, $this->type, $this->offset);
return $visitor->offset($this, $this->type, $this->offset);
}
}
2 changes: 1 addition & 1 deletion src/TypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function objectShape(Type $type, array $properties): mixed;
/**
* @return TReturn
*/
public function offsetOf(Type $type, Type $innerType, Type $offset): mixed;
public function offset(Type $type, Type $innerType, Type $offset): mixed;

/**
* @param Type<resource> $type
Expand Down
14 changes: 6 additions & 8 deletions src/types.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,15 @@ public static function object(string $class, Type ...$templateArguments): Type
*/
public static function objectShape(array $properties = []): Type
{
return new ObjectShapeType(
array_map(
static fn(Type|Property $property): Property => $property instanceof Type ? new Property($property) : $property,
$properties,
),
);
return new ObjectShapeType(array_map(
static fn(Type|Property $property): Property => $property instanceof Type ? new Property($property) : $property,
$properties,
));
}

public static function offsetOf(Type $type, Type $offset): Type
public static function offset(Type $type, Type $offset): Type
{
return new OffsetOfType($type, $offset);
return new OffsetType($type, $offset);
}

/**
Expand Down

0 comments on commit 497e735

Please sign in to comment.