The arg_info member of zend_function is now always a zend_arg_info*. Before,
it was a zend_internal_arg_info* on internal functions, unless the
ZEND_ACC_USER_ARG_INFO flag was set.
Closes GH-19022
Abstracting away the bool parameter is not that useful, and doesn't make the code more legible.
Moreover, it is not needed if one passes the zend_function* directly, which we always have.
This is because it can be derived/copied from the fn_flags.
This regressed in GH-17592.
The function is with its attributes HashTable* is copied in
zend_get_closure_invoke_method() but its refcount is not increased.
This caused a crash in the Symfony demo page.
Closes GH-17880.
* Fix `#[\Deprecated]` for `__call()` and `__callStatic()`
Fixesphp/php-src#17597.
* Do not duplicate the `attributes` table in `zend_get_call_trampoline_func()`
The zend_object.properties HashTable needs to be built just in time by calling
rebuild_object_properties() on the object before accessing it. Normally this is
done automatically in zend_std_get_properties(), but we do it manually in a few
places.
In this change I introduce an inline variant of zend_std_build_properties(), and
refactor these places to use it instead of calling rebuild_object_properties()
manually.
rebuild_object_properties() renamed as rebuild_object_properties_internal(), to
enforce usage of zend_std_get_properties() or zend_std_build_properties_ex().
Closes GH-14996
This is annoying for multiple reasons:
1. LSPs can show many errors for these files.
2. LSP can stop parsing these files completely if there are too many errors,
resulting in spotty LSP features.
This PR introduces a new way of recursion protection in JSON, var_dump
and friends. It fixes issue in master for __debugInfo and also improves
perf for jsonSerializable in some cases. More info can be found in
GH-10020.
Closes GH-11812
`zend_uchar` suggests that the value is an ASCII character, but here,
it's about very small integers. This is misleading, so let's use a
C99 integer instead.
On all architectures currently supported by PHP, `zend_uchar` and
`uint8_t` are identical. This change is only about code readability.
The comment is outdated as of PHP7.
For example, in the current code, zend_assign_op_overloaded_property() expects the refcount of the returned value from read_property to be greater than 0 when the returned value is a refcounted, to call zval_ptr_dtor() later.
History:
- The same description was originally written in a commit in 2004 alongside the write side. c8c0e97982
- One requested to put the description in somewhere. https://externals.io/message/7789
- Then it was added as a comment in zend_object_handler.h . 7d3215d333
- At the time the comment was written, there were at least three places where the code actually set the reference count to 0 in read_properties.
- 7d3215d333/ext/dom/php_dom.c (L229)
- 7d3215d333/ext/mysqli/mysqli.c (L190)
- 7d3215d333/ext/simplexml/simplexml.c (L245)
- All three of the above were removed during the development of PHP 7.
- 2f0a758fbb
- 2402d6cbbc
- a975c7e0fe
- In the current code, even when they generate and return a refcounted value, its refcount would be 1.
Closes GH-6618.
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.
Of course, zend_bool is retained as an alias.
The same description was originally written in a commit in 2004 which fixes a bug in the pre-released simplexml.
c8c0e97982
One requested to put the description in somewhere.
https://externals.io/message/7789
Then it was added as a comment in zend_object_handler.h .
7d3215d333
At the time of the comment written, the refcount of RHS was simply incremented before calling the write handler in the process of ZEND_ASSIGN_OBJ.
c8c0e97982/Zend/zend_execute.c (L407)
The refcount of a zval may be 0 or 1 if the write handler is called from zend_API in that era.
c8c0e97982/Zend/zend_API.c (L1058-L1170)
The original fix in simplexml was removed in 2018, because scalar types don't have reference counter anymore as of PHP7.
f7f790fcc94a475a4976
It seems that the original intent of this prescription was preventing unintended modification to the RHS and values which share the memory location with the RHS in assignments.
In the first place, it is not usual trying to change the RHS in a write handler, IMHO. I don't think the description makes sense in the current situation about handling of refcount, so I simply delete the whole sentences.
Because write_dimension has no return value, the mentioning about the return value is moved to the comment for write_property only.
Closes GH-6597.
Avoid subtle differences in behavior depending on whether the
handler is absent or returns FAILURE.
If you previously set cast_object to NULL, create a handler that
always returns FAILURE instead.
`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.
Now that set() is gone, there is little point in keeping get(), as
it is essentially just a different way of writing cast_object()
now.
Closes GH-4202.
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.
A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.
This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.
With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.
Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files. All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
A dynamic property may be shadowed by a private/protected property.
Make sure we check property accessibility for non-indirect
properties as well.
Closes#3626.