empty() for use as a callback.
Direct predicate — returns true when the value is not empty in PHP's empty() sense.
/**
* @param mixed $value
* @return bool
*/
Comparisons\notEmpty($value): boolThis can be used to create a simple closure which can be used as a regular function.
var_dump(Comparisons\notEmpty('hello')); // true
var_dump(Comparisons\notEmpty('')); // false
var_dump(Comparisons\notEmpty([])); // false
var_dump(Comparisons\notEmpty(0)); // false
// As a callback.
$populated = array_filter(
['a', '', 'b', 0, 'c'],
'PinkCrab\FunctionConstructors\Comparisons\notEmpty'
);
print_r($populated); // ['a', 'b', 'c']