Commit graph

146 commits

Author SHA1 Message Date
Christoph M. Becker
c5f4ee50ab
$context parameter of get_headers() is nullable
Closes GH-7813.
2021-12-23 11:47:20 +01:00
Máté Kocsis
2127b49c65
String default values are enclosed in quotes rather than apostrophes 2021-10-12 09:51:20 +02:00
Máté Kocsis
c58a9f2a57
Declare a few missing function return types
Closes GH-7395
2021-08-24 11:38:50 +02:00
Joe Watkins
b10bcb4faa
fix bad refactor of #7136 2021-06-11 09:33:55 +02:00
Calvin Buckley
4f51a11a84
Enable net_get_interfaces on IBM i PASE
On IBM i, getifaddrs is available renamed as Qp2getifaddrs; freeifaddrs
and struct ifaddr follow a similar fate. I assume this is in case AIX
decides to add it (as if). As such, just use the same implementation,
but rename the standard ones to the IBM i definitions and include its
header.
2021-06-11 09:12:49 +02:00
Nikita Popov
76d1120a48 Remove assert_options() return value info
The ASSERT_CALLBACK value is not validated at all -- it's possible
to set it to an arbitrary value. As such, the function can also
return any value or type (even without outright abuse, the opcache
func info was wrong in that the return can be rcn, and the array
can be array_of_ref).
2021-04-28 11:05:05 +02:00
Rowan Tommins
4e98e65d53 Remove the "getdir" function which was introduced accidentally
The actual name of this function is dir(), but ever since it was
introduced in PHP 3, its internal name was "getdir", leading to it
being mistaken for an alias. This went unnoticed until the switch
to stubs for generating arginfo, at which point getdir() became a
real but undocumented function.

Fixes bug #80914.

Closes GH-6855.
2021-04-12 11:13:57 +02:00
Nikita Popov
cec5e30889 Don't return null from password_get_info()
The get_info() handler should never fail, but even if it does,
we should still return a proper info array -- it doesn't make
sense that a completely incorrect hash returns an info array,
but a hash that is recognized but for which the options can't
be extracted would return null.
2021-02-11 10:21:31 +01:00
Christoph M. Becker
cae0bcbab5 Fix parameter name
Levenshtein is about insertion, replacement and deletion.

Closes GH-6560.
2021-01-01 23:04:28 +01:00
Nikita Popov
73321bc300 getlastmod() can return false
At least this can happen during preloading.
2020-11-04 15:53:08 +01:00
Máté Kocsis
76e4bf3068
Parameter type and name fixes in ext/standard
Closes GH-6382
2020-10-27 11:27:25 +01:00
Máté Kocsis
f076ab0c0c
Fix #80229: assert_options should have int and bool for parameter PHPDoc
Closes GH-6348
2020-10-17 12:01:07 +02:00
Nikita Popov
68195bd481 Update ext/spl parameter names
Closes GH-6284.
2020-10-07 12:26:46 +02:00
Nikita Popov
79484b4f8a Update ext/sockets parameter names
Also change $max_length to $length in a number of filesystem APIs,
where our usage was inconsistent.

Closes GH-6276.
2020-10-06 12:12:43 +02:00
Nikita Popov
d9dce839f7 Update ext/posix parameter names
Closes GH-6275.
2020-10-06 09:49:40 +02:00
Máté Kocsis
e9c707298b
Review parameter names in ext/zlib
Closes GH-6250
2020-10-05 15:20:27 +02:00
Nikita Popov
25f1c405ff Update ext/standard parameter names
Closes GH-6214.
2020-09-29 16:49:46 +02:00
Nikita Popov
cafceea742 Update mbstring parameter names
Closes GH-6207.
2020-09-28 09:51:58 +02:00
Nikita Popov
8067cf4752 Use callable type in register_shutdown_function()
To make things a bit less weird, split off the function name into
a zval stored separately from the arguments. This allows us to
use normal zpp and get standard behavior.
2020-09-25 14:48:33 +02:00
Nikita Popov
43ce18f837 Add proper count() parameter type
We can make this Countable|array now.
2020-09-25 12:31:05 +02:00
Nikita Popov
13b791c79c Normalize substr() behavior
Make the behavior of substr(), mb_substr(), iconv_substr() and
grapheme_substr() consistent when it comes to the handling of
out of bounds offsets. substr() will now always clamp out of
bounds offsets to the string boundary. Cases that previously
returned false will now return an empty string. This means that
substr() itself *always* returns a string now (like mb_substr()
already did before.)

Closes GH-6182.
2020-09-25 09:58:21 +02:00
Nikita Popov
de77344de2 Promote pack/unpack format errors
Errors related to invalid format strings (unlike data mismatch
errors) should throw ValueError.

Closes GH-6185.
2020-09-22 15:12:05 +02:00
Nikita Popov
fdd9018bdf Support uuencoding empty string
Cross checking implementations from other languages, empty strings
are always allowed. PHP's output is peculiar due to it's insistence
to encode a trailing \0, but otherwise sensible and does round-trip
as expected.
2020-09-22 12:39:39 +02:00
Nikita Popov
e60f927f05 stream_bucket_new() cannot return false
php_stream_bucket_new() is infallible.
2020-09-22 12:07:53 +02:00
Nikita Popov
9ef2c5c303 stream_get_transports/wrappers cannot return false
These may return an empty array, but not false.
2020-09-22 12:02:39 +02:00
Nikita Popov
aba0ee71b2 Don't return false for empty string in soundex()
Return "0000" instead of false to have a consistent return type.
"0000" is already a possible return value if the string doesn't
contain any letters, such as with soundex(" "). We can treat the
case of soundex("") exactly the same.
2020-09-22 11:44:35 +02:00
Nikita Popov
e547ea43c1 http_build_query() cannot fail
Assert that ht is not null and make php_url_encode_hash_ex() return
void to clarify that this is an infallible function.
2020-09-22 11:30:02 +02:00
Nikita Popov
0fbebfd1ae html_entity_decode() cannot fail
php_unescape_html_entities() never returns null, so this function
can never return false.

