Commit graph

13299 commits

Author SHA1 Message Date
Nikita Popov
6a8c094e2d Remove string length limit from levenshtein()
As noted on https://bugs.php.net/bug.php?id=80073, I don't think
having this limitation makes sense. The similar_text() function
has much worse asymptotic complexity than levenshtein() and does
not enforce such a limitation. levenshtein() does have fairly high
memory requirements, but they are a fixed factor of the string
length (and subject to memory limit).
2020-10-09 16:12:08 +02:00
Petr Sumbera
240d06118c Add support for Solaris 11.4 openpty implementation.
Closes GH-6287.
2020-10-09 16:10:03 +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
d3cf597328 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix -Wimplicit-function-declaration in configure
2020-10-05 10:48:04 +02:00
Nikita Popov
9ad5381a2f Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix -Wimplicit-function-declaration in configure
2020-10-05 10:46:46 +02:00
Nikita Popov
aa405b7da2 Fix -Wimplicit-function-declaration in configure
As this is an error with xcode 12, see bug #80171.
2020-10-05 10:43:58 +02:00
Christoph M. Becker
54435c9b43 Fix #64060: lstat_stat_variation7.phpt fails on certain file systems
Closes GH-6194.
2020-10-02 18:54:10 +02:00
Máté Kocsis
6b00196e04
Review parameter names in ext/pcre
Closes GH-6259
2020-10-02 11:55:23 +02:00
Nikita Popov
25f1c405ff Update ext/standard parameter names
Closes GH-6214.
2020-09-29 16:49:46 +02:00
Nikita Popov
59aa21c735 Don't accept dir handle in Directory methods
This is an artifact of the shared implementation with readdir() etc.
The method versions should not accept an explicit dir handle, as
they work on the dir handle from the object.
2020-09-29 14:50:40 +02:00
Nikita Popov
de2d38d531 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #80137
  Fix bug #80138
2020-09-29 10:59:46 +02:00
Nikita Popov
1fafcd2b28 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix bug #80137
  Fix bug #80138
2020-09-29 10:59:32 +02:00
Matthias Karbe
f5afd0a827 Fix bug #80137
Skip getprotobyname() and getprotobynumber() tests on *nix if there
is no /etc/protocols file.

Closes GH-6193.
2020-09-29 10:58:00 +02:00
Matthias Karbe
2899137391 Fix bug #80138
Skip getservbyname() and getservbyport() tests on *nix if there is
no /etc/services file.

Closes GH-6191.
2020-09-29 10:57:20 +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
56fb6864c6 Unify 32-bit/64-bit str_split tests
The 32-bit tests work on both 32-bit and 64-bit. I dropped the
64-bit variants as they only test one additional case that I don't
think adds particular value.
2020-09-25 10:03:41 +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
Christoph M. Becker
1fcd6cdbb8 Fix #80139: copy_variation5.phpt fails when run on bind mount
This test case is not supposed to run on case-insensitive file system;
just checking for macOS/Windows doesn't cut it.
2020-09-23 12:14:40 +02:00
Christoph M. Becker
821f6bb511 Clean up file created during testing 2020-09-23 11:45:47 +02:00
Christoph M. Becker
05edf64436 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #76735: Incorrect message in fopen on invalid mode
2020-09-23 11:14:06 +02:00
Christoph M. Becker
a89ac98f15 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #76735: Incorrect message in fopen on invalid mode
2020-09-23 10:54:59 +02:00
Christoph M. Becker
2576c57a51 Fix #76735: Incorrect message in fopen on invalid mode
We have to log errors in `stream_opener` callbacks to the wrapper's
error log, because otherwise we may pick up an unrelated `errno` or a
most generic message.

Closes GH-6187.
2020-09-23 10:54:06 +02:00
Nikita Popov
625d8463a4 Consistent error handling for fgetcsv/fputcsv
Normalize the behavior between the file functions and those on
SplFileObject.

Be consistent about throwing regardless of whether the delimiter etc
is empty or has too many characters. I don't think it's worthwhile
to distinguish these cases.

Back when we looked into this originally, there was some hope that
we might want to add support for multiple-character delimiter etc,
but after a cursory look, I really don't think this is going to
happen (for fputcsv maybe, but for fgetcsv this just makes an already
broken function much more complicated.)

Closes GH-6188.
2020-09-23 10:11:04 +02:00
Máté Kocsis
72e8719ed0
Fix a few ZEND_UNREACHABLE() calls 2020-09-23 10:07:58 +02:00
George Peter Banyard
1e9db80d72 Tweak some macro definition on Windows
Closes GH-5606
2020-09-22 23:05:12 +01:00
Nikita Popov
c2a2d2438a Fix double free on unpack error 2020-09-22 23:31:56 +02:00
Christoph M. Becker
544dbe8ef9 Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #76943: Inconsistent stream_wrapper_restore() errors
2020-09-22 16:14:03 +02:00
Christoph M. Becker
ff0f6c26c2 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #76943: Inconsistent stream_wrapper_restore() errors
2020-09-22 16:12:37 +02:00
Christoph M. Becker
5ed0602ec6 Fix #76943: Inconsistent stream_wrapper_restore() errors
If restoring of any not registered built-in wrapper is requested, the
function is supposed to fail with a warning, so we have to check this
condition first.

Furthermore, to be able to detect whether a built-in wrapper has been
changed, it is not sufficient to check whether *any* userland wrapper
has been registered, but rather whether the specific wrapper has been
modified.

Closes GH-6183.
2020-09-22 16:11:35 +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
048cc9ba78 Convert unpack offset warning to ValueError 2020-09-22 14:13:26 +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
Levi Morrison
f26d855e29 Skip if https wrapper isn't present 2020-09-22 03:36:54 -06: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
12e772f18d Promote substr_replace warnings
The implementation here was pretty confused. In reality the only
error condition it has right now is that for a string input,
from & length cannot be arrays.

The fact that the array lengths are the same was probably supposed
to be checked for the case of array input, as it wouldn't matter
otherwise.
2020-09-22 10:22:43 +02:00
Nikita Popov
ade57e691b substr_replace() cannot return false 2020-09-22 09:59:35 +02:00
Ikko Ashimine
8f3a38d927 Fixed minor typo in comment
Initiailize -> Initialize

Closes GH-6181.
2020-09-22 09:10:23 +02:00
George Peter Banyard
2ee7e2982f Promote count() warning to TypeError
Closes GH-6180
2020-09-21 21:29:15 +01:00