Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41371 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57297 invoked from network); 24 Oct 2008 18:23:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2008 18:23:19 -0000 Authentication-Results: pb1.pair.com header.from=Johannes.Schlueter@Sun.COM; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 192.18.6.21 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 192.18.6.21 gmp-eb-inf-1.sun.com Solaris 10 (beta) Received: from [192.18.6.21] ([192.18.6.21:51963] helo=gmp-eb-inf-1.sun.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/44-01351-59212094 for ; Fri, 24 Oct 2008 14:23:19 -0400 Received: from fe-emea-09.sun.com (gmp-eb-lb-2-fe2.eu.sun.com [192.18.6.11]) by gmp-eb-inf-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id m9OINEH7009282 for ; Fri, 24 Oct 2008 18:23:14 GMT Received: from conversion-daemon.fe-emea-09.sun.com by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0K99009019JJ5200@fe-emea-09.sun.com> (original mail from johannes@php.net) for internals@lists.php.net; Fri, 24 Oct 2008 19:23:14 +0100 (BST) Received: from [192.168.1.101] ([93.104.97.150]) by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0K99006419QM5J20@fe-emea-09.sun.com>; Fri, 24 Oct 2008 19:23:14 +0100 (BST) Date: Fri, 24 Oct 2008 20:23:04 +0200 In-reply-to: <4902006C.7030501@zend.com> Sender: Johannes.Schlueter@Sun.COM To: Stanislav Malyshev Cc: Alexey Zakhlestin , Ionut Gabriel Stan , Mark van der Velden , PHP Internals Message-ID: <1224872584.19390.118.camel@goldfinger.johannes.nop> MIME-version: 1.0 X-Mailer: Evolution 2.22.3.1 (2.22.3.1-1.fc9) Content-type: text/plain Content-transfer-encoding: 7BIT References: <4900DB81.4000805@zend.com> <4900E150.1010607@dynom.nl> <49018FC3.90302@gmail.com> <1224854888.19390.89.camel@goldfinger.johannes.nop> <4902006C.7030501@zend.com> Subject: Re: [PHP-DEV] array_key_exists BC break From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Fri, 2008-10-24 at 10:05 -0700, Stanislav Malyshev wrote: > Hi! > > > 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: > > Just so it is clear - some scripts ALREADY work differently, that's why > it says "BC break". There's a difference between "working differently, but doing something" and "throwing an error". > > > 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. > > In 5.2 it would return true and not the value of $o->prop. > In 5.3 I don't think it would call offsetGet. It would call > get_properties method of ArrayAccess, and that should return list of > object's properties as array, so in this case the return will still be true. I didn't check array_key_exists but most of the affected functions use Z_OBJ_HT and therefore directly access the property table, not the property access APIs. Now changing to these APIs will be a silent change, whereas the old behavior might be considered as a bug, throwing an error might be a good compromise. Example showing the 3 different behaviors: $ cat array_key_exists_array_access.php 1) $ php52 array_key_exists_array_access.php bool(true) 2) $ php53 array_key_exists_array_access.php Warning: array_key_exists() expects parameter 2 to be array, object given in /home/johannes/public_html/- on line 20 NULL 3) Result after using ArrayAccess: Test::offsetExistst(prop) bool(false) Going from 1) to 3) will certainly confuse users and leads to changes in behavior which can't be found in an easy way... johannes