Skip to content

Commit

Permalink
The function in a callable-array is a non-empty-string
Browse files Browse the repository at this point in the history
  • Loading branch information
robchett committed Oct 9, 2023
1 parent df6b5fb commit 889bdca
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2304,7 +2304,7 @@ private static function reconcileArray(
} elseif ($type instanceof TCallable) {
$array_types[] = new TCallableKeyedArray([
new Union([new TClassString, new TObject]),
Type::getString(),
Type::getNonEmptyString(),
]);

$redundant = false;
Expand Down Expand Up @@ -2428,7 +2428,7 @@ private static function reconcileList(
} elseif ($type instanceof TCallable) {
$array_types[] = new TCallableKeyedArray([
new Union([new TClassString, new TObject]),
Type::getString(),
Type::getNonEmptyString(),
]);

$redundant = false;
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ private static function reconcileObject(
} elseif ($type instanceof TCallable) {
$non_object_types[] = new TCallableKeyedArray([
new Union([new TClassString, new TObject]),
Type::getString(),
Type::getNonEmptyString(),
]);
$non_object_types[] = new TCallableString();
$redundant = false;
Expand Down Expand Up @@ -1589,7 +1589,7 @@ private static function reconcileString(
} elseif ($type instanceof TCallable) {
$non_string_types[] = new TCallableKeyedArray([
new Union([new TClassString, new TObject]),
Type::getString(),
Type::getNonEmptyString(),
]);
$non_string_types[] = new TCallableObject();
$redundant = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private static function createInner(
true,
);
$object = new TObject(true);
$string = new TString(true);
$string = new TNonEmptyString(true);
return new TCallableKeyedArray([
new Union([$classString, $object]),
new Union([$string]),
Expand Down
2 changes: 1 addition & 1 deletion tests/TypeReconciliation/ReconcilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function providerTestReconcilation(): array
'nullableClassStringTruthy' => ['class-string<SomeClass>', new Truthy(), 'class-string<SomeClass>|null'],
'iterableToArray' => ['array<int, int>', new IsType(new TArray([Type::getArrayKey(), Type::getMixed()])), 'iterable<int, int>'],
'iterableToTraversable' => ['Traversable<int, int>', new IsType(new TNamedObject('Traversable')), 'iterable<int, int>'],
'callableToCallableArray' => ['callable-array{class-string|object, string}', new IsType(new TArray([Type::getArrayKey(), Type::getMixed()])), 'callable'],
'callableToCallableArray' => ['callable-array{class-string|object, non-empty-string}', new IsType(new TArray([Type::getArrayKey(), Type::getMixed()])), 'callable'],
'SmallKeyedArrayAndCallable' => ['array{test: string}', new IsType(new TKeyedArray(['test' => Type::getString()])), 'callable'],
'BigKeyedArrayAndCallable' => ['array{foo: string, test: string, thing: string}', new IsType(new TKeyedArray(['foo' => Type::getString(), 'test' => Type::getString(), 'thing' => Type::getString()])), 'callable'],
'callableOrArrayToCallableArray' => ['array<array-key, mixed>', new IsType(new TArray([Type::getArrayKey(), Type::getMixed()])), 'callable|array'],
Expand Down

0 comments on commit 889bdca

Please sign in to comment.