RE: [PHP-DEV] question regarding type hinting parameters of php functions (array_slice)

From: Date: Wed, 28 Nov 2007 11:33:54 +0000
Subject: RE: [PHP-DEV] question regarding type hinting parameters of php functions (array_slice)
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-33484@lists.php.net to get a copy of this message
Hi Dirk, > When calling > "array_slice($array, 0, (float)2);" > the resulting array is EMPTY. > When using the right type > "array_slice($array, 0, (int)2);" > it works as expected. i think this should print a warning like other array functions. But i looked into the src and this looks more like a casting bug inside this function. $input = array('a', 'b', 'c', 'd', 'e'); var_dump(array_slice($input, 1, "1")); var_dump(array_slice($input, 1, 1)); var_dump(array_slice($input, 1, (FLOAT)1)); var_dump(array_slice($input, 1, 1.0)); output: array(1) { [0]=> string(1) "b" } array(1) { [0]=> string(1) "b" } array(0) { } array(0) { } So i think the float value isnt correct casted as int value here. Maybe someone else can proof this. -- Marco

« previous php.internals (#33484) next »