Commit Graph

296 Commits

Author SHA1 Message Date
Nikita Popov
9e25c4b3a6 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81626
2021-11-16 12:46:20 +01:00
Nikita Popov
d26965b247 Fixed bug #81626
Backport of a8926474cb to 7.4.
2021-11-16 12:45:33 +01:00
Nikita Popov
2467f759f5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix Closure::call() on internal method closure
2021-08-27 11:59:38 +02:00
Nikita Popov
eda9f5f740 Fix Closure::call() on internal method closure
In this case we should use the original internal handler. Otherwise
the trampoline will attempt to free the closure, but the function
being used is not actually part of a closure anymore.
2021-08-27 11:58:13 +02:00
Joe Watkins
213063f6ca
Fix #81076 Invalid implicit binds cause incorrect count in static vars of closure debug info 2021-05-25 11:26:38 +02:00
twosee
09f55604ec
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80929
2021-04-16 09:49:36 +08:00
twosee
c0b1bdcdc3
Fixed bug #80929
The function name should be kept if Closure was created from the function which is marked as ZEND_ACC_CALL_VIA_TRAMPOLINE, because it is not a one-time thing and it may be called multiple times.

Closes GH-6867.
2021-04-16 09:48:36 +08:00
Christoph M. Becker
c351768e4f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74558: Can't rebind closure returned by Closure::fromCallable()
2020-11-16 14:34:28 +01:00
Christoph M. Becker
78773890f6 Fix #74558: Can't rebind closure returned by Closure::fromCallable()
Failure to rebind such closures is not necessarily related to them
being created by `ReflectionFunctionAbstract::getClosure()`, so we fix
the error message.

Closes GH-6424.
2020-11-16 14:31:06 +01:00
Nikita Popov
8e0789a21c Use proper parameter type in Closure::bindTo() signature 2020-09-21 14:46:10 +02:00
Máté Kocsis
b15885b522
Separate Closure::bind() implementations
Closure::bind() and Closure::bindTo() are currently reported as aliases in stubs because they have a single implementation. They are not aliases in fact though, they just use zend_parse_method_parameters() cleverly.

Thus, let's separate their implementation so that we don't have to alias Closure::bindTo() anymore. This will also have the advantage that the two ZPP implementations become more clear.

Closes GH-6169
2020-09-19 20:14:22 +02:00
George Peter Banyard
fa8d9b1183 Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002
2020-08-28 15:41:27 +02:00
Nikita Popov
befe10fd21 Fix bug #78770
Refactor the zend_is_callable implementation to check callability
at a particular frame (this is an implementation detail for now,
but could be exposed in the API if useful). Pick the first parent
user frame as the one to check.
2020-08-14 10:24:06 +02:00
Nikita Popov
d92229d8c7 Implement named parameters
From an engine perspective, named parameters mainly add three
concepts:

 * The SEND_* opcodes now accept a CONST op2, which is the
   argument name. For now, it is looked up by linear scan and
   runtime cached.
 * This may leave UNDEF arguments on the stack. To avoid having
   to deal with them in other places, a CHECK_UNDEF_ARGS opcode
   is used to either replace them with defaults, or error.
 * For variadic functions, EX(extra_named_params) are collected
   and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS.

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