php_unescape_html_entities() probably should be failing with OOM
for the "overflow" case, but even if it did, it would not be
signalled through a false return value.
2020-09-22 11:23:01 +02:00
Nikita Popov
84be22f1f5 Validate phonemes parameter of metaphone()
And thus avoid the false return value.
2020-09-22 11:19:02 +02:00
Nikita Popov
d0fb2f409e substr_compare() cannot return false 2020-09-22 10:54:44 +02:00
Nikita Popov
5d9ab53a5d Check string bounds in strspn/strcspn
strspn/strcspn are string search functions, and as such should throw
ValueError on out-of-bounds offsets, just like strpos etc do.
2020-09-22 10:46:50 +02:00
Nikita Popov
ade57e691b substr_replace() cannot return false 2020-09-22 09:59:35 +02:00
Máté Kocsis
64af12d13b
Add support for @implementation-alias in stubs
Closes GH-6170
2020-09-21 10:08:45 +02:00
Máté Kocsis
46d22e435f
Change int parameter types to bool when the parameter behaves as bool
Closes GH-6148
2020-09-17 09:38:18 +02:00
Máté Kocsis
de912821e0
Display string default values in stubs more uniformly
Settling on using quoted string
2020-09-16 21:27:01 +02:00
Máté Kocsis
c76910cd96
Display types in stubs more uniformly
In preparation for generating method signatures for the manual.

This change gets rid of bogus false|null return types, a few unnecessary trailing backslashes, and settles on using ? when possible for nullable types.
2020-09-16 21:19:36 +02:00
Máté Kocsis
c37a1cd650
Promote a few remaining errors in ext/standard
Closes GH-6110
2020-09-15 14:26:16 +02:00
Larry Garfield
96f2f3174b Update array parameter names for named parameters
* The array "subject" of a function gets called $array.

* Further parameters should be self-descriptive if used
  as a named parameter, and a full word, not an abbreviation.

* If there is a "bunch more arrays" variadic, it gets
  called $arrays (because that's what was already there).

* A few functions have a variadic "a bunch more arrays,
  and then a callable", and were already called $rest.
  I left those as is and died a little inside.

* Any callable provided to an array function that acts
  on the array is called $callback. (Nearly all were already,
  I just fixed the one or two outliers.)

* array_multisort() is beyond help so I ran screaming.
2020-09-14 14:56:49 +00:00
Máté Kocsis
46c0c82a0f
Declare array|int and object-of-class|int types in stubs
Closes GH-6081

Co-Authored-By: Nikita Popov <nikic@php.net>
2020-09-14 11:59:32 +02:00
Máté Kocsis
eb86d08128
Fix a few stub parameter types in ext/standard 2020-09-14 11:46:14 +02:00
Nikita Popov
d37d222835 Make array_multisort() signature more variadic
The second and third arguments are not always the sort_order and
sort_flags -- they can also be in reverse order, or be arrays
altogether. Move them into the variadic parameter to avoid awkward
error messages.
2020-09-09 11:36:38 +02:00
Nikita Popov
73ab7b30ca Allow array_diff() and array_intersect() with single array argument
Both of these functions are well-defined when used with a single
array argument -- rejecting this case was an artificial limitation.
This is not useful when called with explicit arguments, but removes
edge-cases when used with argument unpacking:

    // OK even if $excludes is empty.
    array_diff($array, ...$excludes);

    // OK even if $arrays contains a single array only.
    array_intersect(...$arrays);

This matches the behavior of functions like array_merge() and
array_push(), which also allow calls with no array or a single
array respectively.

Closes GH-6097.
2020-09-09 11:03:17 +02:00
Máté Kocsis
9975986b7e
Improve error messages mentioning parameters instead of arguments
Closes GH-5999
2020-09-09 10:47:43 +02:00
Máté Kocsis
2c96780e1c
Fix UNKNOWN default values in ext/standard
Closes GH-6026
2020-09-07 18:58:11 +02:00
Nikita Popov
032f862133 Drop support for crypt() without explicit salt
crypt() without salt generates a weak $1$ MD5 hash. It has been
throwing a notice since 2013 and we provide a much better alternative
in password_hash() (which can auto-generate salts for strong
password hashes), so keeping this is just a liability.
2020-09-07 15:43:26 +02:00
Máté Kocsis
8107a1da5a
Use ZPP instead of custom type checks
We can add these types as a native type declaration to stubs as a side-effect. Closes GH-6068
2020-09-04 14:32:34 +02:00
Tyson Andre
9883fec99f Fix more basic function stubs
User-defined functions can't have multiple parameters with the same name.
Don't do that for var_dump/debug_zval_dump.

Consistently use array $array to match docs

Fix typo in UPGRADING

Fixes GH-6015
2020-08-18 20:23:42 -04:00
George Peter Banyard
dae83cd7cb Use ZPP callable check for Windows specific functions 2020-08-13 21:14:50 +02:00
Máté Kocsis
cb2f689778
Fix param name in PHPDoc 2020-08-13 14:54:48 +02:00
Máté Kocsis
2803c8fb8d
Add all the missing parameter types to stubs
Closes GH-5955
2020-08-13 14:47:18 +02:00