Re: array_key_exists BC break

From: Date: Fri, 24 Oct 2008 13:28:08 +0000
Subject: Re: array_key_exists BC break
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-41367@lists.php.net to get a copy of this message
On Fri, 2008-10-24 at 13:15 +0400, Alexey Zakhlestin wrote: > On Fri, Oct 24, 2008 at 1:05 PM, Ionut Gabriel Stan > <ionut.g.stan@gmail.com> wrote: > > But wouldn't be useful to at least accept objects implementing ArrayAccess? > > sounds like a good idea to me nope that would mean that some scripts might work different between 5.2 and 5.3, now one gets an error. consider such a script: <?php class Foo extends ArrayAccess { public $prop = 42; function offsetGet($n) { ... } .... } $o = new foo; array_key_Exists('prop', $o); ?> In <= 5.2 it will return the value of $o->prop, in 5.3 it would call the offsetGet() method. I prefer an error, if many people want the old behavior that's fine to me, but don't change it. btw. this also affects quite a few other functions: next/current/key/... at least ... and maybe more after using the "new" parameter parsing API. johannes

« previous php.internals (#41367) next »