We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the following code:
<?php declare(strict_types=1); use Assert\Assert; class Result { private ?float $percent; private function __construct() { } /** @param array<string, mixed> $payload */ public static function fromQueryResults(array $payload): self { Assert::that($payload['percent']) ->nullOr() ->string() ->numeric(); $floatOrNull = static fn (?string $value): ?float => null === $value ? null : (float) $value; $instance = new self(); $instance->percent = $floatOrNull($payload['percent']); return $instance; } }
Produces the error: Parameter #1 $value of closure expects string|null, float|int|string|null given.
Parameter #1 $value of closure expects string|null, float|int|string|null given.
The type of $payload['percent'] should be infered to string|null, not float|int|string|null
$payload['percent']
string|null
float|int|string|null
The text was updated successfully, but these errors were encountered:
No branches or pull requests
the following code:
Produces the error:
Parameter #1 $value of closure expects string|null, float|int|string|null given.
The type of
$payload['percent']
should be infered tostring|null
, notfloat|int|string|null
The text was updated successfully, but these errors were encountered: