Skip to content

Commit

Permalink
Removed most of the generic types and constraints
Browse files Browse the repository at this point in the history
Closes #37
  • Loading branch information
vudaltsov committed Feb 24, 2024
1 parent c7d93d5 commit a849136
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 172 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42.0",
"friendsofphp/php-cs-fixer": "^3.49.0",
"phpstan/phpstan": "^1.10.59",
"friendsofphp/php-cs-fixer": "^3.50.0",
"phpstan/phpstan": "^1.11@dev",
"phpunit/phpunit": "^10.5.10",
"phpyh/coding-standard": "^2.6.0",
"phpyh/psalm-tester": "^0.1.0",
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon

parameters:
level: 9
paths:
Expand Down
3 changes: 1 addition & 2 deletions src/AliasType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TType
* @implements Type<TType>
* @implements Type<mixed>
*/
final class AliasType implements Type
{
Expand Down
3 changes: 1 addition & 2 deletions src/ArrayShapeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TArray of array
* @implements Type<TArray>
* @implements Type<array>
*/
final class ArrayShapeType implements Type
{
Expand Down
4 changes: 1 addition & 3 deletions src/CallableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TReturn
* @implements Type<callable(): TReturn>
* @implements Type<callable>
*/
final class CallableType implements Type
{
/**
* @param list<Parameter> $parameters
* @param Type<TReturn> $returnType
*/
public function __construct(
private readonly array $parameters,
Expand Down
8 changes: 3 additions & 5 deletions src/ClassConstantType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TClassConstant
* @implements Type<TClassConstant>
* @implements Type<mixed>
*/
final class ClassConstantType implements Type
{
/**
* @param non-empty-string $class
* @param non-empty-string $name
*/
public function __construct(
private readonly string $class,
private readonly Type $classType,
private readonly string $name,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->classConstant($this, $this->class, $this->name);
return $visitor->classConstant($this, $this->classType, $this->name);
}
}
4 changes: 1 addition & 3 deletions src/ClosureType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TReturn
* @implements Type<\Closure(): TReturn>
* @implements Type<\Closure>
*/
final class ClosureType implements Type
{
/**
* @param list<Parameter> $parameters
* @param Type<TReturn> $returnType
*/
public function __construct(
private readonly array $parameters,
Expand Down
3 changes: 1 addition & 2 deletions src/ConstantType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TConstant
* @implements Type<TConstant>
* @implements Type<mixed>
*/
final class ConstantType implements Type
{
Expand Down
13 changes: 4 additions & 9 deletions src/DefaultTypeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function callable(Type $type, array $parameters, ?Type $returnType): mixe
return $this->default($type);
}

public function classConstant(Type $type, string $class, string $name): mixed
public function classConstant(Type $type, Type $classType, string $name): mixed
{
return $this->default($type);
}
Expand Down Expand Up @@ -86,12 +86,7 @@ public function intersection(Type $type, array $types): mixed
return $this->default($type);
}

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

public function intMaskOf(Type $type, Type $innerType): mixed
public function intMask(Type $type, Type $innerType): mixed
{
return $this->default($type);
}
Expand All @@ -106,7 +101,7 @@ public function iterable(Type $type, Type $keyType, Type $valueType): mixed
return $this->default($type);
}

public function keyOf(Type $type, Type $innerType): mixed
public function key(Type $type, Type $innerType): mixed
{
return $this->default($type);
}
Expand Down Expand Up @@ -196,7 +191,7 @@ public function union(Type $type, array $types): mixed
return $this->default($type);
}

public function valueOf(Type $type, Type $innerType): mixed
public function value(Type $type, Type $innerType): mixed
{
return $this->default($type);
}
Expand Down
26 changes: 0 additions & 26 deletions src/IntMaskOfType.php

This file was deleted.

10 changes: 3 additions & 7 deletions src/IntMaskType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TIntMask of int
* @implements Type<TIntMask>
* @implements Type<int>
*/
final class IntMaskType implements Type
{
/**
* @param non-empty-list<int> $ints
*/
public function __construct(
private readonly array $ints,
private readonly Type $type,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->intMask($this, $this->ints);
return $visitor->intMask($this, $this->type);
}
}
3 changes: 1 addition & 2 deletions src/IntRangeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TInt of int
* @implements Type<TInt>
* @implements Type<int>
*/
final class IntRangeType implements Type
{
Expand Down
3 changes: 1 addition & 2 deletions src/IntersectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TType
* @implements Type<TType>
* @implements Type<mixed>
*/
final class IntersectionType implements Type
{
Expand Down
7 changes: 3 additions & 4 deletions src/KeyOfType.php → src/KeyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TType
* @implements Type<TType>
* @implements Type<mixed>
*/
final class KeyOfType implements Type
final class KeyType implements Type
{
public function __construct(
private readonly Type $type,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->keyOf($this, $this->type);
return $visitor->key($this, $this->type);
}
}
10 changes: 3 additions & 7 deletions src/NamedClassStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TObject of object
* @implements Type<class-string<TObject>>
* @implements Type<non-empty-string>
*/
final class NamedClassStringType implements Type
{
/**
* @param Type<TObject> $type
*/
public function __construct(
private readonly Type $type,
private readonly Type $objectType,
) {}

public function accept(TypeVisitor $visitor): mixed
{
return $visitor->namedClassString($this, $this->type);
return $visitor->namedClassString($this, $this->objectType);
}
}
5 changes: 2 additions & 3 deletions src/NamedObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TObject of object
* @implements Type<TObject>
* @implements Type<object>
*/
final class NamedObjectType implements Type
{
/**
* @param class-string<TObject>|non-empty-string $class
* @param non-empty-string $class
* @param list<Type> $templateArguments
*/
public function __construct(
Expand Down
3 changes: 1 addition & 2 deletions src/ObjectShapeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
/**
* @internal
* @psalm-internal Typhoon\Type
* @template-covariant TObject of object
* @implements Type<TObject>
* @implements Type<object>
*/
final class ObjectShapeType implements Type
{
Expand Down
Loading

0 comments on commit a849136

Please sign in to comment.