summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
Commit message (Collapse)AuthorAgeFilesLines
* Add support for union types for internal functionsNikita Popov2021-01-121-3/+33
| | | | | | | | | This closes the last hole in the supported types for internal function arginfo types. It's now possible to represent unions of multiple classes. This is done by storing them as TypeA|TypeB and PHP will then convert this into an appropriate union type list. Closes GH-6581.
* Export zend_is_callable_at_frameNikita Popov2020-11-191-2/+2
| | | | | | Export the zend_is_callable_impl() function as zend_is_callable_at_frame() for use by extension. As twose pointed out, an extension may want to retrieve fcc for a private method.
* Make constexpr compilation robust against multiple compilationNikita Popov2020-09-271-2/+2
| | | | | | | | | | | | | Instead of setting the old AST type to zero, replace the AST with the compiled constexpr AST zval. This requires passing in a zend_ast** instead of a zend_ast*. This allows compiling ASTs containing constexprs multiple times -- the second time, the existing compiled representation will be resused. This means we no longer need to copy the attributes AST for promoted properties.
* Initialize attributes for internal functionsNikita Popov2020-09-211-0/+1
| | | | Fixes a crash in Symfony SecurityBundle tests.
* Declare array|int and object-of-class|int types in stubsMáté Kocsis2020-09-141-3/+29
| | | | | | Closes GH-6081 Co-Authored-By: Nikita Popov <nikic@php.net>
* Consolidate new union type ZPP macro namesMáté Kocsis2020-09-111-6/+6
| | | | | | | They will now follow the canonical order of types. Older macros are left intact due to maintaining BC. Closes GH-6112
* Improve error messages mentioning parameters instead of argumentsMáté Kocsis2020-09-091-33/+30
| | | | Closes GH-5999
* Make null byte error a ValueErrorNikita Popov2020-09-081-13/+27
| | | | | | | | | | | | | Currently we treat paths with null bytes as a TypeError, which is incorrect, and rather inconsistent, as we treat empty paths as ValueError. We do this because the error is generated by zpp and it's easier to always throw TypeError there. This changes the zpp implementation to throw a TypeError only if the type is actually wrong and throw ValueError for null bytes. The error message is also split accordingly, to be more precise. Closes GH-6094.
* Release call trampolines in zpp fccNikita Popov2020-09-041-1/+5
| | | | | | | | | | | | | | When using zpp 'f' or Z_PARAM_FUNC, if the fcc points to a call trampoline release it immediately and force zend_call_function to refetch it. This may require additional callability checks if __call is used, but avoids the need to carefully free fcc values in all internal functions -- in some cases this is not simple, as a type error might be triggered by a later argument in the same zpp call. This fixes oss-fuzz #25390. Closes GH-6073.
* Merge branch 'PHP-7.4'twosee2020-08-301-12/+3
|\ | | | | | | | | | | | | | | * PHP-7.4:   Improve error_handing replacement functions # Conflicts: # Zend/zend_API.c
| * Merge branch 'PHP-7.3' into PHP-7.4twosee2020-08-301-41/+4
| |\ | | | | | | | | | | | | * PHP-7.3: Improve error_handing replacement functions
| | * Improve error_handing replacement functionstwosee2020-08-301-41/+4
| | | | | | | | | | | | | | | | | | We explicitly skip calls to user_error_handler in EH_THROW mode Closes GH-6050.
* | | Rehash function table after disabling functionsNikita Popov2020-08-281-2/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To perform fast shutdown without full table cleanup we need all internal functions to be in one continuous chunk. This was violated when functions were deleted via disable_functions. This drops the zend_disable_function() API in favor of zend_disable_functions(), which disables the given list of functions and performs the necessary rehash afterwards. Also drop PG(disabled_functions), which is no longer used.
* | | Don't mark variadic functions as ZEND_FASTCALLNikita Popov2020-08-281-3/+3
| | | | | | | | | | | | Variadic functions do not support the fastcall calling convention.
* | | Improve type declarations for Zend APIsGeorge Peter Banyard2020-08-281-86/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Remove useless same_zval functiontwosee2020-08-251-31/+2
| | | | | | | | | | | | Closes GH-6039.
* | | Check variadic parameter for type and duplicate nameNikita Popov2020-08-241-6/+10
| | | | | | | | | | | | | | | | | | Set HAS_TYPE_HINTS flag if the variadic parameter is types as well, and make sure it has a distinct name. This was previously missed, because the variadic parameter is not part of num_args.
* | | Fix bug #78770Nikita Popov2020-08-141-26/+33
| | | | | | | | | | | | | | | | | | | | | 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.
* | | Accept zend_object* in zend_update_propertyNikita Popov2020-08-071-11/+11
| | |
* | | Accept zend_object* in zend_unset_propertyNikita Popov2020-08-071-2/+2
| | |
* | | Accept zend_object in zend_read_propertyNikita Popov2020-08-071-3/+3
| | |
* | | Fix bug #79925Nikita Popov2020-08-031-4/+13
| | | | | | | | | | | | | | | If the expected return type of a magic method is "object", we also need to allow class types and "static" to comply with covariance.
* | | Enforce __set_state() parameter typeNikita Popov2020-08-031-0/+1
| | | | | | | | | | | | | | | This fixes one of the issues reported in bug #79925. The parameter type check for this particular method was missed.
* | | Ensure correct signatures for magic methodsGabriel Caruso2020-08-021-1/+52
| | |
* | | Implement named parametersNikita Popov2020-07-311-1/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Implement 'Saner Numeric Strings' RFC:George Peter Banyard2020-07-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RFC: https://wiki.php.net/rfc/saner-numeric-strings This removes the -1 allow_error mode from is_numeric_string functions and replaces it by a trailing boolean out argument to preserve BC in a couple of places. Most of the changes can be resumed to "numeric" strings which emitted a E_NOTICE now emit a E_WARNING and "numeric" strings which emitted a E_WARNING now throw a TypeError. This mostly affects: - String offsets - Arithmetic operations - Bitwise operations Closes GH-5762
* | | Preserve original ce_flags when registering classNikita Popov2020-07-201-1/+1
| | | | | | | | | | | | | | | | | | Bug that regularly sneaks in: ZEND_ACC_FINAL is set before calling zend_register_internal_class() and promptly gets ignored. Remove this footgun by preserving flags from the original CE.
* | | Add common code for magic method assignmentNikita Popov2020-07-201-41/+41
| | | | | | | | | | | | This was repeated three times.
* | | Directly assign magic methodsNikita Popov2020-07-201-30/+14
| | | | | | | | | | | | Instead of going through intermediary variables.
* | | Remove unused lc_class_name variableNikita Popov2020-07-201-21/+0
| | | | | | | | | | | | This is probably a leftover from "old style constructor" support.
* | | Report magic method names as writtenNikita Popov2020-07-201-57/+58
| | | | | | | | | | | | | | | Report the name the way the user has written it, the same way we always do.
* | | Unify magic method visibility checkNikita Popov2020-07-201-6/+23
| | | | | | | | | | | | This was missing entirely for the internal function case.
* | | Unify magic method return type checksNikita Popov2020-07-201-11/+12
| | |
* | | Unify static/non-static check for magic methodsNikita Popov2020-07-201-57/+35
| | | | | | | | | | | | And promote it to be fatal.
* | | Add missing arg num check for __set_stateNikita Popov2020-07-201-0/+2
| | |
* | | Clean up zend_check_magic_method_implementationNikita Popov2020-07-201-42/+44
| | | | | | | | | | | | | | | Let everything go through a common function, which fixes some consistency issues.
* | | Use consistent typesGeorge Peter Banyard2020-07-131-45/+27
| | | | | | | | | | | | | | | | | | | | | | | | uint32_t type for argument count size_t for length of char* zend_bool for a zval bool arg Closes GH-5845
* | | Review the usage of apostrophes in error messagesMáté Kocsis2020-07-101-18/+18
| | | | | | | | | | | | Closes GH-5590
* | | Add zend_wrong_parameter_error to reduce the size of ZPP macrotwosee2020-07-101-0/+27
| | | | | | | | | | | | Closes GH-5831.
* | | Voidify some ZEND_API functionsGeorge Peter Banyard2020-07-091-93/+62
| | | | | | | | | | | | Closes GH-5805
* | | Remove no_separation flagNikita Popov2020-07-071-1/+0
| | |
* | | Add string or object ZPP macrosMáté Kocsis2020-07-061-0/+20
| | | | | | | | | | | | Closes GH-5788
* | | Cache __unserialize() instead of unserialize()Nikita Popov2020-06-261-8/+8
| | | | | | | | | | | | | | | We should use these cache slots for the new object serialization mechanism rather than the old one.
* | | Make zend_argument_error_variadic statictwosee2020-06-091-1/+1
| | | | | | | | | | | | Closes GH-5687
* | | Constify char * arguments of APIstwosee2020-06-081-2/+2
| | | | | | | | | | | | Closes GH-5676.
* | | Fix expression warnings and break warningstwosee2020-06-071-3/+3
| | | | | | | | | | | | Close GH-5675.
* | | Add AttributesBenjamin Eberlei2020-06-041-9/+10
| | | | | | | | | | | | Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
* | | Make Exception::$trace typed array propertyNikita Popov2020-05-281-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a private property, so we are allowed to add a type. The new declaration of the property is: private array $trace = []; This ensures that Exception::getTrace() does indeed return an array. Userland code that was modifying the property through refleciton may have to be adjusted to assign an array (instead of null, for example). Closes GH-5636.
* | | Improve type error messages when an object is givenMáté Kocsis2020-05-261-1/+9
| | | | | | | | | | | | | | | | | | | | | From now on, we always display the given object's type instead of just reporting "object". Additionally, make the format of return type errors match the format of argument errors. Closes GH-5625
* | | Refactor ZPP API to use uint32_t as everywhere elseGeorge Peter Banyard2020-05-221-20/+21
| | | | | | | | | | | | Closes GH-5609