-
-
Notifications
You must be signed in to change notification settings - Fork 48
Closed
Milestone
Description
Flow comes with it's own internal type system:
type_float()type_string()- etc
The challange is that due to nullability being defined on a type level tools like phpstan can't properly narrow the type in methods like isValid(mixed $value) : bool
like it does for tools like webmozart/assert for example.
The goal is to also introduce Type::assert(mixed $value) : mixed so when we use it like this:
$floatValue = type_float()->assert($value);
// $floatValue type is float, not float|nullthe $floatValue is recognized as a proper float
Additionally we also want to get the same behavior for
$floatValue = caster()->to(type_float()->value($value);
// $floatValue type is float, not float|null