Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99063 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82931 invoked from network); 16 May 2017 22:13:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 May 2017 22:13:48 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.128.173 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.128.173 mail-wr0-f173.google.com Received: from [209.85.128.173] ([209.85.128.173:33780] helo=mail-wr0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/B5-15531-A997B195 for ; Tue, 16 May 2017 18:13:47 -0400 Received: by mail-wr0-f173.google.com with SMTP id w50so84457461wrc.0 for ; Tue, 16 May 2017 15:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=NJCDtCYEPLhnPBu4YbkosEIwmUuPO2X2hW77WLyTsVg=; b=OQAB4R+hOSFbWjgrgXasZejKOVMQfi9aqzfNbCLdgRYJ+NjmwDMQq1yowtGeFt3ek4 xU2jeJSDStLAFHklzLIYk4BAezxEa6BG9rQbzLYJrtme4hgLGqr89tKZ3fNleEvx1KnD SSiL9YyMZQNRlqeoZZ3XfHzLAI2uybo4Pct2ZT9ilenog/yW2byx84PfkBNLeXO1uafl gnNe7MHRu40+BDRavJeF+qB9bbfZp8Jek19+08x+5H1xmiwXCG89sfyj7thtndF112TW NvekH3r8m7Y+rMfQJG+K4Ok3ZZGx3GdLnL/r7U059IuF2U93qjXt1iSa9amz4EsRYZpY 8K1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=NJCDtCYEPLhnPBu4YbkosEIwmUuPO2X2hW77WLyTsVg=; b=DkUP4jJzH9VJtEkqkw6Gdgz6IGP5U9ek5SiDxqS7tCdJLPte+6BGNX/Gk9dItYNRLl JCRKS+lpTvOrVumvmJYj/o7yvEQbxzfoPAPCHRY851/Nm5AnWAfYHDsnn++a+JhwnTRR f/+oDetM9tJKzDmKltIzZBFSJ2AKV80H4TvPbdITDnJiwDuNM/VEZmbnuWQ52O79Xe/U wilsosBeM000npi0DFY748ul+h3fhNO9YL+sgOj16QrYEQjGifF+LepNT28Vn79tTe3u dSTEjWD6JBdwm/DbtEYXtzd33+ds14cJZ26iCwuSecAWNela+DZ3iCKIoqvhsfLhoJs9 iXgA== X-Gm-Message-State: AODbwcCTgZjbm/fgIUPE1Oz+/K5p4fPbSVBxKRp1Jn9RJLqdG9b9e4Nn lRoYsJIRmtreTK/OSqPOEitECU6uhMSUCgk= X-Received: by 10.223.173.74 with SMTP id p68mr76271wrc.163.1494972823607; Tue, 16 May 2017 15:13:43 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.157.38 with HTTP; Tue, 16 May 2017 15:13:42 -0700 (PDT) X-Originating-IP: [73.9.224.155] In-Reply-To: References: <1822acea-b6df-35bf-c760-7d1d06a3d88f@fedoraproject.org> Date: Tue, 16 May 2017 17:13:42 -0500 X-Google-Sender-Auth: 3uSC4ZwBZsyjNnKrs_86qSM2rBo Message-ID: To: "Christoph M. Becker" Cc: Remi Collet , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] BC break in master (7.2) - Distinguish betweenunmatched subpatterns and empty matches in preg_*() From: pollita@php.net (Sara Golemon) 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. -Sara