Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33903 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20342 invoked by uid 1010); 10 Dec 2007 18:50:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 20327 invoked from network); 10 Dec 2007 18:50:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2007 18:50:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=steph@zend.com; spf=permerror; sender-id=softfail Authentication-Results: pb1.pair.com header.from=steph@zend.com; sender-id=softfail Received-SPF: error (pb1.pair.com: domain zend.com from 64.97.136.177 cause and error) X-PHP-List-Original-Sender: steph@zend.com X-Host-Fingerprint: 64.97.136.177 smtpout0177.sc1.he.tucows.com Solaris 8 (1) Received: from [64.97.136.177] ([64.97.136.177:38133] helo=n082.sc1.he.tucows.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F2/3C-37002-F6A8D574 for ; Mon, 10 Dec 2007 13:50:26 -0500 Received: from sc1-out05.emaildefenseservice.com (64.97.139.2) by n082.sc1.he.tucows.com (7.2.069.1) id 475869C200083CA1; Mon, 10 Dec 2007 18:50:17 +0000 X-SpamScore: 50 X-Spamcatcher-Summary: 50,0,0,528844a2ad21c96d,86f1fe7bf2bcddd7,steph@zend.com,-,RULES_HIT:355:379:539:540:541:542:543:567:599:601:967:973:980:988:989:1000:1042:1155:1156:1260:1308:1309:1313:1314:1345:1437:1515:1516:1518:1535:1541:1575:1587:1594:1711:1730:1747:1764:1766:1792:2073:2075:2078:2198:2199:2380:2393:2525:2560:2564:2682:2685:2693:2857:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3027:3353:3865:3866:3867:3868:3869:3870:3871:3872:3874:3934:3936:3938:3941:3944:4118: 4321:4886:5007:6119:6120:6261:7281: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 18:50:16 +0000 (UTC) Message-ID: <020c01c83b5d$93c04db0$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> <00c001c83b4c$12cb0f30$e6dfc350@foxbox> <475D7F3B.30504@zend.com> Date: Mon, 10 Dec 2007 18:50:45 -0000 Organization: Zend Technologies MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0209_01C83B5D.929DEDC0" 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") ------=_NextPart_000_0209_01C83B5D.929DEDC0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit >> 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 ." > > Meaning, basically, -1 is the same as omitted and the same as null? No, that works as it says in the manual. -1 is one short of all elements. The only thing the manual doesn't say is what it means by 'omitted', so it's down to whether anyone's found 0 useful when it acts as it always has. If they haven't, we can move to long and break any existing code that uses something other than an integer, but at least we'll be giving a warning about it. If they have, we don't have any option but to stay with the zval and fix it to work as it did up until last month. Warnings in that case would be an added extra. - Steph ps Sane patches attached for both the long version and the zval version (with no warnings). The current test for array_slice behaviour will need fixing whatever the decision is. Please ignore everything on the associated bug report.. > -- > 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 > ------=_NextPart_000_0209_01C83B5D.929DEDC0 Content-Type: text/plain; format=flowed; name="array_slice_with_zval.txt"; reply-type=response Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="array_slice_with_zval.txt" Index: ext/standard/array.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /repository/php-src/ext/standard/array.c,v=0A= retrieving revision 1.308.2.21.2.37.2.11=0A= diff -u -r1.308.2.21.2.37.2.11 array.c=0A= --- ext/standard/array.c 5 Dec 2007 19:55:31 -0000 1.308.2.21.2.37.2.11=0A= +++ ext/standard/array.c 9 Dec 2007 23:07:13 -0000=0A= @@ -2120,6 +2120,7 @@=0A= =0A= /* We want all entries from offset to the end if length is not passed = or is null */=0A= if (ZEND_NUM_ARGS() >=3D 3 && Z_TYPE_P(length_param) !=3D IS_NULL) {=0A= + convert_to_long(length_param);=0A= length =3D Z_LVAL_P(length_param);=0A= } else {=0A= length =3D num_in;=0A= ------=_NextPart_000_0209_01C83B5D.929DEDC0 Content-Type: text/plain; format=flowed; name="array_slice_with_long.txt"; reply-type=response Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="array_slice_with_long.txt" Index: ext/standard/array.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /repository/php-src/ext/standard/array.c,v=0A= retrieving revision 1.308.2.21.2.37.2.11=0A= diff -u -r1.308.2.21.2.37.2.11 array.c=0A= --- ext/standard/array.c 5 Dec 2007 19:55:31 -0000 1.308.2.21.2.37.2.11=0A= +++ ext/standard/array.c 10 Dec 2007 18:40:05 -0000=0A= @@ -2101,17 +2101,16 @@=0A= zval *input, /* Input array */=0A= **entry; /* An array entry */=0A= long offset, /* Offset to get elements from */=0A= - length; /* How many elements to get */=0A= + length =3D 0; /* How many elements to get */=0A= zend_bool preserve_keys =3D 0; /* Whether to preserve keys while = copying to the new array or not */=0A= int num_in, /* Number of elements in the input array */=0A= pos; /* Current position in the array */=0A= - zval *length_param;=0A= char *string_key;=0A= uint string_key_len;=0A= ulong num_key;=0A= HashPosition hpos;=0A= =0A= - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|zb", &input, = &offset, &length_param, &preserve_keys) =3D=3D FAILURE) {=0A= + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|lb", &input, = &offset, &length, &preserve_keys) =3D=3D FAILURE) {=0A= return;=0A= }=0A= =0A= @@ -2119,9 +2118,7 @@=0A= num_in =3D zend_hash_num_elements(Z_ARRVAL_P(input));=0A= =0A= /* We want all entries from offset to the end if length is not passed = or is null */=0A= - if (ZEND_NUM_ARGS() >=3D 3 && Z_TYPE_P(length_param) !=3D IS_NULL) {=0A= - length =3D Z_LVAL_P(length_param);=0A= - } else {=0A= + if (length =3D=3D IS_NULL) {=0A= length =3D num_in;=0A= }=0A= =0A= ------=_NextPart_000_0209_01C83B5D.929DEDC0--