Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87242 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60339 invoked from network); 23 Jul 2015 05:29:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2015 05:29:05 -0000 Authentication-Results: pb1.pair.com header.from=remi@fedoraproject.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=remi@fedoraproject.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fedoraproject.org from 217.70.183.194 cause and error) X-PHP-List-Original-Sender: remi@fedoraproject.org X-Host-Fingerprint: 217.70.183.194 relay2-d.mail.gandi.net Received: from [217.70.183.194] ([217.70.183.194:51261] helo=mrelay2-d.mail.gandi.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/D0-52139-D9B70B55 for ; Thu, 23 Jul 2015 01:29:02 -0400 Received: from mfilter23-d.gandi.net (mfilter23-d.gandi.net [217.70.178.151]) by mrelay2-d.mail.gandi.net (Postfix) with ESMTP id 13512C5A3C for ; Thu, 23 Jul 2015 07:28:59 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter23-d.gandi.net Received: from mrelay2-d.mail.gandi.net ([217.70.183.194]) by mfilter23-d.gandi.net (mfilter23-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id Ulb+uXRHp3fP for ; Thu, 23 Jul 2015 07:28:57 +0200 (CEST) X-Originating-IP: 82.241.130.121 Received: from schrodingerscat.famillecollet.com (pom51-2-82-241-130-121.fbx.proxad.net [82.241.130.121]) (Authenticated sender: contact@ll-experts.com) by mrelay2-d.mail.gandi.net (Postfix) with ESMTPSA id 8880AC5A44 for ; Thu, 23 Jul 2015 07:28:57 +0200 (CEST) To: PHP Internals References: <55AF84C1.8070403@fedoraproject.org> Message-ID: <55B07B98.1050909@fedoraproject.org> Date: Thu, 23 Jul 2015 07:28:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFE to allow dirname($foo, 2) From: remi@fedoraproject.org (Remi Collet) Le 22/07/2015 20:57, Marco Pivetta a =C3=A9crit : > On 22 July 2015 at 19:49, Sara Golemon > wrote: >=20 > On Wed, Jul 22, 2015 at 4:55 AM, Remi Collet > > wrote: >> See https://bugs.php.net/bug.php?id=3D70112 >>=20 > I'm not inherently against it, but this really really sounds like > a job for a userspace function. >=20 > function dirname_n($path, $n) { while (($path !=3D=3D '.') && $n--) > $path =3D dirname($path); return $path;=20 > } >=20 >=20 > 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. See https://github.com/search?q=3Ddirname+__DIR__+language%3Aphp&ref=3Dsearch= results&type=3DCode&utf8=3D%E2%9C%93 As github search doesn't allow to search for (, I use __dir__ which probably hides more usage. As "n" is usually 2 or 3, nobody will write a userland function. Remi > Greets, >=20 > Marco Pivetta >=20 > http://twitter.com/Ocramius >=20 > http://ocramius.github.com/ >=20