-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
See https://bugs.php.net/bug.php?id=70112
As this a very small self-contained change,
I don't think it needs a RFE.
Feedback welcome
Remi.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEARECAAYFAlWvhMEACgkQYUppBSnxahh+HACg18VjI/eZpBXAfXrHD+KOjCpb
IAgAoN33DaqH0j4kTe1FTceeL3T3OweQ
=yaJf
-----END PGP SIGNATURE
Hi,
De: "Remi Collet" remi@fedoraproject.org
See https://bugs.php.net/bug.php?id=70112
As this a very small self-contained change, I don't think it needs a RFE.
+1 for the feature, but not sure it can go to 7.0.
Regards
François
Hi,
De: "Remi Collet" remi@fedoraproject.org
See https://bugs.php.net/bug.php?id=70112
As this a very small self-contained change, I don't think it needs a RFE.
+1 for the feature, but not sure it can go to 7.0.
Regards
François
--
+1 from me
+1 from me on adding it to PHP 7.0.0 as well. And not just to be
contrary, I'd like it to be another selling point for upgrading
swiftly. :)
Though my second vote probably won't count for anything.
Scott Arciszewski
Chief Development Officer
Paragon Initiative Enterprises <https://paragonie.com
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;
}
-Sara
On Wed, Jul 22, 2015 at 4:55 AM, Remi Collet remi@fedoraproject.org
wrote: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?
Greets,
Marco Pivetta
Le 22/07/2015 20:57, Marco Pivetta a écrit :
On 22 July 2015 at 19:49, Sara Golemon <pollita@php.net
mailto:pollita@php.net> wrote:On Wed, Jul 22, 2015 at 4:55 AM, Remi Collet
<remi@fedoraproject.org mailto:remi@fedoraproject.org> wrote: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.phpIndeed. 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=searchresults&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.
Remi
Greets,
Marco Pivetta
Hi,
-----Original Message-----
From: Remi Collet [mailto:remi@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 <pollita@php.net
mailto:pollita@php.net> wrote:On Wed, Jul 22, 2015 at 4:55 AM, Remi Collet <remi@fedoraproject.org
mailto:remi@fedoraproject.org> wrote: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.phpIndeed. 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%93As 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
Great suggestion, Remi, I'd love to see this change!
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;
}-Sara
Let's assume that we implement this function in userland, either in a Composer
package or more likely in a functions.php file in our project, which Composer or
our project's bootstrap includes for us.
Now, most often, dirname(... dirname(DIR) ...) is used in application entry
points during the bootstrapping process. In my experience, it's most commonly
used in order to include an autoloader or some bootstrap file which itself is
responsible for including the autoloader.
In other words, dirname(...) is generally used before we have access to our
includes and classes (no autoloader). Which means, if we were to simply
implement this in userland, we'd have to either write require
dirname(...) in order
to load the dirname_n function every time we need to use it, which would
obviously defeat the object, or conditionally declare the function everywhere
it's needed, which wouldn't be ideal.
Is there some more elegant way this could work in userland which I've missed?
Hi,
Am 23.07.2015 um 11:54 schrieb Josh Di Fabio:
Now, most often, dirname(... dirname(DIR) ...) is used in application entry
points during the bootstrapping process. In my experience, it's most commonly
used in order to include an autoloader or some bootstrap file which itself is
responsible for including the autoloader.
doesn't work DIR.'/../../' on Windows also? Why do you need
dirname()
here?
Greets
Dennis
Hi,
Am 23.07.2015 um 11:54 schrieb Josh Di Fabio:
Now, most often, dirname(... dirname(DIR) ...) is used in application entry
points during the bootstrapping process. In my experience, it's most commonly
used in order to include an autoloader or some bootstrap file which itself is
responsible for including the autoloader.doesn't work DIR.'/../../' on Windows also? Why do you need
dirname()
here?Greets
Dennis--
What's easier to read and less likely to result in bugs?
require_once DIR . '/../../../../autoload.php';
or
require_once dirname(FILE, 5) . '/autoload.php';
Scott Arciszewski
Chief Development Officer
Paragon Initiative Enterprises <https://paragonie.com
Hi,
Am 25.07.2015 um 19:42 schrieb Scott Arciszewski:
Hi,
Am 23.07.2015 um 11:54 schrieb Josh Di Fabio:
Now, most often, dirname(... dirname(DIR) ...) is used in application entry
points during the bootstrapping process. In my experience, it's most commonly
used in order to include an autoloader or some bootstrap file which itself is
responsible for including the autoloader.doesn't work DIR.'/../../' on Windows also? Why do you need
dirname()
here?What's easier to read and less likely to result in bugs?
require_once DIR . '/../../../../autoload.php';
or
require_once dirname(FILE, 5) . '/autoload.php';
I am not going to discuss personal preferences, but for me the first is.
You require to go four Levels up and include something, that should just
not be necessary with proper autoloading.
Greets,
Dennis
Hi Scott!
2015-07-25 19:42 GMT+02:00 Scott Arciszewski scott@paragonie.com:
What's easier to read and less likely to result in bugs?
require_once DIR . '/../../../../autoload.php';
or
require_once dirname(FILE, 5) . '/autoload.php';
That's on everyone's own, but for me it's the first. However, it
couldn't be a disaster having ability to choose other option for
those, who are not familiar with relative paths. :-)
Best regards,
Kubo2, Jakub Kubíček
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1See https://bugs.php.net/bug.php?id=70112
As this a very small self-contained change,
I don't think it needs a RFE.Feedback welcome
Shouldn't you check if you are at the root (or cwd)?
currently dirname("/foo/bar", PHP_INT_MAX); "hangs"
-Hannes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le 24/07/2015 02:11, Hannes Magnusson a écrit :
On Wed, Jul 22, 2015 at 4:55 AM, Remi Collet
remi@fedoraproject.org wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
See https://bugs.php.net/bug.php?id=70112
As this a very small self-contained change, I don't think it
needs a RFE.Feedback welcome
Shouldn't you check if you are at the root (or cwd)? currently
dirname("/foo/bar", PHP_INT_MAX); "hangs"
Good catch.
Should be ok now.
Remi.
-Hannes
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEARECAAYFAlWx+dMACgkQYUppBSnxahjuPACgxZ+yLXbLzQXZKmJhWAbH0OD9
jqAAnjImkjL6j+p4dsRC0IC8N6fRKFXc
=4YM4
-----END PGP SIGNATURE