Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97561 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77356 invoked from network); 7 Jan 2017 18:25:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jan 2017 18:25:04 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:34931] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/B5-37836-D7231785 for ; Sat, 07 Jan 2017 13:25:01 -0500 Received: by mail-wm0-f43.google.com with SMTP id a197so59482793wmd.0 for ; Sat, 07 Jan 2017 10:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=Oyx/IS47jrRWoi7W9VzBa1xXAs1B/ebD4d34rcGfX0s=; b=JBxvPuBTSzOW3ipKijDlp0zSWe4jwYnSj6fEzrxFBorUSnd1dc8uYjHnnOqgdH7UTA 3UXdzj9nuIeTGnGhcQLoPpyFy9Foc0j6lnuNiZ8QfoGPOpjWIfQZ9fQYLN2AbUs+LdEx c8waA9tbh52ACQ7RKdd6h/hm0F6p6F/5uTiwxcocZ4/nhnc8Spxp7IhjDtgvBmfa8rE2 iD9dkWXRvGGircqosFmGh4Wug+f+3aerKlVdS5BzfEGAfaoYyKFEMqVd7qp6h8HqjBWN 2kZNoVuf2WK+HslKvYI/VNWq5s3vxfiTB8AKZHeIDRQNI8vRXneIQxwb2JBKeA0YTJCB 0MQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=Oyx/IS47jrRWoi7W9VzBa1xXAs1B/ebD4d34rcGfX0s=; b=QmVMRfGIw+xV+AlPYTu1uTrIMYUAG2pTF0ulFSsFlWS9xwlqKG+fmFcDtty/D0+4be rF6qXI2kjXgS/TM+uSZO6IAZjcoM04Cds8K5jcEF/kfo587/Y4OQi1noImu9ZwNeHPen fh8/CbO0+a11FWT8a6kXmWNqoE9VFD8EQqzmHIiImOW3R60oBciYwaUNymyf8SeFDx0+ stC0BRnb8+XXFFpjrUO40B6T0N9CVxt8IKvLOBetmdn3VHKUJ0z/JW9wXQ/TwfF1UNyR I8imNtcj6M/6xzM3eKyYdchga3RBlfobiaEJbZ2D/DHjB1F/pqgP5gt55TwFDtZpCKvM 0RqA== X-Gm-Message-State: AIkVDXJ8tPUMAzi4fOXJVLP9nQefdl9G4RGLi8YAopIDCkAPl+sK45t2fi+sRZoZXRRO5Q== X-Received: by 10.28.142.5 with SMTP id q5mr1547438wmd.78.1483813498751; Sat, 07 Jan 2017 10:24:58 -0800 (PST) Received: from ?IPv6:2a00:23c4:4bd2:6e00:19e9:e99a:a646:76a2? ([2a00:23c4:4bd2:6e00:19e9:e99a:a646:76a2]) by smtp.googlemail.com with ESMTPSA id 135sm9630274wmh.14.2017.01.07.10.24.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jan 2017 10:24:58 -0800 (PST) To: PHP internals References: <8e8f1cf4-a698-63b0-71a6-84daff20fdf2@gmail.com> Message-ID: <6925329b-3513-544a-2d40-6fcf402ebfff@gmail.com> Date: Sat, 7 Jan 2017 18:24:57 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] SimpleXML's atXPath method From: rowan.collins@gmail.com (Rowan Collins) On 07/01/2017 17:01, Joe Watkins wrote: > Evening Rowan, > > I must protest: It is wasteful, unclear, and generally nasty, to > create, return, and manipulate an array if you are only ever going to > reference one element in code. Meh, feels like a micro-optimisation to me, and "[0] to access first search result" seems pretty obvious, but fair enough if you disagree. I know development's not a zero-sum game, but there are plenty of things I'd add to the SimpleXML extension that aren't just aliases for things you can trivially do already. For instance, sticking with XPath usage, the fact that registerXPathNamespace() only affects the current element, so has to be re-run as you traverse: $sx->registerXPathNamespace('a', 'http://example.com'); $foo = $xml->xpath('//a:foo')[0]; // do something with $foo $foo->registerXPathNamespace('a', 'http://example.com'); // won't work without this $bar = $foo->xpath('./a:bar')[0]; That's a lot more intrusive than needing to add "[0]" next to a few method calls. Regards, -- Rowan Collins [IMSoP]