Commit graph

170 commits

Author SHA1 Message Date
Máté Kocsis
3197104e85
Fix GH-10292 1st param of mt_srand() has UNKNOWN default on PHP <8.3
Closes GH-10429
2023-01-24 19:05:33 +01:00
Christoph M. Becker
ccd7d410f1
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  $context parameter of get_headers() is nullable
2021-12-23 11:49:33 +01:00
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
220f0f55cf
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix the return type of imagecolorexactalpha()
  String default values are enclosed in quotes rather than apostrophes
2021-10-12 09:53:30 +02:00
Máté Kocsis
2127b49c65
String default values are enclosed in quotes rather than apostrophes 2021-10-12 09:51:20 +02:00
Craig Francis
2b25ac6f3c Update stub to show default of ENT_HTML401 (for documentation)
Closes GH-7514.
2021-09-29 12:14:29 +02:00
Máté Kocsis
c19e4b9997
Generate optimizer func info from stubs for ext/standard - part 3 (#7426) 2021-08-30 15:56:47 +02:00
Nikita Popov
0f7e0cf34b str_replace() can return the original string 2021-08-30 10:23:09 +02:00
Máté Kocsis
b49d340f74
Generate optimizer func info from stubs for ext/standard - part 2 (#7414) 2021-08-27 16:54:04 +02:00
Máté Kocsis
1ce81b6bcd
Generate optimizer func info from stubs for ext/standard - part 1 (#7413) 2021-08-27 13:11:57 +02:00
Máté Kocsis
b1822899fc
Add support for generating optimizer function info from stubs (#7367) 2021-08-24 16:35:33 +02:00
Máté Kocsis
b4b980e6ad
Merge branch 'PHP-8.0'
* PHP-8.0:
  Declare a few missing function return types
2021-08-24 11:43:31 +02:00
Máté Kocsis
c58a9f2a57
Declare a few missing function return types
Closes GH-7395
2021-08-24 11:38:50 +02:00
Nikita Popov
bed7139375 Deprecate strptime()
Use date_parse_from_format() or IntlDateFormatter::parse() instead.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-09 10:03:45 +02:00
Joe Watkins
ec9ce49c8e
Merge branch 'PHP-8.0'
* PHP-8.0:
  fix bad refactor of #7136
2021-06-11 09:34:03 +02:00
Joe Watkins
b10bcb4faa
fix bad refactor of #7136 2021-06-11 09:33:55 +02:00
Joe Watkins
9068b27974
Merge branch 'PHP-8.0'
* PHP-8.0:
  Enable net_get_interfaces on IBM i PASE
2021-06-11 09:14:17 +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
Máté Kocsis
b4b848bfa7
Fix the signature of ini_alter()
It should be the same as ini_set()
2021-05-26 12:32:38 +02:00
Nikita Popov
e8ef923dd6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove assert_options() return value info
2021-04-28 11:06:54 +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
Niklas Keller
59d5b3dd51
Accept null for microseconds argument in stream_select() (#6879)
The deprecation of passing null is thrown otherwise.

If the timeout is calculated conditionally before calling stream_select(), passing to avoid the deprecation seems unreasonable, example:

7d4bbc6e0b/lib/Loop/NativeDriver.php (L286)

Also enforce that if $seconds is null, then $microseconds should be null as well. However 0 is still accepted (with deprecation) for backwards compatibility.
2021-04-22 10:09:55 +02:00
David Gebler
cbcfd86026 Add fsync() and fdatasync() functions
fsync is a straightforward wrapper around the same C function
(implemented on Windows API as _commit() with identical signature).

From the man pages:

    fsync() transfers ("flushes") all modified in-core data of (i.e.,
    modified buffer cache pages for) the file referred to by the file
    descriptor fd to the disk device (or other permanent storage
    device) so that all changed information can be retrieved even if
    the system crashes or is rebooted.  This includes writing through
    or flushing a disk cache if present.  The call blocks until the
    device reports that the transfer has completed.

RFC: https://wiki.php.net/rfc/fsync_function

Closes GH-6650.
2021-04-13 16:09:22 +02:00
Nikita Popov
dae23ab723 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove the "getdir" function which was introduced accidentally
2021-04-12 11:14:28 +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
Cameron Hall
5b29eba7ca Fix #42357: fputcsv() has an optional parameter for line endings
fputcsv does not terminate lines correctly as per RFC 41801[1]. After adding a new parameter fputcsv may now use a user defined line ending,. In order to maintain backwards compatibility fputcsv() still terminates lines with "\n" by default.

Also fixes: #46367[2], #62770[3]
Ref: #42357[4]

[1] <https://tools.ietf.org/html/rfc4180>
[2] <https://bugs.php.net/bug.php?id=46367>
[3] <https://bugs.php.net/bug.php?id=62770>
[4] <https://bugs.php.net/bug.php?id=42357>
2021-03-29 13:34:38 +01:00
Máté Kocsis
4c6533c257
Generate class entries from stubs for com, standard, xmlreader, xmlwriter, xsl, zip, Zend
Closes GH-6706
2021-02-22 15:24:03 +01:00
Nikita Popov
070e24d7a9 Allow all scalar types in ini_set()
This changes ini_set() to accept all scalar types
(string|int|float|bool|null) for the new value. The idea here is
that while the INI system ultimately works with strings, its value
interpretation is designed to be consistent with PHP's casting rules,
e.g. "1" and "" are interpreted as boolean true and false respectively.

I personally believe that writing ini_set('precision', 10) makes more
sense than ini_set('precision', '10'), and find strict_types to be
unnecessarily pedantic here.

Closes GH-6680.
2021-02-11 15:01:16 +01:00
Nikita Popov
bfbac70ec5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't return null from password_get_info()
2021-02-11 10:23:09 +01: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
Dusk
13c430b1db Add array_is_list(array $array) function
This function tests if an array contains only sequential integer keys. While
list isn't an official type, this usage is consistent with the community usage
of "list" as an annotation type, cf.
https://psalm.dev/docs/annotating_code/type_syntax/array_types/#lists

Rebased and modified version of #4886

- Use .stub.php files
- Add opcache constant evaluation when argument is a constant
- Change from is_list(mixed $value) to array_is_list(array $array)

RFC: https://wiki.php.net/rfc/is_list

Co-Authored-By: Tyson Andre <tysonandre775@hotmail.com>
Co-Authored-By: Dusk <dusk@woofle.net>

Closes GH-6070
2021-01-20 18:53:48 -05:00
Craig Francis
50eca61f68 Use ENT_QUOTES|ENT_SUBSTITUTE default for HTML encoding and decoding functions
htmlspecialchars() etc now use ENT_QUOTES | ENT_SUBSTITUTE rather
than ENT_COMPAT by default.

Closes GH-6583.
2021-01-18 15:45:28 +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