Bug #76734 [Opn->Csd]: Parameter type cannot be limited to scalar with FILTER_CALLBACK

From: Date: Fri, 07 Feb 2020 06:05:32 +0000
Subject: Bug #76734 [Opn->Csd]: Parameter type cannot be limited to scalar with FILTER_CALLBACK
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225401@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76734&edit=1 ID: 76734 Updated by: phpdocbot@php.net Reported by: 498936940 at qq dot com Summary: Parameter type cannot be limited to scalar with FILTER_CALLBACK -Status: Open +Status: Closed Type: Bug Package: Filter related Operating System: Linux PHP Version: 7.2.8 Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmb Revision: http://git.php.net/?p=doc/en.git;a=commit;h=a88a42497fb14cb2a3adc35d1e5962c4cec4275e Log: Fix #76734: Parameter type cannot be limited to scalar with FILTER_CALLBACK Previous Comments: ------------------------------------------------------------------------ [2018-08-14 14:31:01] 498936940 at qq dot com i'm feel no happy. ------------------------------------------------------------------------ [2018-08-14 06:21:14] requinix@php.net Perhaps classifying this as a doc bug was premature. While the flags are deliberately not used, I see no way to use FILTER_CALLBACK and enforce a scalar or array: the callback is called on the non-array (leaf) values, so even with ?id[0][]=3&id[1][]=4 the callback only receives the values 3 and 4. The obvious workaround is to apply two filters: one with filter_input_array and FILTER_REQUIRE_SCALAR, then another with filter_var_array and FILTER_CALLBACK. ------------------------------------------------------------------------ [2018-08-14 02:01:18] 498936940 at qq dot com Not just the Documentation Problem problem, but Bug still has problems. ------------------------------------------------------------------------ [2018-08-14 01:12:14] 498936940 at qq dot com ··· var_dump( filter_input_array( INPUT_GET, [ 'id' => [ 'filter' => FILTER_CALLBACK, 'options' => function($v){ return is_scalar($v) ? $v : null; } ] ] ) ); exit(); /?id=2 array(1) { ["id"]=> string(1) "2" } /?id[]=3&id[]=4 array(1) { ["id"]=> array(2) { [0]=> string(1) "3" [1]=> string(1) "4" } } ··· I must limit ID must be scalar, not array, filter cannot control! ------------------------------------------------------------------------ [2018-08-13 11:42:53] cmb@php.net This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=76734 -- Edit this bug report at https://bugs.php.net/bug.php?id=76734&edit=1

« previous php.bugs (#225401) next »