1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Commit Graph

113 Commits

Author SHA1 Message Date
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
Tyson Andre
1e9a5c67ef Rename standard array function parameters to $array
This is targeting 8.0.

`$arg` seems like a poor choice of a name,
especially if the function were to have arguments added.

In many cases, the php.net documentation already has $array for these functions.
E.g. https://www.php.net/manual/en/function.array-intersect.php

I'd assume that since named arguments was added to 8.0 near the feature freeze,
PHP's maintainers had planned to make the names consistent
and gradually use the same name for  docs and implementation.
2020-08-11 19:11:59 -04:00
Máté Kocsis
af80d8a14e Add more argument types to stubs
Closes GH-5943
2020-08-07 12:35:30 +02:00
Máté Kocsis
0d330e1a02 Add a few missing parameter types in stubs
Related to GH-5627
2020-07-30 14:26:45 +02:00
Derick Rethans
cdc8523300 Last pass of 'More consistent parameter names for date/time functions' 2020-07-27 11:42:13 +01:00
Nikita Popov
be9c5daf28 Remove null from highlight_* return types
Also fix show_source() discrepancy in func_info.
2020-07-21 10:40:08 +02:00
Nikita Popov
9d37a57411 Remove bool return type from assert_options
Not seeing any way this function can return bool.
2020-07-21 10:18:33 +02:00
Nikita Popov
895a22c03c Add missing image_type_to_extension() argument 2020-07-17 15:24:41 +02:00
Christoph M. Becker
ae7554270f Fix #79805: sapi_windows_vt100_support throws TypeError
It does not make sense to throw a `TypeError` when the stream can't be
analyzed.  If `sapi_windows_vt100_support()` is used as getter, we just
return `false` in that case; if the function is used as setter, we
additionally trigger a warning.

We also fix the test cases for this function, which have been broken
before.  Note that these tests are still whitespace sensitive.
2020-07-16 18:36:02 +02:00
George Peter Banyard
c4a0ba8d6e Refactor levenshtein()
Closes GH-5816
2020-07-07 00:41:10 +02:00
Christoph M. Becker
fecea7b89c Fix sapi_windows_vt100_support() arginfo 2020-07-06 10:48:10 +02:00
Máté Kocsis
aa9b0ccda8 Add tests to check mismatching function signatures
Closes GH-5666
2020-06-06 09:23:34 +02:00
Nikita Popov
6b45039fb7 Add some mixed types 2020-06-02 10:16:13 +02:00
Máté Kocsis
b3718430de Annotate internal functions with the mixed type
Closes GH-5618
2020-05-25 17:30:57 +02:00
Máté Kocsis
cbf86efc21 Fix ZPP of v*printf() 2020-05-25 17:29:46 +02:00
Nikita Popov
50a9f511cc Allow null callback to array_filter()
With same behavior as not passing it.
2020-05-13 17:24:13 +02:00
William Hudgins
31fb6a08b3 Add str_starts_with() and str_ends_with()
RFC: https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions

Closes GH-5300.
2020-05-05 16:03:47 +02:00
George Peter Banyard
8d346f7679 Use ZPP int|string and add ValueError for Windows codepages
Closes GH-5517
2020-05-04 12:44:54 +02:00
George Peter Banyard
34f727e637 Use ZPP check for string|int|null arguments in array_column() 2020-05-02 19:50:51 +02:00
Máté Kocsis
31a626cf7e Remove the deprecated is_real() function
Closes GH-5506
2020-05-01 15:33:58 +02:00
Your Name
ef0e4478c5 Add get_debug_type() function
RFC: https://wiki.php.net/rfc/get_debug_type
2020-04-23 10:45:08 +02:00
Máté Kocsis
beff93f60d Fix the default parameter values of stream_socket_client()
$timeout and $flags were mixed up
2020-04-10 17:17:12 +02:00
Nikita Popov
fcc6da3e42 Mark $time argument of touch() as UNKNOWN as well
For some reason I thought that passing 0 is same as current time,
but that's not the case.
2020-04-09 16:54:42 +02:00
Nikita Popov
636c827aa2 Mark fgets() argument as UNKNOWN
If no value is passed, this reads as much as necessary, not 1024
bytes.
2020-04-09 16:22:34 +02:00
Christoph M. Becker
62e8dcbc48 Change parameter default to always available value
`SIGTERM` is only defined in ext/pcntl, and as such never available on
Windows.  Moving the constant to ext/standard does not make much sense,
because that parameter is actually unused on Windows.  Therefore, we
use the magic number `15` instead, what is also done in the PHP manual.
2020-04-09 16:15:47 +02:00
Nikita Popov
87ba975e31 Make touch() $atime parameter UNKNOWN
The actual default here is $time, not 0.
2020-04-09 16:11:17 +02:00
Nikita Popov
258c4dfdb2 Mark rand/mt_rand args as UNKNOWN
The second argument should be mt_getrandmax(), not PHP_INT_MAX.
Additionally this function only accepts either zero or two arguments,
so err on the side of being conservative and mark both UNKNOWN.
2020-04-09 16:10:56 +02:00
Nikita Popov
1dcb559664 Mark array_walk $userdata arg as UNKNOWN
It makes a difference whether this arg is not passed or is null.
2020-04-09 16:10:39 +02:00
Nikita Popov
b3f3a80f9c Make stream_socket_enable_crypto() session stream nullable 2020-04-09 16:10:33 +02:00
Nikita Popov
217dfc0832 Accept null context in stream_socket_(client|server) 2020-04-09 16:10:27 +02:00
Nikita Popov
2bcc4ab8f4 Verify that all stubs have a return type 2020-04-03 17:59:30 +02:00
Nikita Popov
51bc6233b2 Generate function entries from stubs
If @generate-function-entries is specified in the stub file,
also generate function entries for the extension.

Currently limited to free functions only.
2020-04-03 15:41:41 +02:00
Máté Kocsis
305b17e85f Do not include the same stub multiple times
Closes GH-5322
2020-04-03 14:23:54 +02:00
Nikita Popov
97cb81ead5 Remove HAVE_REALPATH checks
We do not actually use realpath(), but a custom implementation.
Make sure the realpath() function is always available.

Closes GH-5290.
2020-03-26 11:46:00 +01:00