If you have been monitoring PHP's internal mailing list you probably know that over the last few weeks we've been locked in a stalemate in regard to the API revision of the filter extension brought to light by Dan from our documentation team. This is also the reason why despite this being early October PHP 5.2 is still not out.
Fortunately, after mediation with Derick and Pierre the two protagonists of the filter conundrum a compromise was finally reached. I took Pierre's proposed patch for the filter extension and based on it made a fairly series of adjustments yielding a very clear and flexible API (I hope) that seems to keep everyone happy. The patch was committed late last night and given lack of complaints today, I think we've finally got this issue resolved. YEY!
The only downside, is that my proposal to rename the filter extension to "Ilia' Awesome Filter Extension" was shot-down, with only Tony being in favor, oh well, I guess you can't have it all.
On a related note, since filter issue is now resolved, we can resume with the 5.2 release cycle and I hope to have RC5 out this Thursday to be followed shortly with a final release. On the bright side, the delay allowed us to fix about a dozen bugs and make PHP 5.2 even faster by fixing an inefficiency spotted by Matt W. related to creation of hash tables with known sizes.
Here is a brief overview of the filter function API and short descriptions of what the functions do. If you'd like more information take a look at the tests found within the filter extension.
filter_input() - Fetch an element from a given input source and return a filtered variant of the data.
filter_var() - Filter a PHP variable which can be either a scalar or an array (if flag indicating that arrays are allowed is passed).
filter_input_array() - Filter entire set of input arguments based on definitions provided in a form of another array.
filter_var_array() - Filter a variable containing an array based on definitions provided in a form of another array.
filter_list() - Get an array of all the available filters.
filter_id() - Return a filter name based on a filter's numeric identifier.
filter_has_var() - Determine if a variable is found within a particular input source.
Other changes to the filter extension include:
1) Added recursion protection.
2) Introduced 2 flags, FILTER_REQUIRE_SCALAR & FILTER_REQUIRE_ARRAY that allow you to identify the desired input type.
3) Introduced FILTER_FORCE_ARRAY flag that forces a scalar output to be returned in a form of an array.
Now that we got a more efficient use of the zend[_u]_hash_init() function, it would be nice to initially set the internal HashTable size to an appropriate value when we already now how many array elements we want to add in order to minimize the internal calls to zend_hash_do_resize() while adding elements. For example
$count = 100000;
$a = array();
$result = array_grow_internal_size($a, $count); // FALSE if $count is not numeric or smaller than the current internal size; otherwise new internal size (or TRUE)
for($i = 0; $i != $count; $i++)
$a[i] = $i * 2;
Keep up the good work,
P.S.: The comparison operator characters > and < seem not to be allowed, not so good for entering code snippets
Aliases at this stage would be a very bad idea. That's why I asked the internals list to find a comprimised based on my API. It is better to change the API and behaviors now that we are in beta that later when already a lot of people rely on this extension.