Skip to content

Commit

Permalink
Refactored naming of most parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Feb 24, 2024
1 parent a849136 commit 2dafbfd
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 201 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $type = types::arrayShape([
types::param(types::template('TSend', types::atClass(Generator::class)), hasDefault: true),
types::param(types::scalar, variadic: true),
],
returnType: types::void,
return: types::void,
),
], sealed: false);
```
10 changes: 5 additions & 5 deletions src/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
final class ArrayType implements Type
{
/**
* @param Type<TKey> $keyType
* @param Type<TValue> $valueType
* @param Type<TKey> $key
* @param Type<TValue> $value
*/
public function __construct(
private readonly Type $keyType,
private readonly Type $valueType,
private readonly Type $key,
private readonly Type $value,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->array($this, $this->keyType, $this->valueType);
return $visitor->array($this, $this->key, $this->value);
}
}
4 changes: 2 additions & 2 deletions src/CallableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ final class CallableType implements Type
*/
public function __construct(
private readonly array $parameters,
private readonly Type $returnType,
private readonly Type $return,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->callable($this, $this->parameters, $this->returnType);
return $visitor->callable($this, $this->parameters, $this->return);
}
}
4 changes: 2 additions & 2 deletions src/ClassConstantType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ final class ClassConstantType implements Type
* @param non-empty-string $name
*/
public function __construct(
private readonly Type $classType,
private readonly Type $class,
private readonly string $name,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->classConstant($this, $this->classType, $this->name);
return $visitor->classConstant($this, $this->class, $this->name);
}
}
4 changes: 2 additions & 2 deletions src/ClosureType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ final class ClosureType implements Type
*/
public function __construct(
private readonly array $parameters,
private readonly Type $returnType,
private readonly Type $return,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->closure($this, $this->parameters, $this->returnType);
return $visitor->closure($this, $this->parameters, $this->return);
}
}
158 changes: 79 additions & 79 deletions src/DefaultTypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,203 +11,203 @@
*/
abstract class DefaultTypeVisitor implements TypeVisitor
{
public function alias(Type $type, string $class, string $name): mixed
public function alias(Type $self, string $class, string $name): mixed
{
return $this->default($type);
return $this->default($self);
}

public function anyLiteral(Type $type, Type $innerType): mixed
public function anyLiteral(Type $self, Type $type): mixed
{
return $this->default($type);
return $this->default($self);
}

public function array(Type $type, Type $keyType, Type $valueType): mixed
public function array(Type $self, Type $key, Type $value): mixed
{
return $this->default($type);
return $this->default($self);
}

public function arrayShape(Type $type, array $elements, bool $sealed): mixed
public function arrayShape(Type $self, array $elements, bool $sealed): mixed
{
return $this->default($type);
return $this->default($self);
}

public function bool(Type $type): mixed
public function bool(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function callable(Type $type, array $parameters, ?Type $returnType): mixed
public function callable(Type $self, array $parameters, ?Type $return): mixed
{
return $this->default($type);
return $this->default($self);
}

public function classConstant(Type $type, Type $classType, string $name): mixed
public function classConstant(Type $self, Type $class, string $name): mixed
{
return $this->default($type);
return $this->default($self);
}

public function classString(Type $type): mixed
public function classString(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function classStringLiteral(Type $type, string $class): mixed
public function classStringLiteral(Type $self, string $class): mixed
{
return $this->default($type);
return $this->default($self);
}

public function closure(Type $type, array $parameters, ?Type $returnType): mixed
public function closure(Type $self, array $parameters, ?Type $return): mixed
{
return $this->default($type);
return $this->default($self);
}

public function conditional(Type $type, Argument|Type $subject, Type $if, Type $then, Type $else): mixed
public function conditional(Type $self, Argument|Type $subject, Type $if, Type $then, Type $else): mixed
{
return $this->default($type);
return $this->default($self);
}

public function constant(Type $type, string $name): mixed
public function constant(Type $self, string $name): mixed
{
return $this->default($type);
return $this->default($self);
}

public function float(Type $type): mixed
public function float(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function int(Type $type): mixed
public function int(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function intersection(Type $type, array $types): mixed
public function intersection(Type $self, array $types): mixed
{
return $this->default($type);
return $this->default($self);
}

public function intMask(Type $type, Type $innerType): mixed
public function intMask(Type $self, Type $type): mixed
{
return $this->default($type);
return $this->default($self);
}

public function intRange(Type $type, ?int $min, ?int $max): mixed
public function intRange(Type $self, ?int $min, ?int $max): mixed
{
return $this->default($type);
return $this->default($self);
}

public function iterable(Type $type, Type $keyType, Type $valueType): mixed
public function iterable(Type $self, Type $key, Type $value): mixed
{
return $this->default($type);
return $this->default($self);
}

public function key(Type $type, Type $innerType): mixed
public function key(Type $self, Type $type): mixed
{
return $this->default($type);
return $this->default($self);
}

public function list(Type $type, Type $valueType): mixed
public function list(Type $self, Type $value): mixed
{
return $this->default($type);
return $this->default($self);
}

public function literal(Type $type, float|bool|int|string $value): mixed
public function literal(Type $self, float|bool|int|string $value): mixed
{
return $this->default($type);
return $this->default($self);
}

public function mixed(Type $type): mixed
public function mixed(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function namedClassString(Type $type, Type $objectType): mixed
public function namedClassString(Type $self, Type $object): mixed
{
return $this->default($type);
return $this->default($self);
}

public function namedObject(Type $type, string $class, array $templateArguments): mixed
public function namedObject(Type $self, string $class, array $templateArguments): mixed
{
return $this->default($type);
return $this->default($self);
}

public function never(Type $type): mixed
public function never(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function nonEmpty(Type $type, Type $innerType): mixed
public function nonEmpty(Type $self, Type $type): mixed
{
return $this->default($type);
return $this->default($self);
}

public function null(Type $type): mixed
public function null(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function numericString(Type $type): mixed
public function numericString(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function object(Type $type): mixed
public function object(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function objectShape(Type $type, array $properties): mixed
public function objectShape(Type $self, array $properties): mixed
{
return $this->default($type);
return $this->default($self);
}

public function offset(Type $type, Type $innerType, Type $offset): mixed
public function offset(Type $self, Type $type, Type $offset): mixed
{
return $this->default($type);
return $this->default($self);
}

public function resource(Type $type): mixed
public function resource(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function string(Type $type): mixed
public function string(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function template(Type $type, string $name, AtClass|AtFunction|AtMethod $declaredAt, Type $constraint): mixed
public function template(Type $self, string $name, AtClass|AtFunction|AtMethod $declaredAt, Type $constraint): mixed
{
return $this->default($type);
return $this->default($self);
}

public function truthyString(Type $type): mixed
public function truthyString(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

public function union(Type $type, array $types): mixed
public function union(Type $self, array $types): mixed
{
return $this->default($type);
return $this->default($self);
}

public function value(Type $type, Type $innerType): mixed
public function value(Type $self, Type $type): mixed
{
return $this->default($type);
return $this->default($self);
}

public function varianceAware(Type $type, Type $innerType, Variance $variance): mixed
public function varianceAware(Type $self, Type $type, Variance $variance): mixed
{
return $this->default($type);
return $this->default($self);
}

public function void(Type $type): mixed
public function void(Type $self): mixed
{
return $this->default($type);
return $this->default($self);
}

/**
* @return TReturn
*/
abstract protected function default(Type $type): mixed;
abstract protected function default(Type $self): mixed;
}
10 changes: 5 additions & 5 deletions src/IterableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
final class IterableType implements Type
{
/**
* @param Type<TKey> $keyType
* @param Type<TValue> $valueType
* @param Type<TKey> $key
* @param Type<TValue> $value
*/
public function __construct(
private readonly Type $keyType,
private readonly Type $valueType,
private readonly Type $key,
private readonly Type $value,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->iterable($this, $this->keyType, $this->valueType);
return $visitor->iterable($this, $this->key, $this->value);
}
}
6 changes: 3 additions & 3 deletions src/ListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
final class ListType implements Type
{
/**
* @param Type<TValue> $valueType
* @param Type<TValue> $value
*/
public function __construct(
private readonly Type $valueType,
private readonly Type $value,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->list($this, $this->valueType);
return $visitor->list($this, $this->value);
}
}
Loading

0 comments on commit 2dafbfd

Please sign in to comment.