Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73340 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22822 invoked from network); 20 Mar 2014 16:31:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2014 16:31:20 -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 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:62828] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/1F-33112-5D71B235 for ; Thu, 20 Mar 2014 11:31:18 -0500 Received: by mail-wi0-f170.google.com with SMTP id bs8so5256254wib.3 for ; Thu, 20 Mar 2014 09:31:14 -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=sDWiHDU+H5wEfUZwnWDEbK9rYaKNpe/jKiXCkAhiNeM=; b=g2MP37jniezLMyR4wAYNsWYhkus+vrqLX5urbUvHErofReIj6rZJcWaH5kfvBv1pLB GQYycKlZ8HP/M1IhaGGTuTW9jVhblM80ZTUUpsq01vDuF39IjwfB9WK7q1yx0X/rj3vP PhyUGy9Av8xe9yJd9AmtLNlmhfFuIgOUFhUt6b3xEOKoJeXABntq1RiraLX6sbftF3dk eSPC7uB0VBq/ld+3r3kUQvmDz96kjE4Bz4TGEo3NuQYEosi5HuzrYQEOhpuxOVrFFjyL xSzbm2jzFEgKBO84GMFtMyMw6hURhy6U+3FVVhO8yH2Ovxn/R0BYNRXTkwT0hMGmfvpt 94Og== X-Received: by 10.180.73.1 with SMTP id h1mr4151246wiv.10.1395333074595; Thu, 20 Mar 2014 09:31:14 -0700 (PDT) MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.216.47.67 with HTTP; Thu, 20 Mar 2014 09:30:44 -0700 (PDT) In-Reply-To: References: <532A3E88.20202@sugarcrm.com> <532A418A.8020607@sugarcrm.com> Date: Thu, 20 Mar 2014 17:30:44 +0100 X-Google-Sender-Auth: v7bQDeA3tv5zbxDsY4ofrG0NK7Y Message-ID: To: Stas Malyshev Cc: Tjerk Meesters , PHP Internals Content-Type: multipart/alternative; boundary=f46d0434c0b841373c04f50c4c9d Subject: Re: [PHP-DEV] Merge PR 621 From: colder@php.net (Etienne Kneuss) --f46d0434c0b841373c04f50c4c9d Content-Type: text/plain; charset=UTF-8 oops, few typos. On Thu, Mar 20, 2014 at 5:26 PM, Etienne Kneuss wrote: > > > > 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() > 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() > isset() -> has_dimension() && read_dimension() !== NULL -> offsetExists() && offsetGet() !== NULL empty() -> !has_dimension() || !read_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 > -- Etienne Kneuss http://www.colder.ch --f46d0434c0b841373c04f50c4c9d--