Skip to content

Commit

Permalink
It's called any, not mixed (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
MidnightDesign authored Feb 16, 2024
1 parent 3a1fea9 commit 539c843
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static function alias(string $name, self $type): self
*/
public static function any(): self
{
return new self('mixed', Assert::mixed(...));
return new self('any', Assert::mixed(...));
}

/**
Expand Down Expand Up @@ -273,10 +273,10 @@ public function isSubtypeOf(self $other): bool
{
$self = $this->canonical();
$other = $other->canonical();
if ($other->name === 'mixed') {
if ($other->name === 'any') {
return true;
}
if ($self->name === 'mixed') {
if ($self->name === 'any') {
return false;
}
if ($self->name === 'Option') {
Expand Down
1 change: 1 addition & 0 deletions tests/unit/ExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public static function toStringCases(): iterable
'foo',
new Declarations(variables: ['foo' => Type::string()]),
];
yield 'Any type' => ['myval:any', 'myval:any'];
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Parser/ExpressionParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@ public static function invalidExpressions(): iterable
];
yield 'lambda returning the wrong type' => [
'x:list<string>.some(|i| i:string)',
'Argument 1 of some must be of type func(mixed): bool, got func(mixed): string',
'Argument 1 of some must be of type func(any): bool, got func(any): string',
];
yield 'passing a string to a function expecting a lambda' => [
'x:list<string>.some("foo")',
'Argument 1 of some must be of type func(mixed): bool, got string',
'Argument 1 of some must be of type func(any): bool, got string',
];
yield 'passing a lambda to a function expecting an int' => [
'x:string.substr(|i| i:int, 3)',
'Argument 1 of substr must be of type int, got func(mixed): int',
'Argument 1 of substr must be of type int, got func(any): int',
];
yield 'calling contains on an int' => [
'x:int.contains(42)',
'contains must be called on an expression of type list<mixed>, but x:int is of type int',
'contains must be called on an expression of type list<any>, but x:int is of type int',
];
yield 'call to undeclared function without an inline type' => [
'x:string.foo()',
Expand Down

0 comments on commit 539c843

Please sign in to comment.