Re: question regarding type hinting parameters of php functions (array_slice)

From: Date: Mon, 10 Dec 2007 18:02:35 +0000
Subject: Re: question regarding type hinting parameters of php functions (array_slice)
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-33902@lists.php.net to get a copy of this message
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.
Ouch... Now I see. Is there anybody using this trick, provided it never was documented? This is *so* wrong.
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? -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#33902) next »