Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73345 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42230 invoked from network); 20 Mar 2014 21:22:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2014 21:22:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wg0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:47444] helo=mail-wg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/10-40859-60C5B235 for ; Thu, 20 Mar 2014 16:22:15 -0500 Received: by mail-wg0-f49.google.com with SMTP id a1so1049905wgh.20 for ; Thu, 20 Mar 2014 14:22:11 -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=UkShLfQ+kJJVVA+CzNEqc0RtUPLDdDBiQiD2TF28WM0=; b=XLd8MECI3A8K13qxIR2ggfGeoZc2JLEWTrLCtOC8im2h2aolKTwnuZYe7vMu9UI2zN QxNrPxAyrRO8CUKXoOgG6wlfwfDAUI5FgA2ddjn52TBcG6Y38ukacQAAVk/oQyfCJw3K ljCFRsKsyYWtb0cpHeqTcauluAnul03V0fWSdmM71aVCAohJnT6Fn6DiAbNxvNMEABDG bVTJd/buJeKuS+hGfeE8MEnxweBFvfif3y/gt7Xn99GK1xDBjTEbkaWsmyqeFj92eY4t yupTsSdFSN33Sr13yq/0BPCs2sfHwC+Day52R6wUI6UGG5MNTkSN4J2h+4I7tMUE3CKV o/aw== X-Received: by 10.194.63.236 with SMTP id j12mr35935184wjs.5.1395350531223; Thu, 20 Mar 2014 14:22:11 -0700 (PDT) MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.216.47.67 with HTTP; Thu, 20 Mar 2014 14:21:41 -0700 (PDT) In-Reply-To: <532B4A1B.5090503@sugarcrm.com> References: <532A3E88.20202@sugarcrm.com> <532A418A.8020607@sugarcrm.com> <532B4A1B.5090503@sugarcrm.com> Date: Thu, 20 Mar 2014 22:21:41 +0100 X-Google-Sender-Auth: qgg7ODqK9GUNzhu4SJbdiB8tQBU Message-ID: To: Stas Malyshev Cc: Tjerk Meesters , PHP Internals Content-Type: multipart/alternative; boundary=047d7ba98294c037f304f5105ca4 Subject: Re: [PHP-DEV] Merge PR 621 From: colder@php.net (Etienne Kneuss) --047d7ba98294c037f304f5105ca4 Content-Type: text/plain; charset=UTF-8 On Thu, Mar 20, 2014 at 9:05 PM, Stas Malyshev wrote: > Hi! > > > The current behavior is: > > > > isset() -> has_dimension(check_exmpty=false) -> offsetExists() > > empty() -> !has_dimension(check_exmpty=true) -> !offsetExists() > > || offsetGet() > > I think isset part is wrong - it should use offsetGet (probably via > check_empty=true) and then verify that the result is not null. > > > 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() > > I'm not sure this is the right way to go. It changes the existing API > without any need - while it can be handled within the existing API as well. > I agree that the API change is not in fact needed. We could limit ourselves to changing the behavior of the default has_dimension handler. It is also probably faster to do everything in has_dimension. I still think the "new version" is clearer, but it might not be worth the hassle of forcing this API change. The important part is that isset() triggers read_dimension and eventually offsetGet() for isset(), and we seem to agree on that. > > 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. > > This is actually OK, isset should return for ArrayObject the same it > would return for array with the same data. > > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > -- Etienne Kneuss http://www.colder.ch --047d7ba98294c037f304f5105ca4--