-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Update ext/standard parameter names #6214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b517044
to
f9d386d
Compare
I've done a first pass through everything ... |
*/ | ||
function dns_get_record(string $hostname, int $type = DNS_ANY, &$authns = null, &$addtl = null, bool $raw = false): array|false {} | ||
function dns_get_record(string $hostname, int $type = DNS_ANY, &$authoritative_name_servers = null, &$additional_records = null, bool $raw = false): array|false {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These names are excessively long, but I'm not familiar enough with this API to suggest a good concise name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other ideas:
array_push()
: I think we could use$array
instead of$stack
(update: I now see that you did this change in a few places)array_walk*()
:$array
instead of$input
,$args
instead of$argument
array_filter()
:$flags
instead of$use_keys
move_uploaded_file()
: maybe "from" and "to" could be used (either also includingpath
or not:$from
/$from_path
), but I like the source - destination terms tooheaders_sent()
:$filename
|
||
function strtr(string $str, string|array $from, ?string $to = null): string {} | ||
function strtr(string $string, string|array $from, ?string $to = null): string {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly unrelated: I saw that the manual has a very detailed description about the two versions of strtr()
(https://www.php.net/manual/en/function.strtr.php), and this is the first time when I realized that the default value fix for PHP 8.0 has a side-effect that we can't have an entirely accurate name for the 2nd parameter :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to discuss, but I think what we should do with these overloaded signatures is to keep listing them as multiple signatures in the manual and define a policy that overloaded functions are excluded from our parameter name stability policy -- and that we reserve the right to make invoking them with named params a hard error in the future (once we have "positional only" arguments). We just can't support these kinds of signatures properly.
|
||
/** @param int $replace_count */ | ||
function str_replace(array|string $search, array|string $replace, string|array $subject, &$replace_count = null): string|array {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bob had a very good suggestion IMO to rename these to $from
, $to
, $subject
. Sometimes I'm also wondering if $search
is what we search for or where we search, so I'd also prefer these names. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strtr() uses $from, $to terminology, so there's some precedent there...
Something we also need to consider is how this will interact with pcre APIs. Here we have $search, $replace, $subject
. In preg_replace, we have $pattern, $replace, $subject
. In preg_replace_callback, we have $pattern, $callback, $subject
.
|
||
function hebrev(string $str, int $max_chars_per_line = 0): string {} | ||
function hebrev(string $string, int $max_chars_per_line = 0): string {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: in other places character
is not abbreviated. I'm ok with $max_chars_per_line
though, it already has very long a name.
f9d386d
to
7a2543e
Compare
Done! This was indeed just an oversight.
I've renamed
Hm... it looks like the values here don't form a bitmaks. I've changed it to
I'm not sure on this one. We seem to be using "old"/"new" for renaming operations (see also
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh gosh, I finally reached the bottom of the stub file. :D (although, this time I only vaguely checked the non-changed parts).
closedir
: should$dir_handle
become a$stream
?password_needs_rehash
:$hash
to$password
?
the plural was just a typo ^^ |
Yes, absolutely!
I'm on board :) |
Not sure on this one: You are right that closedir() accepts a stream resource, but it's a special kind (PHP_STREAM_FLAG_IS_DIR) created by opendir(). Passing something like fopen() to it will throw. Is it worthwhile to distinguish this?
This function accepts a hash from password_hash(), not a plain password. |
7a2543e
to
ae2e0ed
Compare
Yes, you're right then, I wasn't really aware of the distinction. Will
Ah, yes, I didn't realize at first that it's for distinguishing hashed password from plain password. This is something I also support very much, so +1! |
Go back to what the manual calls is ... it seems clearest.
8579efd
to
212de89
Compare
Hard to say. Depends on how the conversion is done. If we use the same underlying implementation, directories might also be an instance of I think |
@nikic The PR seems good for me now! :) Somewhere you asked a question about the |
@kocsismate Yeah, I think these are the open questions that are left:
We'll have to do some fine tuning later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm leaving two more small ideas here:
parse_url
: first param could be$uri
because it accepts URIs. It doesn't match with the function name though, so this change is not a must-have. P.S. ext/ldap is about to use$uri
.is_callable()
:$callable_name
could be$name
or$callback_name
I think.
Another thing we'll have to check is that manual references to |
Just putting this up to avoid duplicate work ... will take a while to go through all of it.