Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33485 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46851 invoked by uid 1010); 28 Nov 2007 13:13:45 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 46836 invoked from network); 28 Nov 2007 13:13:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Nov 2007 13:13:45 -0000 Authentication-Results: pb1.pair.com header.from=mbechler@eenterphace.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=mbechler@eenterphace.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain eenterphace.org from 212.227.83.217 cause and error) X-PHP-List-Original-Sender: mbechler@eenterphace.org X-Host-Fingerprint: 212.227.83.217 phoenix.epplehaus.de Linux 2.5 (sometimes 2.4) (4) Received: from [212.227.83.217] ([212.227.83.217:45453] helo=server1.epplehaus.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 89/D7-08781-7896D474 for ; Wed, 28 Nov 2007 08:13:44 -0500 Received: from [134.2.166.43] (vpn0543.extern.uni-tuebingen.de [134.2.166.43]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by server1.epplehaus.de (Postfix) with ESMTP id 78E30B80B2; Wed, 28 Nov 2007 14:13:24 +0100 (CET) Message-ID: <474D6813.9090606@eenterphace.org> Date: Wed, 28 Nov 2007 14:07:31 +0100 User-Agent: Thunderbird 2.0.0.6 (X11/20071002) MIME-Version: 1.0 To: Marco Kaiser CC: 'Dirk Thomas / 4wd media' , internals@lists.php.net References: <46.93.08781.F374D474@pb1.pair.com> <474d5320.0d135e0a.43d0.ffffd2b3@mx.google.com> In-Reply-To: <474d5320.0d135e0a.43d0.ffffd2b3@mx.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] question regarding type hinting parameters of php functions (array_slice) From: mbechler@eenterphace.org (Moritz Bechler) Hi, > >> 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. Actually most functions use implicit type conversions for this. So I wouldn't say this should cause a warning. > > > So i think the float value isnt correct casted as int value here. Maybe > someone else > can proof this. Yes, you are right here I think.... the code is if (ZEND_NUM_ARGS() >= 3 && Z_TYPE_P(length_param) != IS_NULL) { length = Z_LVAL_P(length_param); } else { length = num_in; } and afaik should be if (ZEND_NUM_ARGS() >= 3 && Z_TYPE_P(length_param) != IS_NULL) { convert_to_long(length_param); length = Z_LVAL_P(length_param); } else { length = num_in; } best regards Moritz Bechler