[wp-hackers] PHP Coding Practices

Robert Deaton false.hopes at gmail.com
Wed Feb 15 01:56:06 GMT 2006


On 2/15/06, Dave Grijalva <grijalva at gmail.com> wrote:
> That's not really true.  I'm pretty sure you can foreach a PHP4 array.

Where did this come from? Nobody was debating that. In the event that
you really meant object, you are wrong, as per http://php.net/foreach,
object iteration was added in PHP5.

> <snip>  In either case, it seems foolish to include code that will
> become a problem in the future, no matter how remote.  Plus, people who are
> running on 5 and want to take advantage of it should be able to.  Backwards
> compatibility is great, but forwards compatibility is a no brainer.

I am in no way seeing how this would break forwards compatability.
Anyone who wants to submit a patch that iterates over an object can
easily do so, leaving out the typecast (maybe even making a comment
that it is an object so that nobody else comes along and tries to
typecast it), and continue along with their life.

We cannot change the behavior of foreach to force the typecast, but we
can however typecast wherever we know we are expecting an array.

--
--Robert Deaton
http://somethingunpredictable.com


More information about the wp-hackers mailing list