gettype() name; the returned Closure answers "is this of that type?".
Creates a predicate Closure that is true when the passed value's type matches the bound type-name string.
/**
* @param string $source Type name (bool, boolean, integer, object, ...).
* @return Closure(mixed):bool
*/
Comparisons\isScalar(string $source): ClosureWhen Comparisons\isScalar() is called, it returns the following Closure which can be used like a regular function.
/**
* @param mixed $value
* @return bool
*/
$function ($value): boolThis can be used to create a simple closure which can be used as a regular function.
$isString = Comparisons\isScalar('string');
var_dump($isString('hello')); // true
var_dump($isString(42)); // false
$isInt = Comparisons\isScalar('integer');
array_filter([1, '2', 3, 4.5, 5], $isInt); // [1, 3, 5]