Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87244 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77244 invoked from network); 23 Jul 2015 10:17:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2015 10:17:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=anatol.php@belski.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=anatol.php@belski.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain belski.net from 85.214.73.107 cause and error) X-PHP-List-Original-Sender: anatol.php@belski.net X-Host-Fingerprint: 85.214.73.107 klapt.com Received: from [85.214.73.107] ([85.214.73.107:54011] helo=h1123647.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/01-03755-35FB0B55 for ; Thu, 23 Jul 2015 06:17:56 -0400 Received: by h1123647.serverkompetenz.net (Postfix, from userid 1006) id AB78023D6299; Thu, 23 Jul 2015 12:17:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on h1123647.serverkompetenz.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.5 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable version=3.3.2 Received: from w530phpdev (pD9FE8C6D.dip0.t-ipconnect.de [217.254.140.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by h1123647.serverkompetenz.net (Postfix) with ESMTPSA id BFBEE23D6003; Thu, 23 Jul 2015 12:17:49 +0200 (CEST) To: "'Remi Collet'" , "'PHP Internals'" References: <55AF84C1.8070403@fedoraproject.org> <55B07B98.1050909@fedoraproject.org> In-Reply-To: <55B07B98.1050909@fedoraproject.org> Date: Thu, 23 Jul 2015 12:17:47 +0200 Message-ID: <020501d0c530$d4263440$7c729cc0$@belski.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQK6O6+cvVhGbhyp5NGRGiY/9DHs2AHICuffAqXFzncCPhDDbZvghrJg Content-Language: en-us Subject: RE: [PHP-DEV] RFE to allow dirname($foo, 2) From: anatol.php@belski.net ("Anatol Belski") Hi, > -----Original Message----- > From: Remi Collet [mailto:remi@fedoraproject.org] > Sent: Thursday, July 23, 2015 7:29 AM > To: PHP Internals > Subject: Re: [PHP-DEV] RFE to allow dirname($foo, 2) >=20 > Le 22/07/2015 20:57, Marco Pivetta a =C3=A9crit : > > On 22 July 2015 at 19:49, Sara Golemon > > wrote: > > > > On Wed, Jul 22, 2015 at 4:55 AM, Remi Collet > > wrote: > >> See https://bugs.php.net/bug.php?id=3D70112 > >> > > I'm not inherently against it, but this really really sounds like a > > job for a userspace function. > > > > function dirname_n($path, $n) { while (($path !=3D=3D '.') && $n--) = $path > > =3D dirname($path); return $path; } > > > > > > Indeed. What need is there to add a functionality to a relatively > > simple function like this one? What's the actual advantage that = cannot > > be achieved in userland code? > > >=20 > Legibility and the frequency of the usage of dirname(dirname(... > in various pieces of code. >=20 > See > = https://github.com/search?q=3Ddirname+__DIR__+language%3Aphp&ref=3Dsearch= r > esults&type=3DCode&utf8=3D%E2%9C%93 >=20 > As github search doesn't allow to search for (, I use __dir__ which = probably hides > more usage. >=20 > As "n" is usually 2 or 3, nobody will write a userland function. >=20 IMHO the idea is not doing any harm while solving a real use case. I = wouldn't resist to take it in, especially if there are more useful cases = and we can test the patch early. One more note is that it's somehow logic coupled with mkdir having the = recursive option. Also it's useful for including the autoloader as no = custom library functions are available yet. A downside could be - it = will encourage people writing a non PHP5 compatible code (or maybe it's = not an issue). Regards Anatol