Nikita Popov
29bc5a0b0f
Merge branch 'PHP-7.0'
2016-03-30 18:32:29 +02:00
Nikita Popov
f95679885f
Fix __invoke comparison in closure_get_method
...
It compared against the wrong variable. Fixed this by getting rid
of lc_name entirely and use equals_literal_ci instead.
2016-03-30 18:32:00 +02:00
Xinchen Hui
563659822d
Merge branch 'PHP-7.0'
2016-01-02 17:56:54 +08:00
Xinchen Hui
97a9470d97
bump year which is missed in rev 49493a2
2016-01-02 17:56:11 +08:00
Nikita Popov
65e456f364
Introduce BIND_LEXICAL
...
This opcodes inserts a local CV into the closure static variable
table. This replaces the previous mechanism of having static
variables marked as LEXICAL, which perform a symtable lookup
during copying.
This means a) functions which contain closures no longer have to
rebuild their symtable (better performance) and b) we can now track
used variables in SSA.
2015-12-29 23:14:53 +01:00
Andrea Faulds
8907da99b8
Set called_scope in Closure::call (fixes bug #70987 )
2015-11-27 15:06:13 +00:00
Dmitry Stogov
23b372d358
Forbid "fake" closure rebinding
2015-10-12 20:34:08 +02:00
Nikita Popov
4b821f0fc6
Normalize rebinding failures
...
Move all rebinding checks into one function to make sure they stay
in sync. Normalize return value to be NULL for all rebinding
failures, instead of returning an improperly bound closure in some
cases.
2015-10-10 13:56:36 +02:00
Nikita Popov
d677b25b1c
Merge branch 'PHP-5.6' into PHP-7.0
2015-10-09 23:28:58 +02:00
Nikita Popov
e19423f3cb
Improve previous fix
...
Don't forbid null binding on plain functions.
2015-10-09 23:28:24 +02:00
Nikita Popov
f6ae19f158
Merge branch 'PHP-5.6' into PHP-7.0
2015-10-09 23:06:32 +02:00
Nikita Popov
bbae7ddf29
Fixed bug #70681
2015-10-09 23:01:23 +02:00
Dmitry Stogov
0847681b1a
Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())
2015-10-09 11:48:13 +03:00
Dmitry Stogov
93748bf9dd
Fixed infinity recurion if we create closure on top of other closure.
2015-10-09 02:37:51 +03:00
Dmitry Stogov
05bd331c6a
Fixed use after free
2015-10-09 01:09:22 +03:00
Dmitry Stogov
91fb3a7b27
Fixed bug #70674 (ReflectionFunction::getClosure() leaks memory when used for internal functions)
2015-10-09 00:45:02 +03:00
Dmitry Stogov
e0b3b3c752
Revert "Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())"
...
This reverts commit 517b553625
.
2015-10-06 23:59:36 +03:00
Dmitry Stogov
e193d35c1e
Revert "Improve 517b55362
(scope rebinding on method Closures)"
...
This reverts commit 881c502520
.
2015-10-06 23:48:15 +03:00
Dmitry Stogov
524d00e005
Revert "Allow random $this on non-internal Closures again"
...
This reverts commit 35d0405c47
.
2015-10-06 23:48:10 +03:00
Bob Weinand
35d0405c47
Allow random $this on non-internal Closures again
...
As it turns out, there is actually no reason to prevent this, it even was a bigger BC break than expected...
Also fixes a memory leak (the Closure leaks) when calling internal functions via Closure by moving it out of leave helper onto caller side for TOP_CODE:
$z = new SplStack; $z->push(20);
$x = (new ReflectionMethod("SplStack", "pop"))->getClosure($z);
var_dump($x());
2015-10-05 17:49:32 +02:00
Bob Weinand
881c502520
Improve 517b55362
(scope rebinding on method Closures)
...
Now it is completely impossible to rebind a scoped method Closure (only the kind you get from ReflectionMethod::getClosure()) to a foreign scope
Adding a lot of tests to ensure this...
Also, properly return NULL in case the Closure could not be created instead of some crippled unbound Closure
2015-10-05 00:56:55 +02:00
Bob Weinand
517b553625
Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())
...
This additionally removes support for binding to an unknown (not in parent hierarchy) scope.
Removing support for cross-scope is necessary for certain compile-time assumptions (like class constants) to prevent unexpected results
2015-10-04 01:38:59 +02:00
Bob Weinand
e878dff5d8
Revert accidentally committed closures.c and execute.c
2015-09-19 23:22:07 +02:00
Bob Weinand
08e253cdbc
Optimize zend_mm_small_size_to_bin()
...
It removes a cmov operation and has a much faster branch for small allocations (especially when handling strings) (<= 64 bytes)
2015-09-19 23:07:43 +02:00
Bob Weinand
50d6fd6a03
Fixed bug #70397 (Segmentation fault when using Closure::call and yield)
2015-09-01 18:04:19 +02:00
Dmitry Stogov
71af54e5f6
Mark error and exception functions as "cold" (Matt's idea)
2015-08-19 14:40:56 +03:00
Aaron Piotrowski
5df893ce3c
Use NULL where possible for exception class
...
Matches usage of zend_throw_exception()/zend_throw_exception_ex().
2015-07-07 12:10:55 -05:00
Aaron Piotrowski
22c38b2ef5
Remove need to pass error level
2015-07-03 17:53:41 -05:00
Aaron Piotrowski
5a99c07ecc
Enable throwing custom exceptions from errors
2015-07-03 17:53:40 -05:00
Dmitry Stogov
7aa7627172
Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes).
2015-06-30 13:59:27 +03:00
Rasmus Lerdorf
41774bceff
Fix more minor mistakes in the proto comments
2015-06-23 15:47:33 -04:00
Bob Weinand
3c288b12b4
Fix bad run_time_cache with Closure::call()
...
This also fixes a memory "leak" (memory is allocated on unbounded arena without limits) on each new Closure instantiation.
Closures with same scope now all share the same run_time_cache (as long as it is arena allocated)
2015-06-21 16:39:44 +02:00
Dmitry Stogov
3180b8e100
Fixed bug #69802 (Reflection on Closure::__invoke borks type hint class name) (onr more problem)
2015-06-16 13:29:17 +03:00
Dmitry Stogov
ed84bff445
Complete fix for problems related to bug #69802
2015-06-16 11:24:35 +03:00
Nikita Popov
39753fa222
Merge branch 'PHP-5.6'
...
Preserving HAS_RETURN_TYPE for __invoke() here as well.
Conflicts:
Zend/zend_alloc.c
2015-05-29 11:11:02 +02:00
Nikita Popov
e7d0ca39e5
Preserve VARIADIC flag for Closure::__invoke()
...
The 13 arguments are for the benefit of PHP 7, where the first
twelve use the bitmask.
2015-05-29 11:07:23 +02:00
Stanislav Malyshev
ef8bb69a14
Ban rebinding closures to different internal classes
2015-05-12 10:54:59 +02:00
Nikita Popov
bc2ff4a299
Don't implicitly make closures in static methods static
...
It makes no sense that you can't write a closure using $this in a
static method, even though you can write one outside a class.
Now only closures that have been marked as static will be considered
to be static.
Fixes bug #65598 .
2015-05-06 17:29:05 +02:00
Nikita Popov
d9c2959c27
Fix LSB handling for closures
...
Closures will now use the called_scope from their instantiation
site. If they are rebound either the class of $this is used or if
no $this is provided the bound scope is used.
With this change the scope for static closures can be changed back
to use EG(scope) rather than EX(called_scope), thus fixing
bug #69568 .
2015-05-05 21:14:03 +02:00
Dmitry Stogov
fc80305e48
Cleanup comments and add related tests.
2015-04-23 17:52:05 +03:00
Nikita Popov
018bcc6388
Use temporary debug_info for closures
2015-04-16 15:33:47 +02:00
Dmitry Stogov
1d75953a86
We don't need this protection anymore (now reference counting on closures is accurate).
2015-04-01 13:38:05 +03:00
Dmitry Stogov
acfc31c0f8
Use zend_error_noreturn() for fatal errors
2015-04-01 13:32:23 +03:00
Dmitry Stogov
ed9c8a23ba
More accurate reference counting on closures
2015-03-10 23:04:41 +03:00
Dmitry Stogov
a30d328671
Errors converted to exceptions are not "recoverable" anymore.
2015-03-10 10:31:55 +03:00
Dmitry Stogov
1c94ff0595
Implement engine exceptions
...
RFC: https://wiki.php.net/rfc/engine_exceptions_for_php7
Pending changes regarding naming of BaseException and whether it
should be an interface.
2015-03-09 14:01:32 +01:00
Xinchen Hui
f25419f8e3
Only do this in debug build
2015-02-21 22:44:51 +08:00
Xinchen Hui
865a719a3f
Fixed mem issue with internal return type hinting assert
2015-02-21 22:17:17 +08:00
Dmitry Stogov
5f76eed14e
don't count op_arrays stored in opcache SHM
2015-02-20 14:59:30 +03:00
Dmitry Stogov
e10e151e9b
Merged zend_array and HashTable into the single data structure.
...
Now each HashTable is also zend_array, so it's refcounted and may be a subject for Copy on Write
zend_array_dup() was changed to allocate and return HashTable, instead of taking preallocated HashTable as argument.
2015-02-13 22:20:39 +03:00
Stanislav Malyshev
b64cafdb9e
Merge branch 'PHP-5.5' into PHP-5.6
...
* PHP-5.5:
Added test and possible fix for https://bugs.php.net/bug.php?id=67068
2015-01-31 23:17:24 -08:00
Danack
dbc0a80b23
Added test and possible fix for https://bugs.php.net/bug.php?id=67068
2015-01-31 23:13:55 -08:00
Stanislav Malyshev
e8e0481755
Merge branch 'pull-request/994'
...
* pull-request/994:
Added test and possible fix for https://bugs.php.net/bug.php?id=67068
2015-01-31 23:12:00 -08:00
Dmitry Stogov
638d0cb753
Merge branch 'typed_returns' of github.com:morrisonlevi/php-src into test
...
* 'typed_returns' of github.com:morrisonlevi/php-src:
Implement return types
2015-01-28 06:56:19 +03:00
Levi Morrison
c8576c5a46
Implement return types
...
RFC is documented here: https://wiki.php.net/rfc/return_types
2015-01-27 11:49:56 -07:00
Xinchen Hui
fc33f52d8c
bump year
2015-01-15 23:27:30 +08:00
Xinchen Hui
0579e8278d
bump year
2015-01-15 23:26:37 +08:00
Xinchen Hui
73c1be2653
Bump year
2015-01-15 23:26:03 +08:00
Danack
1397790560
Added test and possible fix for https://bugs.php.net/bug.php?id=67068
2015-01-13 01:24:19 +00:00
Stanislav Malyshev
b7a7b1a624
trailing whitespace removal
2015-01-10 15:07:38 -08:00
Dmitry Stogov
c42ac09518
Added new API function 'zend_string* zend_string_tolower(zend_string*)'.
...
It simplifies code and avoids unnecessary allocation and copying if string is already in lower case.
2014-12-24 15:04:51 +03:00
Dmitry Stogov
2646f7bcb9
Don't count variadic argument in zend_func.common.num_args. This allows faster CALL/RETURN code.
2014-12-22 16:44:39 +03:00
Anatol Belski
bdeb220f48
first shot remove TSRMLS_* things
2014-12-13 23:06:14 +01:00
Dmitry Stogov
3893c1fc3d
Fixed compilation warnings
2014-12-12 21:57:34 +03:00
Guilherme Blanco
094d409b3d
Removed ZEND_ACC_FINAL_CLASS which is unnecessary. This also fixed some currently defined classes as final which were just not being considered as such before.
2014-12-12 17:29:54 +01:00
Dmitry Stogov
5dd427eac2
Use zend_string* for op_array->arg_info[]->name and op_array->arg_info[]->class_name. For internal functions we still use char*.
2014-12-03 16:56:09 +03:00
Nikita Popov
ee5b30fa19
Remove support for classes without class entries
...
get_class_entry must be non-NULL and return non-NULL.
2014-10-09 13:58:14 +02:00
Dmitry Stogov
bd9a234645
Replaced EG(This) and EX(object) with EX(This).
...
Internal functions now recieves zend_execute_data as the first argument.
2014-10-03 19:32:46 +04:00
Dmitry Stogov
3bc8a958c5
Fixed useless or duplicated IS_INTERNED() checks
2014-09-19 15:41:01 +04:00
Xinchen Hui
24ab7b53f2
It should be int
2014-08-27 12:14:57 +08:00
Xinchen Hui
8b87534468
Fixed folder mark
2014-08-27 12:13:17 +08:00
Andrea Faulds
7379abba8f
Fixed Closure::apply() for int64
2014-08-27 02:05:50 +01:00
Andrea Faulds
17c5e82816
Merge branch 'master' into Closure_apply
2014-08-27 01:53:26 +01:00
Nikita Popov
46b53e815c
Add zend_string_equals and zend_string_equals_literal
2014-08-25 22:40:58 +02:00
Anatol Belski
6f9f0bf205
master renames phase 2
2014-08-25 19:28:33 +02:00
Anatol Belski
c3e3c98ec6
master renames phase 1
2014-08-25 19:24:55 +02:00
Andrea Faulds
342265badb
Just return, no need for RETURN_NULL()
2014-08-20 00:11:11 +01:00
Andrea Faulds
56e6a45c41
Accuracy
2014-08-18 14:50:05 +01:00
Andrea Faulds
2f40631716
Fixed issues spotted by code review
2014-08-18 14:47:57 +01:00
Andrea Faulds
333a465751
Comment clarification
2014-08-18 00:03:56 +01:00
Andrea Faulds
429bbd7081
Old comment, whitespace
2014-08-17 23:54:23 +01:00
Andrea Faulds
59010bff01
Don't allow unbound scoped closures; make ->call used passed object as scope
2014-08-17 23:47:47 +01:00
Andrea Faulds
3f468cd1c7
Removed unused variable
2014-08-17 20:21:12 +01:00
Andrea Faulds
6d187d53ae
Fixed and cleaned up implementaton of Closure::call() for phpng
2014-08-17 20:20:23 +01:00
Andrea Faulds
e35c8ae13e
Merge branch 'master' into Closure_apply
...
Conflicts:
Zend/zend_closures.c
Zend/zend_closures.h
Zend/zend_execute_API.c
Zend/zend_vm_def.h
2014-08-17 17:20:02 +01:00
Andrea Faulds
85bf8b4ff1
Fixed unbound scoped closure edge cases and added tests for them
2014-07-30 03:21:44 +01:00
Andrea Faulds
f65bdda469
Rename ::apply to ::call for the sake of JS consistency
2014-07-30 01:26:53 +01:00
Andrea Faulds
ded5b3fda4
Added optional bool param $unbound_scoped to Closure::bind and ::bindTo
2014-07-29 18:59:36 +01:00
Andrea Faulds
167128d854
Implemented Closure::apply
2014-07-29 02:36:17 +01:00
Dmitry Stogov
2ed8a17045
Refactored run_time_cache usage in object handlers
2014-07-07 20:54:31 +04:00
Dmitry Stogov
412ad4b254
Uinified call frame handling for user and internal functions.
...
Now EG(current_execute_data) always point to the call frame of the currently executed function.
2014-07-02 22:01:25 +04:00
Dmitry Stogov
c69781393c
Refactoring: merge call_frame and end_execute_data into single data structure. Keep only single copy of each argument on VM stack (previously ZE kept two copies of each arguments for user functions)
2014-06-26 23:51:14 +04:00
Dmitry Stogov
43477bc7a2
Refactoring: use call_frames instead of call_slots
2014-06-24 02:17:16 +04:00
Dmitry Stogov
dd1c68e67f
Merge branch 'master' into phpng
...
* master: (77 commits)
NEWS entry for Fix potential segfault in dns_get_record()
NEWS entry for "Fix potential segfault in dns_get_record()"
NEWS entry for Fix potential segfault in dns_get_record(
Fix potential segfault in dns_get_record()
Revert "Add optional second arg to unserialize()"
5.5.15 now
update NEWS
Fix bug #66127 (Segmentation fault with ArrayObject unset)
5.4.31 next
Add NEWS. This doesn't need UPGRADING (or an RFC), IMO.
Fix broken test.
Add a mime type map generation script and update the header.
Move the mime type map out of php_cli_server.c for easier generation.
Replace the CLI server's linear search for extensions with a hash table.
fix test
Remove unused included file
NEWS
NEWS
NEWS
Fixed Bug #67413 fileinfo: cdf_read_property_info insufficient boundary chec
...
Conflicts:
Zend/zend_closures.c
Zend/zend_execute.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/spl/spl_array.c
ext/standard/basic_functions.c
ext/standard/dns.c
ext/standard/var.c
2014-06-12 05:07:33 +04:00
Stanislav Malyshev
8f527fbf14
Merge branch 'PHP-5.5' into PHP-5.6
...
* PHP-5.5:
Fix bug 666222
Fix bug 666222
2014-06-08 19:02:24 -07:00
Levi Morrison
f47976dd9b
Fix bug 666222
...
This also adds some smaller, isolated tests related to bug 66622.
2014-06-08 18:59:44 -07:00
Xinchen Hui
bc357eaf3f
Fixed apply_func_args_t
2014-05-25 20:04:35 +08:00
Dmitry Stogov
9eb89dddb1
Use optimized zend_array_dup() function. convert zend_hash_num_elements() and zend_hash_next_free_element() into macros.
2014-05-23 20:37:53 +04:00
Xinchen Hui
88c550a799
Added vstrpprintf strpprintf to avoid duplicate string
...
(the function name maybe improvement)
2014-05-10 00:21:49 +08:00
Dmitry Stogov
4ed452c1b5
Convert zval_get_string() into "fast path" macro and "slow path" function
2014-04-21 22:36:01 +04:00