Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124063 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 3086A1A009C for <internals@lists.php.net>; Sat, 29 Jun 2024 21:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719696290; bh=ZmI1LBnY0lKcZ3YryEmujuWKe+jPop8Zwl1NiwUe35M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RfxaeR1LWwnWNHB8lWdnK32c0OqfXDgksC7gfah7BEBadoi9AvYMtx+yhzKg/sNNy owcBEAQus6M8Ya6fXFDkyrKYMLzS6iAj+LLm8AYbz538E0/LXtchPT2M/O4EbH8aQy skvIo4tI0Fload1F0e5QQ5J8EgPwKNVgcFNw6cHV/u7vwKrW1N3C+FSbzMfTrg3cNM IT0IbRu4D4+xwBh06brzKkAELjjReXQ/hqTbcSdvgUo5/z88nyy5FYuR++bTw3/EGK WcP80jZtSrfEDvdgMO87dQ9Fr1765ncSz0FrCSkQ2o/ZEDebomUPK32VKYAvM6gTt2 mRfS3m6mPPycg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 551C1180932 for <internals@lists.php.net>; Sat, 29 Jun 2024 21:24:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: <mickmackusa@gmail.com> Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for <internals@lists.php.net>; Sat, 29 Jun 2024 21:24:45 +0000 (UTC) Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-57cb9a370ddso2262536a12.1 for <internals@lists.php.net>; Sat, 29 Jun 2024 14:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719696205; x=1720301005; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=nekz1J8eK9qSDaCA8ghFqhSXdJo5I/YEL0QUv38Tpa8=; b=ac6Z3ZyI65P7uY5YaT3feueBbLJNkzqoxYoMesB4BGx5zaJbdYrowAwXfzctbdTPW4 +yM/bE1/4FPEwJx+W0q45GprMet/8lSw7nND7qYr1KrfFA0Cf9NSZ493TAgmjJcHSA83 BQRHkuc0GlbjMV4XB5bvpaII03j5UDyQzjOOyxZ6lVB6e2Qrc4NVnCL6gw4omN2AyTaE AVQWuxavt6Z/jJSfVetfcwEULEW1mNHlmoXYerHGStXGn6tkIKehik3inkfkMapqfjga jiqKRajQyNorGUnyUAl22nnvspIjaCZWvR/hu/KBE+n51ElnUg8twhTMC55SuzBC6ld8 okLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719696205; x=1720301005; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nekz1J8eK9qSDaCA8ghFqhSXdJo5I/YEL0QUv38Tpa8=; b=DUogn/ykEn3nyvZb3EBq6MRDdCwJHPoRZt1O9U3FXIlWWsa/JV+fMv/bjvlocz20Z4 yQapiEwbS0RneXsUK7rb/QQuUnrWqx3EnmHi5UH8Ik9luN4YzzbG7/pXVe8WbPemawQK ekTCdfavnoKiH49FsS+i36SFkr/eU4oik+X2qfqpch29MAcD7OWv+R4Ds5MUHbHFm4+X BNF7JyNfjCJsZm4tc0RV2B6x/IycO6VRx5oXjRsd7jP2xL1/YA8UuXVwWrA8JqD6cLPP GfieEUjTYuTOr/fzyLs6w9Reoedyg+7qLGjUcuCTvOrv8B5Khq4RoC3ZDAuSMhV0rxUA 5zCg== X-Forwarded-Encrypted: i=1; AJvYcCXkyH9lTEzd1J3O24OAobzlxSdMR+DOEktEBBNzROKGMrrd293yy50+AozkX6nMBxg9Gum/d+TV17xlToamZLuuhYd56QAPDw== X-Gm-Message-State: AOJu0Yw9avpUTRHmXH6ZpstZlLh/LAxd6rjw7CzLq0TNEerzEAV9UeBP HfRmiYZNXAWiNCKJiyXu3xIMkCQUO4TbuyROT5H/Ab+3NlXORazMWtrRp4EIBwDbjQn6hosfQnD F9TDlEKywZUgfylEGlVxEvlQv4rk= X-Google-Smtp-Source: AGHT+IEjG+K2uUG1Z0mPKi2xeidoLPFtd8Qk3kIdfDjwSVlrMAiNb0E9LYo1AW7O4TOwwAUc+HrU4KzuSuMN3+pEKHU= X-Received: by 2002:a05:6402:278d:b0:57d:692:92d9 with SMTP id 4fb4d7f45d1cf-5879ece923cmr1504961a12.4.1719696204642; Sat, 29 Jun 2024 14:23:24 -0700 (PDT) Precedence: bulk list-help: <mailto:internals+help@lists.php.net list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net> list-post: <mailto:internals@lists.php.net> List-Id: internals.lists.php.net MIME-Version: 1.0 References: <bw20I5b7ly3lSbI-2Bv3kfrfTVJbDo5RhwBiQa1PEwuLjprDJWptPajLiaialj1RLVKu7z1j0MofJUhhRVtzT_5i2E11oKeQx_VMUxnKhUE=@gpb.moe> <E146A171-CFA6-4E3F-91AA-2ACE7710A6D9@newclarity.net> <dbGe34EpQtjyP7ja7aUHnZYwmtupxeLd7EoOv3JjQMSh_UqoMrbqo5PkxrlIiaXJePC1-TfLyyblz5QDM13OkitgBqKPuSvh28WiJFh7qJI=@gpb.moe> <B958318C-B61D-4618-BA7D-3BF204C5B3CD@newclarity.net> <ca140b2c-51ff-4217-8f66-23f877ac0cb8@gmail.com> <3f230c9b-7aca-4bce-ab2a-544a10bf128f@bastelstu.be> In-Reply-To: <3f230c9b-7aca-4bce-ab2a-544a10bf128f@bastelstu.be> Date: Sun, 30 Jun 2024 07:23:12 +1000 Message-ID: <CAKVXxD8k0aJj9RisUOnvFo6qynX1eyO4whPz5jc4wyknqw83tQ@mail.gmail.com> Subject: Re: [PHP-DEV] [RFC] Deprecations for PHP 8.4 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= <tim@bastelstu.be> Cc: Markus Podar <markus.podar@gmail.com>, internals <internals@lists.php.net> Content-Type: multipart/alternative; boundary="00000000000066433f061c0df94a" From: mickmackusa@gmail.com (mickmackusa) --00000000000066433f061c0df94a Content-Type: text/plain; charset="UTF-8" > > If one can easily use a function incorrectly in a way that is not > *immediately* apparent, then I consider the function to be badly > designed. > Does that philosophy also cover preg_quote()? I've lost count of the number of times that I've seen it used in Stack Overflow answers without a second parameter (including array_map('preg_quote', $array)) and its returned value used in a regex that has foward slashes as delimiters. Additionally, it is an unintuitively named function; it doesn't actually "quote" anything -- it \e\s\c\a\p\e\s characters. This makes life unnecessarily harder for devs who are new to PHP who need to find the regex escaping function. Would it be reasonable to create `preg_escape()` which also (sometimes unnecessrily) includes the (de facto default delimiter) forward slash in its default list of escaped characters so that preg_quote() could eventually be deprecated? As far as I know this would do no harm, will prevent holes in code, and make PHP more intuitive. Mick > --00000000000066433f061c0df94a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div><div class=3D"gmail_quote"><blockquote class=3D"gmai= l_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left= :1ex">If one can easily use a function incorrectly in a way that is not <br= > *immediately* apparent, then I consider the function to be badly <br> designed.=C2=A0<br></blockquote></div></div><div dir=3D"auto"><br></div><di= v dir=3D"auto">Does that philosophy also cover preg_quote()?=C2=A0 I've= lost count of the number of times that I've seen it used in Stack Over= flow answers without a second parameter (including array_map('preg_quot= e', $array)) and its returned value used in a regex that has foward sla= shes as delimiters.</div><div dir=3D"auto"><br></div><div dir=3D"auto">Addi= tionally, it is an unintuitively named function; it doesn't actually &q= uot;quote" anything -- it \e\s\c\a\p\e\s characters.=C2=A0 This makes = life unnecessarily harder for devs who are new to PHP who need to find the = regex escaping function.</div><div dir=3D"auto"><br></div><div dir=3D"auto"= >Would it be reasonable to create `preg_escape()` which also (sometimes unn= ecessrily) includes the (de facto default delimiter) forward slash in its d= efault list of escaped characters so that preg_quote() could eventually be = deprecated?=C2=A0 As far as I know this would do no harm, will prevent hole= s in code, and make PHP more intuitive.</div><div dir=3D"auto"><br></div><d= iv dir=3D"auto">Mick</div><div dir=3D"auto"><div class=3D"gmail_quote"><blo= ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c= cc solid;padding-left:1ex"> </blockquote></div></div></div> --00000000000066433f061c0df94a--