Re: Allowing is_* functions to accept multiple parameters

From: Date: Wed, 18 Sep 2013 11:15:20 +0000
Subject: Re: Allowing is_* functions to accept multiple parameters
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Sep 18, 2013, at 11:53 AM, Leigh <[email protected]> wrote:

> Hi Internals.
> 
> How do you feel about expanding the is_* functions to accept multiple
> parameters similar to the way isset() already does?
> 
> ...
> 
> Thoughts?

For isset() there is a good reason to do this, because the var might not exist at all, and as such
you cannot use a function, as it would produce warnings.

However, for is_* functions, this could easily be done with a higher-order "every"
function. You pass a predicate and an array of values. It returns a boolean.

Example:

	if (!every('is_int', $numbers)) {
		throw new \InvalidArgumentException(...);
	}

Not only is that much cleaner in my opinion, it also is composable without having to change *all* of
the is_* predicates.

As such, I don't see much value in changing this.

Igor



Thread (19 messages)

« previous php.internals (#69183) next »