Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99064 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84521 invoked from network); 16 May 2017 22:21:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 May 2017 22:21:42 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.15.19 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.15.19 mout.gmx.net Received: from [212.227.15.19] ([212.227.15.19:65453] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/06-15531-37B7B195 for ; Tue, 16 May 2017 18:21:41 -0400 Received: from [192.168.2.102] ([79.243.116.67]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MgbTj-1dO8xG1W3b-00NwqP; Wed, 17 May 2017 00:21:17 +0200 To: Sara Golemon , "Christoph M. Becker" Cc: Remi Collet , PHP internals References: <1822acea-b6df-35bf-c760-7d1d06a3d88f@fedoraproject.org> Message-ID: <5e1c7ae7-4562-7268-7686-8be7305ac83c@gmx.de> Date: Wed, 17 May 2017 00:21:31 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:A3qhZlao7+NYNEGwxjUHvbOyi7ZHfsPYZl5PfnhaUEChiH8R9my rCWOOe8jJZd/GZk22XMgof3LVgsIk8IJzJg5W1FfCdbwWGAVtA7kZdqhWPkjyE5Yja4HuY/ hWq2PaVyt0iaExGWWKX3iFf9/4P43Pz2CvWKAL5rv7OEGnjnYodqXTAd/mRmA1HmsAiXgIH cXQ7msU+ncKQJ9CseeQeg== X-UI-Out-Filterresults: notjunk:1;V01:K0:SL7/MEaF8WM=:HMZTQHOrTnATLL4HSTFGPN hOGtNc5lvChgzNyNd6vIxav51/UxIVCIAJosKQLP24hld2DNBeLlXkMiso24AKg0pak3p6y2F sIXm0ALftRzCaa+N6dBpc5U4bVtwj5qtNocHa5Foc0Zgxz8oEzp7bq3i2cirALoQbnUNEkreu MSYXqL8ZZXL7nIQEYfzyO/BPULUsdLN4tbinlqmof4cz3fxzTYUWzNP0lraGWJGNLTi+wPoms MrjvgULpOqsY69iguYQL9Q4dxyZuzSaGSo35EHi1ailsOW7tuUggz+XDSCjvLO9HzjkDND3ks aCgX1rMvXb8W6lecu6IOpsylKTc+UIPKzOUuVqEMUTockvPGtupKRteE8wtaTz0WbmNXjeX49 J7gIdS0I9+qqWWfmhqo/8v/4G3e6kIDdUq9+GX9+O8E2OXXKcq6g31b61LZrHBXK2G8VW5kPS GQlkSy3jWARqEARQ97hoQf2VRXULxf07W+R9WxDPlzWhuL2a/ZsQm1kD8JH5oR+mATcaagNGp iYt1tC297MAcJKBFPJRo/ApTToSKSASZdf4cmyaWitZ4j4uWC26X8Fu+04PysrTYWcXnO74yx 3eWoNNz8pM7+GRsv3BXVW1CkLFqJxIAp4fg8mW+1mmYWyXHWmkhpmGRLvuf1Lk57VJ7MHFyHy jWOtk22lQeuyCBAPAQ4ik2FHXxxFjKLpXzUCXT/VWauRyJFJtp9gwK1wRn5oDUkgpFf9BONUw kzhj3y7Yw/TczWViYdgXsxp5YllfiVVFpUc8geSXVnAhoe+4DBYznk9lX/caa39R+bQD2xqiD sW7NK0G Subject: Re: [PHP-DEV] BC break in master (7.2) - Distinguish betweenunmatchedsubpatterns and empty matches in preg_*() From: cmbecker69@gmx.de ("Christoph M. Becker") On 17.05.2017 at 00:13, Sara Golemon wrote: > On Tue, May 16, 2017 at 5:03 PM, Christoph M. Becker wrote: > >>>> I suggest not to set unmatched subpatterns at all, >>> >>> Can you give an example of expected output ? >>> (I think stable position for matched pattern is important) >>> >>> php -r 'var_dump(preg_match("/(a)?([a-z]*)(\d*)/", "123", $matches), >>> $matches);' >> >> See the pcretest results danielklein posted in his last comment on >> . Basically, instead of assigning NULL as >> values, the array indexes could be skipped, so that array_key_exists() >> can be used to determine whether a certain subpattern matched or not. > > Well, but isset() would do this already with NULLs. > > $x = ['foo'=>NULL]; > // isset($x['foo'] === false) > > I know people are generally getting trained to use array_key_exists() > to avoid this "set but null" issue, but this is a case where that > behavior of isset() is actually quite useful. Personally, I rarely use array_key_exists(), but others may prefer it, and it appears to be cleaner not to set unmatched subpatterns at all. And if we're going to add a flag anyway, it appears to be reasonable to change the behavior right away, i.e. to introduce something like PREG_SKIP_UNMATCHED instead of PREG_UNMATCHED_AS_NULL. -- Christoph M. Becker