Hi, > -----Original Message----- > From: Remi Collet [mailto:r...@fedoraproject.org] > Sent: Thursday, July 23, 2015 7:29 AM > To: PHP Internals <internals@lists.php.net> > Subject: Re: [PHP-DEV] RFE to allow dirname($foo, 2) > > Le 22/07/2015 20:57, Marco Pivetta a écrit : > > On 22 July 2015 at 19:49, Sara Golemon <poll...@php.net > > <mailto:poll...@php.net>> wrote: > > > > On Wed, Jul 22, 2015 at 4:55 AM, Remi Collet <r...@fedoraproject.org > > <mailto:r...@fedoraproject.org>> wrote: > >> See https://bugs.php.net/bug.php?id=70112 > >> > > 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 !== '.') && $n--) $path > > = dirname($path); return $path; }<http://www.php.net/unsub.php> > > > > > > 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? > > > > Legibility and the frequency of the usage of dirname(dirname(... > in various pieces of code. > > See > https://github.com/search?q=dirname+__DIR__+language%3Aphp&ref=searchr > esults&type=Code&utf8=%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. > 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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php