Variadic is_*() functions

From: Date: Mon, 11 Feb 2019 15:39:43 +0000
Subject: Variadic is_*() functions
Groups: php.internals 
Request: Send a blank email to internals+get-104342@lists.php.net to get a copy of this message
Hi internals, as I reviewed a bunch of code for handling data from different sources (eg. json) in the last days I stumbled over code like this multiple times: if (!(is_numeric($input['example1']) && is_numeric($input['example2']))) { if (!is_numeric($input['example1'] || !is_numeric($input['example2'])) { and I had multiple problems with this. * it's kinda hard to read * multiple writings for the same logic * ends up in complex conditionals I searched for discussions regarding this topic and found it was mentioned in a 'side thread' of the RFC for changing empty() to a variadic a few years ago (https://externals.io/message/82549#82641) and I'd like to collect some feedback if it's wothy to revisit the topic to write the above example as: if (!is_numeric($input['example1'], $input['example2'])) { Except the is_callable() method all is_*() methods could be extended with a variadic behaviour which would check the given values from the left to the right and abort if a value doesn't match the condition (in the example if a given value is not numeric). So all in all there are some points to talk about: Revisit the discussion? Which functions are reasonable to be extended? If all functions are reasonable: what to do with is_callable()? regards, Enno

« previous php.internals (#104342) next »