summaryrefslogtreecommitdiff
path: root/Zend/zend_interfaces.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove unnecessary checkNikita Popov2020-09-211-13/+1
| | | | | We should only produce IS_UNDEF if an exception is thrown, this check is not needed.
* Improve type declarations for Zend APIsGeorge Peter Banyard2020-08-281-4/+6
| | | | | | | | | 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
* Lowercase method name in zend_call_method()Nikita Popov2020-08-261-1/+1
|
* Implement named parametersNikita Popov2020-07-311-1/+1
| | | | | | | | | | | | | | | | | | 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.
* Fixed bug #79852Nikita Popov2020-07-141-1/+3
|
* Add get_gc handle for object iteratorsNikita Popov2020-07-011-1/+2
| | | | Optional handler with the same semantics as the object handler.
* Cache __unserialize() instead of unserialize()Nikita Popov2020-06-261-3/+4
| | | | | We should use these cache slots for the new object serialization mechanism rather than the old one.
* Don't use iterator_funcs_ptr if it is nullNikita Popov2020-06-251-1/+2
| | | | | | This avoids ubsan warnings. Alternatively we could always initialize iterator_funcs_ptr for aggregates, instead of doing so only for non-internal ones.
* Introduce InternalIteratorNikita Popov2020-06-241-8/+178
| | | | | | | | | | | | | | | | | | | Userland classes that implement Traversable must do so either through Iterator or IteratorAggregate. The same requirement does not exist for internal classes: They can implement the internal get_iterator mechanism, without exposing either the Iterator or IteratorAggregate APIs. This makes them usable in get_iterator(), but incompatible with any Iterator based APIs. A lot of internal classes do this, because exposing the userland APIs is simply a lot of work. This patch alleviates this issue by providing a generic InternalIterator class, which acts as an adapater between get_iterator and Iterator, and can be easily used by many internal classes. At the same time, we extend the requirement that Traversable implies Iterator or IteratorAggregate to internal classes as well. Closes GH-5216.
* Add ZVAL_OBJ_COPY macroNikita Popov2020-06-171-2/+1
| | | | | For the common ZVAL_OBJ + GC_ADDREF pattern. This mirrors the existing ZVAL_STR_COPY API.
* Remove called_scope inheritance in zend_call_method()Nikita Popov2020-06-101-6/+1
| | | | | | | Similar to 097043db2a0d113f89bd26c6f1d7a976d83951a8, but for the zend_call_method() API. I don't think we ever use this for static methods, but this logic shouldn't be there. If you want to inherit the active LSB scope for some reason, do so explicitly.
* Add zend_call_known_function() API familyNikita Popov2020-06-091-45/+16
| | | | | | | | | | | | | | | | | | | | | | | | This adds the following APIs: void zend_call_known_function( zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr, int param_count, zval *params); void zend_call_known_instance_method( zend_function *fn, zend_object *object, zval *retval_ptr, int param_count, zval *params); void zend_call_known_instance_method_with_0_params( zend_function *fn, zend_object *object, zval *retval_ptr); void zend_call_known_instance_method_with_1_params( zend_function *fn, zend_object *object, zval *retval_ptr, zval *param); void zend_call_known_instance_method_with_2_params( zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2); These are used to perform a call if you already have the zend_function you want to call. zend_call_known_function() is the base API, the rest are just really thin wrappers around it for the common case of instance method calls. Closes GH-5692.
* Remove some special-casing in zend_call_method()Nikita Popov2020-06-091-44/+36
| | | | | | | Don't treat the !fn_proxy && !obj_ce case differently. There doesn't seem to be any need for it, and it will result in subtly different behavior (e.g. it will accept "Foo::bar" syntax, but break as soon as you pass in an fn_proxy cache).
* Generate method entries from stubs for Zend classesMáté Kocsis2020-04-261-45/+3
| | | | Closes GH-5459
* Fixed bug #62609: Allow implementing Traversable in abstract classNikita Popov2020-03-061-0/+5
| | | | | Master only, as this depends on fixes to calling order of interface implementation handlers.
* Implement interfaces after all methods availableNikita Popov2020-03-041-88/+48
| | | | | | | | | | | | | | | | | | | | | | | | | The place where interface implementation handlers is called is currently ill-defined: If the class implements interfaces itself, the handlers for both the parent interfaces and the new interfaces will be called after all methods are registered (post trait use). If the class does not implement interfaces, then the parent interface handlers are called early during inheritance (before methods are inherited). This commit moves the calls to always occur after all methods are available. For userland classes this will be post trait import, at the time where interfaces get implemented (whether the class itself defines additional interfaces or not). For internal classes it will be at the end of inheritance, as internal class declarations do not have proper finalization. This allows us to simplify the logic for implementing the magic Iterator / IteratorAggregate interfaces. In particularly we can now also automatically detect whether an extension of IteratorAggregate can safely reuse a custom get_iterator handler, or whether it needs to switch to the userland mechanism. The Iterator case continues to rely on ZEND_ACC_REUSE_GET_ITERATOR for this purpose, as a wholesale replacement is not possible there.
* Remove empty "interface gets implemented" handlersNikita Popov2020-03-031-18/+6
|
* Define Stringable with __toString():string methodNicolas Grekas2020-03-021-0/+10
|
* Eliminate uses of ZVAL_ZVAL and friendsNikita Popov2020-01-201-1/+1
| | | | | | | | 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.
* Optimize instanceof_functionNikita Popov2019-10-251-1/+1
| | | | | | | | Split out the simple equality check into an inline function -- this is one of the common cases. Replace instanceof_function_ex with zend_class_implements_interface. There are a few more places where it may be used.
* Add Zend class/interface arginfo stubsChristoph M. Becker2019-10-151-33/+14
| | | | | | 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()`.
* Merge branch 'PHP-7.4'Nikita Popov2019-06-111-2/+2
|\
| * Support full variance if autoloading is usedNikita Popov2019-06-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keep track of delayed variance obligations and check them after linking a class is otherwise finished. Obligations may either be unresolved method compatibility (because the necessecary classes aren't available yet) or open parent/interface dependencies. The latter occur because we allow the use of not fully linked classes as parents/interfaces now. An important aspect of the implementation is we do not require classes involved in variance checks to be fully linked in order for the class to be fully linked. Because the involved types do have to exist in the class table (as partially linked classes) and we do check these for correct variance, we have the guarantee that either those classes will successfully link lateron or generate an error, but there is no way to actually use them until that point and as such no possibility of violating the variance contract. This is important because it ensures that a class declaration always either errors or will produce an immediately usable class afterwards -- there are no cases where the finalization of the class declaration has to be delayed until a later time, as earlier variants of this patch did. Because variance checks deal with classes in various stages of linking, we need to use a special instanceof implementation that supports this, and also introduce finer-grained flags that tell us which parts have been linked already and which haven't. Class autoloading for variance checks is delayed into a separate stage after the class is otherwise linked and before delayed variance obligations are processed. This separation is needed to handle cases like A extends B extends C, where B is the autoload root, but C is required to check variance. This could end up loading C while the class structure of B is in an inconsistent state.
* | Merge branch 'PHP-7.4'Dmitry Stogov2019-05-281-1/+2
|\ \ | |/ | | | | | | * PHP-7.4: Replace ZVAL_COPY() and ZVAL_COPY_VALUE() for IS_OBJECT by cheaper macros
| * Replace ZVAL_COPY() and ZVAL_COPY_VALUE() for IS_OBJECT by cheaper macrosDmitry Stogov2019-05-281-1/+2
| |
* | Merge branch 'PHP-7.4'Nikita Popov2019-05-231-2/+2
|\ \ | |/
| * Forbid use of not fully linked classesNikita Popov2019-05-231-2/+2
| |
* | Merge branch 'PHP-7.4'Nikita Popov2019-02-181-2/+14
|\ \ | |/
| * Fixed bug #77633Dmitry Stogov2019-02-181-2/+14
| | | | | | | | | | | | Add a new class flag to inherit get_iterator() when implementing the Iterator/IteratorAggregate interfaces and use it for ArrayIterator.
* | Refactor zend_object_handlers API to pass zend_object* and zend_string* ↵Dmitry Stogov2019-02-041-14/+14
|/ | | | insted of zval(s).
* Remove local variablesPeter Kokot2019-02-031-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Adios, yearly copyright rangesZeev Suraski2019-01-301-1/+1
|
* Micro optimizationsDmitry Stogov2018-10-171-26/+40
|
* Replace ZEND_ACC_ANON_BOUND, ZEND_ACC_UNRESOLVED_PARENT and ↵Dmitry Stogov2018-09-181-2/+2
| | | | ZEND_ACC_UNRESOLVED_INTERFACES with single ZEND_ACC_LINKED.
* Get rid of ZEND_ACC_CTOR, ZEND_ACC_DTOR and ZEND_ACC_IMPLEMENTED_ABSTRACTDmitry Stogov2018-09-051-1/+1
|
* Keep information about unresolved interfaces in ↵Dmitry Stogov2018-08-231-3/+7
| | | | | | | zend_class_entry->interface_names. Move interface implementation code into ZEND_DECLARE_*CLASS opcodes. Remove ZEND_ADD_INTERFACE and ZEND_VERIFY_ABSTRACT_CLASS opcodes.
* Fix some misspellingsGabriel Caruso2018-08-121-1/+1
|
* Removed useless IS_UNDEF checksDmitry Stogov2018-07-311-5/+3
|
* Remove unused Git attributes identPeter Kokot2018-07-251-2/+0
| | | | | | | | | | | | | | | The $Id$ keywords were used in Subversion where they can be substituted with filename, last revision number change, last changed date, and last user who changed it. In Git this functionality is different and can be done with Git attribute ident. These need to be defined manually for each file in the .gitattributes file and are afterwards replaced with 40-character hexadecimal blob object name which is based only on the particular file contents. This patch simplifies handling of $Id$ keywords by removing them since they are not used anymore.
* Improved user iterator implementation to reduce zend_class_entry memory ↵Dmitry Stogov2018-07-121-15/+36
| | | | consumption and avoid race condition during resolving/caching of user iterator functions of internal classes in ZTS build.
* Fixed ability to call plain functions through zend_call_method()Dmitry Stogov2018-06-251-6/+13
|
* zend_fcall_info_cache.calling_scope is not used by zend_call_function() and ↵Dmitry Stogov2018-05-031-1/+0
| | | | | | doesn't have to be initialized. It's used only as a result of zend_is_callable() in forward_static_call and spl_autoload.
* year++Xinchen Hui2018-01-021-1/+1
|
* zend_fcall_info_cache.initialized is removed (zend_fcall_info_cache is ↵Dmitry Stogov2017-12-271-1/+0
| | | | initialized if zend_fcall_info_cache.function_handler is set).
* Move constants into read-only data segmentDmitry Stogov2017-12-141-6/+6
|
* Move zend_object_iterator_funcs structures into read-only data segmentDmitry Stogov2017-12-141-1/+1
|
* further sync for vim mode linesAnatol Belski2017-07-041-0/+2
|
* "Countable" interface is moved from SPL to CoreDmitry Stogov2017-05-251-0/+18
|
* Update copyright headers to 2017Sammy Kaye Powers2017-01-021-1/+1
|
* Drop dead code in zend_call_methodNikita Popov2016-10-291-9/+0
| | | | As no_separation=1 is used this can not happen anymore.