Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33899 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75032 invoked by uid 1010); 10 Dec 2007 16:45:04 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 75016 invoked from network); 10 Dec 2007 16:45:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2007 16:45:04 -0000 Authentication-Results: pb1.pair.com header.from=steph@zend.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=steph@zend.com; spf=permerror; sender-id=softfail Received-SPF: error (pb1.pair.com: domain zend.com from 64.97.136.161 cause and error) X-PHP-List-Original-Sender: steph@zend.com X-Host-Fingerprint: 64.97.136.161 smtpout0161.sc1.he.tucows.com Solaris 8 (1) Received: from [64.97.136.161] ([64.97.136.161:31960] helo=n064.sc1.he.tucows.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A0/E5-37002-F0D6D574 for ; Mon, 10 Dec 2007 11:45:04 -0500 Received: from sc1-out05.emaildefenseservice.com (64.97.139.2) by n064.sc1.he.tucows.com (7.2.069.1) id 47586C890007D791; Mon, 10 Dec 2007 16:44:57 +0000 X-SpamScore: 50 X-Spamcatcher-Summary: 50,0,0,8401081f3d708e46,86f1fe7bf2bcddd7,steph@zend.com,-,RULES_HIT:355:379:539:540:541:542:543:567:599:601:945:960:967:973:980:982:988:989:1042:1155:1156:1260:1277:1311:1313:1314:1345:1437:1515:1516:1518:1534:1542:1587:1593:1594:1711:1730:1747:1766:1792:2073:2075:2078:2198:2199:2380:2393:2525:2560:2565:2682:2685:2692:2693:2828:2857:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3027:3354:3636:3653:3865:3866:3867:3868:3869:3870:3871:3872:3873:3874:3934: 3936:3938:3941:3944:4250:4321:4886:5007:6119:6120:6261:7679,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:none,DNSBL:none X-Spamcatcher-Explanation: Received: from foxbox (unknown [64.97.206.40]) (Authenticated sender: steph.fox) by sc1-out05.emaildefenseservice.com (Postfix) with ESMTP; Mon, 10 Dec 2007 16:44:56 +0000 (UTC) Message-ID: <00c001c83b4c$12cb0f30$e6dfc350@foxbox> Reply-To: "Steph Fox" To: "Stanislav Malyshev" Cc: References: <46.93.08781.F374D474@pb1.pair.com> <474d5320.0d135e0a.43d0.ffffd2b3@mx.google.com> <474D6813.9090606@eenterphace.org> <474DB7F8.5010907@zend.com> <016b01c83ae3$c3acfb60$e6dfc350@foxbox> <475CCA82.2010204@zend.com> <018b01c83aec$7413b2c0$e6dfc350@foxbox> <475CD134.9020005@zend.com> Date: Mon, 10 Dec 2007 16:45:27 -0000 Organization: Zend Technologies MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Subject: Re: [PHP-DEV] question regarding type hinting parameters of php functions (array_slice) From: steph@zend.com ("Steph Fox") >>> Right, that's what "l" parameter spec is doing, doesn't it? Why convert >>> it manually? >> >> Because it doesn't know the difference between NULL and 0 if it's a long. > > And why this difference is important in array_slice()? I don't see > anything in manual that says anything about NULLs. Could you explain? There's an IS_NULL check... if (ZEND_NUM_ARGS() >= 3 && Z_TYPE_P(length_param) != IS_NULL) { .... If Z_TYPE_P(length_param) is 0, it's not NULL because it has something in it. If length_param were of type long and had a value of 0, it would be NULL. The manual kind of skirts around it: "If length is given and is positive, then the sequence will have that many elements in it. If length is given and is negative then the sequence will stop that many elements from the end of the array. If it is omitted, then the sequence will have everything from offset up until the end of the array ." >> One that doesn't break every script that didn't strictly stay with int >> over the last 8 years or so. Actually that check hasn't been there forever, behaviour's different again in 5.1* - I didn't realize that. It used to always mean 0 (!) and was changed in 5.2.3 in response to a bug report: http://bugs.php.net/bug.php?id=41686. > Errm... I still don't understand. Could you give code example? C:\Documents and Settings\Steph\Desktop\PHP versions\5_1_2>php -a Interactive mode enabled php -a Interactive mode enabled int(1) [1]=> int(2) [2]=> int(3) } I think 0 and NULL should both always have acted like NULL does in 5_2_4 (which would happen if the third parameter was a long), but since 0 has always acted wrongly it's possible that people are relying on that behaviour. There's also the side-issue that every type has always been allowed in that argument, whether it makes sense or not. - Steph ps the patch on my bug report is now out of date (again). > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com http://www.zend.com/ > (408)253-8829 MSN: stas@zend.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >