1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 07:28:09 +02:00
Commit Graph

572 Commits

Author SHA1 Message Date
Nikita Popov 6811222422 Eliminate uses of ZVAL_ZVAL and friends
Instead add RETURN_COPY(_VALUE) macros will the expected behavior.

RETURN_ZVAL doesn't make any sense since PHP 7, but has stuck
around, probably because the alternative was to write directly to
the return_value variable.
2020-01-20 10:34:17 +01:00
Máté Kocsis 31cf9a7ea9 Use RETURN_THROWS() when an exception is thrown
Closes GH-5036
2019-12-30 17:38:10 +01:00
Nikita Popov a603c06e2e Support "string or array" in zpp
This is one of our more common argument unions. Usage is just
prototyped in a few places, certainly not a full conversion.

I'm removing the str_replace.phpt test, because aparently it was
split up into smaller tests at some point, but the original has
not been removed.

Closes GH-4970.
2019-12-05 12:25:57 +01:00
Nikita Popov 292a1aeb59 Support union types for args in gen stubs
Using this requires care! The zpp implementation for this union
must be consistent with the arginfo implementation!

Apart from array|object, this is probably only the case for
int|float right now.
2019-11-15 17:33:37 +01:00
Nikita Popov 0cec268d15 Support single class unions in gen stubs 2019-11-15 17:19:26 +01:00
Nikita Popov 9bbbc9e7e9 Add support for union types in stubs
This is the MVP for supporting union types in PHP stubs. Return
types with only builtin types work, which is the part we mainly
need.

Closes GH-4895.
2019-11-08 17:32:18 +01:00
Tyson Andre 70b4bc963c Fix compile error using zend_parse_parameters_throw()
Fixes a bug introduced in 4008704f62

The trailing comma is followed by `)` when the varargs list
is empty in the macro, which is a syntax error in C

This fixes compilation of code such as the following

    PHP_FUNCTION(get_metadata) {
      if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "") == FAILURE) {
        return;
      }

Closes GH-4896.
2019-11-08 16:29:10 +01:00
Nikita Popov ac4e0f0852 Make zend_type a 2-field struct
We now store the pointer payload and the type mask separately. This
is in preparation for union types, where we will be using both at
the same time.

To avoid increasing the size of arginfo structures, the
pass_by_reference and is_variadic fields are now stored as part of
the type_mask (8-bit are reserved for custom use).

Different types of pointer payloads are distinguished based on bits
in the type_mask.
2019-11-08 15:15:48 +01:00
Christoph M. Becker 4008704f62 zend_parse_parameters_throw() is obsolete
Since `zend_parse_parameters()` throws now, there is no reason to
explicitly call `zend_parse_parameters_throw()` anymore, and since both
have actually the same implementation, we redefine the latter as macro.
2019-11-01 16:47:15 +01:00
Nikita Popov 6719d3e718 Add Z_PARAM_STRING/ARRAY_OR_NULL convenience macros 2019-10-29 13:29:52 +01:00
Colin O'Dell 8ccd58baca Add Z_PARAM_LONG_OR_NULL macro 2019-10-22 12:09:04 +02:00
Nikita Popov 9e8ba7891e Change representation of zend_type from type code to MAY_BE_* mask
This switches zend_type from storing a single IS_* type code to
storing a MAY_BE_* type mask. Right now most code still assumes
that there is only a single type in the mask (or two together
with MAY_BE_NULL). But this will make it a lot simpler to introduce
union types.

