Commit graph

33 commits

Author SHA1 Message Date
Máté Kocsis
8e6e9838b0
Add support for generating MAY_BE_ARRAY_OF_REF func info flag (#7416) 2021-08-30 13:50:34 +02:00
Máté Kocsis
fdc6082902
Generate optimizer func info from stubs for various extensions (#7409)
ext/hash, ext/iconv, ext/mbstring, ext/xml, ext/zlib
2021-08-26 19:52:11 +02:00
Máté Kocsis
cad66533f0
Generate class entries from stubs for ldap, libxml, mbstring and mysqli
Closes GH-6684
2021-02-16 14:46:19 +01:00
Nikita Popov
5582490bf2 Normalize mb_ereg() return value
mb_ereg()/mb_eregi() currently have an inconsistent return value
based on whether the $matches parameter is passed or not:

> Returns the byte length of the matched string if a match for
> pattern was found in string, or FALSE if no matches were found
> or an error occurred.
>
> If the optional parameter regs was not passed or the length of
> the matched string is 0, this function returns 1.

Coupling this behavior to the $matches parameter doesn't make sense
-- we know the match length either way, there is no technical
reason to distinguish them. However, returning the match length
is not particularly useful either, especially due to the need to
convert 0-length into 1-length to satisfy "truthy" checks. We
could always return 1, which would kind of match the behavior of
preg_match() -- however, preg_match() actually returns the number
of matches, which is 0 or 1 for preg_match(), while false signals
an error. However, mb_ereg() returns false both for no match and
for an error. This would result in an odd 1|false return value.

The patch canonicalizes mb_ereg() to always return a boolean,
where true indicates a match and false indicates no match or error.
This also matches the behavior of the mb_ereg_match() and
mb_ereg_search() functions.

This fixes the default value integrity violation in PHP 8.

Closes GH-6331.
2020-10-13 20:40:55 +02:00
Nikita Popov
cafceea742 Update mbstring parameter names
Closes GH-6207.
2020-09-28 09:51:58 +02:00
Larry Garfield
94854e0dff Standardize mbstring and string on using 'string' as a parameter name.
Closes GH-6171.
2020-09-21 12:06:50 +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
Máté Kocsis
1c81a34563
Make mb_send_mail() consistent with mail()
The $additional_headers parameter shouldn't accept null.
2020-09-14 11:52:33 +02:00
Máté Kocsis
3e800e997b
Move custom type checks to ZPP
Closes GH-6034
2020-09-02 11:11:38 +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
Máté Kocsis
ac0da090ae
Fix UNKNOWN default values in ext/mbstring and ext/gd
Closes GH-5598
2020-07-28 17:06:25 +02:00
Nikita Popov
33ddc3bb96 Fix mb_ereg_search* arg and func info 2020-07-21 10:40:08 +02:00
George Peter Banyard
68164f40ce Fix [-Wundef] warning in MBString extension 2020-05-16 15:31:20 +02:00
George Peter Banyard
7dd332f110 Refactor mb_substitute_character()
Using the new Fast ZPP API for string|int|null

This also fixes Bug #79448 which was too disruptive to fix in PHP 7.x
2020-05-11 17:30:01 +02:00
George Peter Banyard
12ec7a2730 Convert if blocks to assertions and adapt stubs accordingly 2020-04-09 13:50:37 +02:00
Nikita Popov
38d93262a0 Update mb_strrpos() stub
We no longer accept the encoding as 3rd param, so we can make this
a proper int argument.
2020-04-08 12:03:14 +02:00
Máté Kocsis
21cfa03f17
Generate function entries for another batch of extensions
Closes GH-5352
2020-04-05 21:15:30 +02:00
George Peter Banyard
1b6f61e7c4 Promote invalid case mode to ValueError in mb_case_converter
Add assertions to check the return value is not NULL as this indicates a bug.
Add identical assertion to mb_strtoupper and mb_strtolower.
This means these functions can't return false anymore, ammend stubs accordingly.
2020-04-05 03:33:08 +02:00
George Peter Banyard
a34e73de5a mb_scrub() can't return false anymore
Also drop the intermediary function which was only used here
2020-04-05 01:44:39 +02:00
George Peter Banyard
656046873c Refactor mb_substr_count()
Promote empty needle warning to ValueError
Convert if branch into an assertion as if mbfl_substr_count fails this now implies a bug
Thus mb_substr_count() can only return int now, fix stubs accordingly
2020-04-02 22:40:00 +02:00
George Peter Banyard
165fde9a37 Convert if branch to assertion in mb_strlen
This operation should never fail, therefore it's converted to an assertion.
Thus this mb_strlen() can now only return int, fix stubs accordingly
2020-04-02 22:40:00 +02:00
George Peter Banyard
d44ee9112f Promote mb_str_split warning to ValueError
Also add a TODO about documenting this funcion on PHP.net
Convert some checks to assertions as if they don't hold something went wrong during memory allocation
Due to these changes this function cannot return false anymore, fix stubs accordingly
2020-04-02 22:40:00 +02:00
Nikita Popov
8a2ce27bba mb_detect_order(): Use proper array|string argument 2020-03-30 16:26:28 +02:00
Nikita Popov
b02b3539e7 mb_check_encoding(): Make var a proper array|string arg 2020-03-30 16:15:12 +02:00
Nikita Popov
50d07ff28c mb_detect_encoding(): Use proper array|string parameter
Needed to add support for nullabiltiy in some places.
2020-03-30 16:15:12 +02:00
Nikita Popov
bb6523693c mb_convert_variables(): Make $from an array|string argument 2020-03-30 15:51:04 +02:00
Nikita Popov
0d24422749 mb_convert_encoding(): Make $input a proper array|string arg 2020-03-30 15:41:55 +02:00
Nikita Popov
f24f6cbab9 mb_convert_encoding(): Make $from_encodings a proper array|string arg
Switching to FastZPP, as we don't support this in normal zpp.
2020-03-30 15:39:33 +02:00
Christoph M. Becker
7d0102dfa7 Revert "Replace @param annotations with type declarations"
This reverts commit c31029f335.
2020-02-17 08:55:18 +01:00
Christoph M. Becker
c31029f335 Replace @param annotations with type declarations 2020-02-16 23:43:38 +01:00
Máté Kocsis
27e83d0fb8
Add union return types for function stubs 2019-11-11 14:54:55 +01:00
Christoph M. Becker
e2100619ac Expect appropriate parameter type in the first place
`mb_encode_numericentity()` and `mb_decode_numericentity()` accepted
arbitrary zvals as `$convmap`, but ignored anything else than arrays.
This appears to be an unresolved relict of their ZPP conversion for
PHP 5.3[1].  We now expect an array in the first place.

We also expect `count($convmap)` to be a multiple of four (else we
throw a `ValueError`), and do no longer special case empty `$convmap`.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=1c77f594294aee9d60e7309279c616c01c39ba9d>
2019-10-07 16:48:08 +02:00
Christoph M. Becker
0a47096c08 Add MBString arginfo stubs 2019-10-06 17:45:32 +02:00