Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73339 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21320 invoked from network); 20 Mar 2014 16:27:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2014 16:27:19 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.174 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 74.125.82.174 mail-we0-f174.google.com Received: from [74.125.82.174] ([74.125.82.174:39548] helo=mail-we0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/BE-33112-6E61B235 for ; Thu, 20 Mar 2014 11:27:19 -0500 Received: by mail-we0-f174.google.com with SMTP id t60so787694wes.33 for ; Thu, 20 Mar 2014 09:27:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=JM/xVnhhExNtSRM4hHpmXDb1jDpMVlYEGBjBAaK6m7k=; b=lC3LDgeOF5CwFlgoAm2pMsIbfHyGBoCldO8qXup2qvvqkhK6GYV2NTS+TTxqS82WMr 0V6fhRYd+DUFpnNpfWerwnxmYxz1s+olpYCfBupGyr0+qg8LYznsPNDriwVILMox2O+N S9BYiOGCja7SOFA8DJdjG/9jNciWkjzkQSbxiV7t8XlSioyB/xJ5c/KsIKCZyJ7RvqqP Op27VgHJL+YGt5q2cVmSm0qvB9kGTkAz4ntj4P9Eea65ZzNk2T+fZGiP6ValgBJ2Zi/z i7onv4vPjuKVLAoYm+A7y3Kutf1uyjTDpReByI5ZBPoNCENIVu3WuDOtkUrpoph8fGYr JS/g== X-Received: by 10.180.98.71 with SMTP id eg7mr24574677wib.31.1395332835830; Thu, 20 Mar 2014 09:27:15 -0700 (PDT) MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.216.47.67 with HTTP; Thu, 20 Mar 2014 09:26:45 -0700 (PDT) In-Reply-To: <532A418A.8020607@sugarcrm.com> References: <532A3E88.20202@sugarcrm.com> <532A418A.8020607@sugarcrm.com> Date: Thu, 20 Mar 2014 17:26:45 +0100 X-Google-Sender-Auth: ax_sZ8a964Zo8ENWIFQGCL7WOhI Message-ID: To: Stas Malyshev Cc: Tjerk Meesters , PHP Internals Content-Type: multipart/alternative; boundary=f46d0442807005f07e04f50c3e34 Subject: Re: [PHP-DEV] Merge PR 621 From: colder@php.net (Etienne Kneuss) --f46d0442807005f07e04f50c3e34 Content-Type: text/plain; charset=UTF-8 On Thu, Mar 20, 2014 at 2:16 AM, Stas Malyshev wrote: > Hi! > > > Yes, that's probably what it was supposed to do, but as you can see > > from bug 66834 that's clearly not the case. I had earlier approached > > the problem purely from SPL standpoint (see linked PR) but Etienne > > said that it would be a better idea to tackle this issue further up > > the chain so to speak :) > > I think we need to first find out why that code did not work, instead of > ripping out the code that already was supposed to do exactly what this > bug is saying and replacing it with other code. At least we need to know > the reason why that did not work. So please do not merge this patch > until we know what's going on there. > The main question here is the following: what is the supposed semantics of has_dimension: is it the semantics of isset(), or array_key_exists(). The current behavior is: isset() -> has_dimension(check_exmpty=false) -> offsetExists() empty() -> !has_dimension(check_exmpty=true) -> !offsetExists() || offsetGet() which one might argue is inconsistent, at least in names. offsetExists relates to array_key_exists, and as such should IMHO return true for entries that are defined to NULL. ArrayObject follows that by (badly) hacking within has_dimension: $o = new ArrayObject(array('a' => NULL)); var_dump($o->offsetExists('a')); // true var_dump(isset($o['a'])); // false as long as ArrayObject::offset* are not overriden This patch is about decoupling has_dimension from isset()/empty() and doing, instead: isset() -> has_dimension() && get_dimension() !== NULL -> offsetExists() && offsetGet() !== NULL empty() -> !has_dimension() || !get_dimension() -> !offsetExists() && !offsetGet() which is in my opinion a sensible thing to do. Now it is clear it is a BC breaking change for people that defined offsetExists with array_key_exists: isset() which returned true for NULL will now invoke offsetGet and thus return false, but it is a change towards more consistency. If not everybody is confident about this, we will need a RFC. -- Etienne Kneuss --f46d0442807005f07e04f50c3e34--