An additional advantage (and why I'm doing this separately), is
that a number of special cases no longer need to be handled
separately: We can do a single mask & (1 << type) check to handle
all simple types, booleans (true|false) and null.
2019-09-23 15:31:35 +02:00
George Peter Banyard 675e975185 Promote warning to error in zend_forbid_dynamic_call() 2019-08-23 20:01:51 +02:00
Nikita Popov bbcfa5083e Remove Z_PARAM_ZVAL_DEREF
Since PHP 7.4 using this is very likely wrong, and we don't have
any core uses of it for that reason. Extensions shouldn't be using
it either. Accept as Z_PARAM_ZVAL and then assign using
ZEND_TRY_ASSIGN macros.
2019-07-18 10:44:27 +02:00
Nikita Popov 6efb354831 Merge branch 'PHP-7.4' 2019-07-11 17:09:23 +02:00
Nikita Popov cbda1b1c6a Add ZEND_DEP_ME macro 2019-07-11 17:09:03 +02:00
Dmitry Stogov 0e5ecc7a8f Merge branch 'PHP-7.4'
* PHP-7.4:
  Delay EG(exception) check on slow path
2019-07-08 14:13:02 +03:00
Dmitry Stogov 9a833438d1 Delay EG(exception) check on slow path 2019-07-08 13:56:34 +03:00
Dmitry Stogov bfca9592d0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Eliminate useless checks
2019-07-05 14:25:26 +03:00
Dmitry Stogov 55f7d3b70a Eliminate useless checks 2019-07-05 14:21:18 +03:00
Nikita Popov 88a71ed5f3 Merge branch 'PHP-7.4' 2019-06-14 13:12:08 +02:00
twosee 42cc58ff7b Turn add_index_zval and add_next_index_zval into inline function
Avoids expression warnings and allows explicitly namespaced use in
C++.

Closes GH-4250.
2019-06-14 13:10:27 +02:00
twosee 61f78de486 Constify some char* arguments or return values of ZEND_API
Closes GH-4247.
2019-06-12 16:49:32 +02:00
twosee 63171d88f2 Add do...while(0) for RETURN_* and ZVAL_* APIs
Closes GH-4255.
2019-06-12 16:17:16 +02:00
Nikita Popov 7686b0b889 Merge branch 'PHP-7.4' 2019-06-05 14:53:50 +02:00
Nikita Popov a31f46421d Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions

And convert some object to string conversion related recoverable
fatal errors into Error exceptions.

Improve exception safety of internal code performing string
conversions.
2019-06-05 14:25:07 +02:00
Nikita Popov 321fe88935 Add Z_PARAM_NUMBER and use it for some functions 2019-06-03 10:14:05 +02:00
Nikita Popov 8a0965e3d6 Remove zpp L specifier
We don't use this internally anymore, and external usages should
be encouraged to move towards 'l'.
2019-06-03 09:39:17 +02:00
Dmitry Stogov b4a3b49eab Merge branch 'PHP-7.4'
* PHP-7.4:
  Better hot/cold code splitting
2019-05-31 12:22:08 +03:00
Dmitry Stogov 1df9f238fe Better hot/cold code splitting 2019-05-31 12:20:21 +03:00
Dmitry Stogov 6d89553c48 Merge branch 'PHP-7.4'
* PHP-7.4:
  Mark "cold" functions
2019-05-29 11:50:27 +03:00
Dmitry Stogov e14d77335c Mark "cold" functions 2019-05-29 11:48:41 +03:00
Anatol Belski 37d01ff81a Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix conditional compilation
  These macros should not expect any argument
2019-05-29 02:54:15 +02:00
Anatol Belski 1a4ace05ae These macros should not expect any argument 2019-05-29 02:29:02 +02:00
Dmitry Stogov 6a8b5599df Merge branch 'PHP-7.4'
* PHP-7.4:
  Put phpinfo() related code into cold code segment
2019-05-28 11:04:47 +03:00
Dmitry Stogov 072f28938f Put phpinfo() related code into cold code segment 2019-05-28 11:04:13 +03:00
Nikita Popov 20e983d9ce Merge branch 'PHP-7.4' 2019-05-14 14:59:36 +02:00
Nikita Popov 3f19f5112a Add RETURN_EMPTY_ARRAY() / RETVAL_EMPTY_ARRAY()
The usual wrappers around ZVAL_EMPTY_ARRAY()...
2019-05-14 14:59:10 +02:00
Nikita Popov cdb7ebd972 Merge branch 'PHP-7.4' 2019-04-29 09:58:56 +02:00
Nikita Popov 22e9a5e0c3 Fix typo in TRY_ASSIGN macro name 2019-04-29 09:58:45 +02:00
Dmitry Stogov e188e4170f Use ZEND_TRY_ASSIGN_REF_... macros for arguments passed to internal function by reference 2019-04-24 18:28:29 +03:00
Dmitry Stogov 2e4686b566 Use ZEND_TRY_ASSIGN_REF_... macros for arguments passed to internal function by reference 2019-04-24 18:16:47 +03:00
Dmitry Stogov 34db07567d Use ZEND_TRA_ASSIGN_REF_... macros for by reference arguments of internal functions. 2019-04-24 16:14:48 +03:00
Nikita Popov 8971728383 Merge branch 'PHP-7.4' 2019-03-20 12:07:05 +01:00
Nikita Popov abc457fe1d Fixed bug #74345
Export zend_release_fcall_info_cache(). It is only necessary to
call it if the fcc may not have been used -- if it is passed to
zend_call_function() and friends, then they will take care of
freeing trampolines.
2019-03-20 12:06:42 +01:00
Nikita Popov 513b76794b Make zpp failures always throw, independent of strict_types
Previously zend_parse_parameters (and FastZPP) would handle invalid
arguments depending on strict_types: With strict_types=1, a TypeError
is thrown, with strict_types=0 a warning is thrown and (usually) NULL
is returned. Additionally, some functions (constructors always and
other methods sometimes) opt-it to throwing regardless of strict_types.

This commit changes zpp to always generate a TypeError exception in
PHP 8.
2019-03-11 11:32:20 +01:00
Nikita Popov a9d4caeece Add ZEND_TRY_ASSIGN_BOOL API
Cherry-picked from master, this is of course also necessary in 7.4...
2019-02-08 12:30:54 +01:00
Nikita Popov 706ba151d2 Add ZEND_TRY_ASSIGN_BOOL API 2019-02-08 11:06:50 +01:00
Dmitry Stogov 91ef4124e5 Refactor zend_object_handlers API to pass zend_object* and zend_string* insted of zval(s). 2019-02-04 13:20:25 +03:00
Peter Kokot 623911f993 Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove local variables
2019-02-03 21:23:18 +01:00