Closes GH-5357.
2020-07-31 15:53:36 +02:00
Máté Kocsis
8664ff7ae1
Cleanup argument handling in ext/reflection
Closes GH-5850
2020-07-24 17:47:42 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +02:00
Nikita Popov
7da8c48a9b Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79778
2020-07-07 10:20:31 +02:00
Nikita Popov
d9b4974cbc Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79778
2020-07-07 10:20:11 +02:00
Nikita Popov
b765f96f5f Fixed bug #79778
In the interest of avoiding side-effects during dumping, I'm
replacing the value with a <constant ast> string instead of
performing an update constant operation.
2020-07-07 10:19:39 +02:00
Nikita Popov
302933daea Remove no_separation flag 2020-07-07 09:30:24 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Nikita Popov
15846ff115 Add ZVAL_OBJ_COPY macro
For the common ZVAL_OBJ + GC_ADDREF pattern.
This mirrors the existing ZVAL_STR_COPY API.
2020-06-17 16:36:56 +02:00
twosee
7d6a0ba808 Fix expression warnings and break warnings
Close GH-5675.
2020-06-07 10:41:11 +02:00
Máté Kocsis
d1d3a4afd5
Generate method entries for Closure 2020-05-19 14:19:37 +02:00
Nikita Popov
53efa1b0c6 Store aliased name of trait method
Currently, trait methods are aliased will continue to use the
original function name. In a few places in the codebase, we will
try to look up the actual method name instead. However, this does
not work if an aliased method is used indirectly
(https://bugs.php.net/bug.php?id=69180).

I think it would be better to instead actually change the method
name to the alias. This is in principle easy: We have to allow
function_name to be changed even if op array is otherwise shared
(similar to static_variables). This means we need to addref/release
the function_name separately, but I don't think there is a
performance concern here (especially as everything is usually
interned).

There is a bit of complication in opcache, where we need to make
sure that the function name is released the correct number of times
(interning may overwrite the name in the original op_array, but we
need to release it as many times as the op_array is shared).

Fixes bug #69180.
Fixes bug #74939.
Closes GH-5226.
2020-03-03 11:55:48 +01:00
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
1b93cfee0c
Use RETURN_THROWS() after zend_parse_method_parameters() 2020-01-02 23:01:37 +01:00
Máté Kocsis
e1b57310b1
Use RETURN_THROWS() during ZPP in main, sapi, win32, and Zend 2019-12-30 17:38:10 +01:00
Nikita Popov
48d5100738 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix use-after-free when trying to write to closure property
2019-12-18 10:24:41 +01:00
Nikita Popov
b965f158ac Fix use-after-free when trying to write to closure property 2019-12-18 10:24:02 +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
Nikita Popov
776f4bc680 Merge branch 'PHP-7.4'
* PHP-7.4:
  Add missing refcount increment
2019-10-30 09:23:23 +01:00
Nikita Popov
7816275244 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Add missing refcount increment
2019-10-30 09:23:06 +01:00
Nikita Popov
d3237b5504 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Add missing refcount increment
2019-10-30 09:22:51 +01:00
Nikita Popov
5f6eaf355c Add missing refcount increment 2019-10-30 09:22:20 +01:00
Nikita Popov
4963701aa4 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78689
2019-10-29 15:08:03 +01:00
Nikita Popov
4f1d5380e2 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #78689
2019-10-29 15:07:28 +01:00
Nikita Popov
33dd25d21c Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed bug #78689
2019-10-29 15:06:52 +01:00
Nikita Popov
f9895b4bf5 Fixed bug #78689 2019-10-29 15:06:16 +01:00
Nikita Popov
87fefd165a Remove ability to unbind $this of closures if used
This was deprecated in PHP 7.4, removing it for PHP 8.0.
2019-10-28 13:24:07 +01:00
Christoph M. Becker
273731fb76 Add Zend class/interface arginfo stubs
We also change `Generator::throw()` to expect a `Throwable` in the
first place, and we now throw a TypeError instead of returning `false`
from `Exception::getTraceAsString()`.
2019-10-15 16:21:00 +02:00
Nikita Popov
efed9f6b15 Merge branch 'PHP-7.4' 2019-10-09 17:01:02 +02:00
Nikita Popov
91eb632472 Merge branch 'PHP-7.3' into PHP-7.4 2019-10-09 17:00:55 +02:00
Nikita Popov
6fd6ad8f53 Fixed bug #78658 2019-10-09 17:00:27 +02:00
Dmitry Stogov
b02b81299c Comparison cleanup:
- introduce zend_compare() that returns -1,0,1 dirctly (without intermediate zval)
- remove compare_objects() object handler, and keep only compare() handler
2019-10-07 17:57:49 +03:00
Christoph M. Becker
0c7124e6be Add check_only parameter to get_closure handler
`get_closure` handlers are called to check whether an object is
callable, and to actually get the closure, respectively.  The behavior
of the handler might differ for these two cases, particularly the
handler may throw in the latter case, but should not in the former.

Therefore we add a `check_only` parameter, to be able to distinguish
the desired purpose.
2019-09-24 16:08:42 +02:00
Dmitry Stogov
33e10fe1cb Merge branch 'PHP-7.4'
* PHP-7.4:
  Free two bits in fn_flags by merging ZEND_ACC_HEAP_RT_CACHE/ZEND_ACC_USER_ARG_INFO and ZEND_ACC_DONE_PASS_TWO/ZEND_ACC_ARENA_ALLOCATED that may be used only for user/internal functions
2019-09-02 14:20:01 +03:00
Dmitry Stogov
c739023a50 Free two bits in fn_flags by merging ZEND_ACC_HEAP_RT_CACHE/ZEND_ACC_USER_ARG_INFO and ZEND_ACC_DONE_PASS_TWO/ZEND_ACC_ARENA_ALLOCATED that may be used only for user/internal functions 2019-09-02 14:05:28 +03:00
Nikita Popov
4e4cc9b480 Merge branch 'PHP-7.4' 2019-08-23 17:23:31 +02:00
Nikita Popov
d1157cbce1 Relax closure $this unbinding deprecation
Only deprecate unbinding of $this from a closure if $this is
syntactically used within the closure.

This is desired to support Laravel's macro system, see laravel/framework#29482.

This should still allow us to implement the performance improvements
we're interested in for PHP 8, without breaking existing use-cases.
2019-08-23 17:21:23 +02:00