summaryrefslogtreecommitdiff
path: root/Zend/zend_exceptions.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix typoAnton Vasiliev2021-02-181-1/+1
| | | | | | Closes GH-6708 Signed-off-by: George Peter Banyard <girgias@php.net>
* Add support for generating class entries from stubsMáté Kocsis2021-01-261-58/+28
| | | | | | Closes GH-6289 Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
* Replace zend_bool uses with boolNikita Popov2021-01-151-3/+3
| | | | | | | 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.
* Make convert_to_*_ex simple aliases of convert_to_*Nikita Popov2021-01-141-1/+1
| | | | | | | | | | | | | Historically, the _ex variants separated the zval first, if a conversion was necessary. This distinction no longer makes sense since PHP 7. The only difference that was still left is that _ex checked whether the type is the same first, but the usage of these macros did not actually distinguish on whether such an inlined check is valuable or not in a given context. Also drop the unused convert_to_explicit_type macros.
* Fix handling of throwing undef var in verify returnNikita Popov2020-10-131-3/+9
| | | | | | | | | | If we have an undefined variable and null is not accepted by the return type, we want to throw just the undef var error. In this case this lead to an infinite loop, because we overwrite the exception opline in SAVE_OPLINE and it does not get reset when chaining into a previous exception. Add an assertiong to catch this case earlier.
* Convert exception instanceof checks to assertionsNikita Popov2020-09-211-11/+8
|
* Improve default value handling of Exception constructorsMáté Kocsis2020-09-211-6/+9
| | | | Closes GH-6166
* Rename zend_error_notify APIs to zend_observer_error*Benjamin Eberlei2020-09-141-2/+3
|
* Improve type declarations for Zend APIsGeorge Peter Banyard2020-08-281-3/+3
| | | | | | | | | 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
* Fixed bug #79948Nikita Popov2020-08-101-2/+2
| | | | | | | | | | | | | | Make sure we don't execute further scripts if one of them encountered an exit exception. Also make sure that we free file handles that end up unused due to an early abort in php_execute_scripts(), which turned up as an issue in the added test case. Finally, make use of EG(exit_status) in the places where we zend_eval_string_ex, instead of unconditionally assigning exit code 254. If an error occurs, the error handler will already set exit status 255.
* Accept zend_object* in zend_update_propertyNikita Popov2020-08-071-27/+25
|
* Accept zend_object* in zend_unset_propertyNikita Popov2020-08-071-1/+1
|
* Accept zend_object* in zend_get_exception_baseNikita Popov2020-08-071-16/+16
|
* Accept zend_object in zend_read_propertyNikita Popov2020-08-071-7/+7
|
* Add more argument types to stubsMáté Kocsis2020-08-071-11/+11
| | | | Closes GH-5943
* Implement named parametersNikita Popov2020-07-311-1/+7
| | | | | | | | | | | | | | | | | | 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.
* [RFC] Make string length for getTraceAsString() configurableTyson Andre2020-07-251-2/+2
| | | | | | | | | | | | | | | Add a `zend.exception_string_param_max_len` ini setting. (same suffix as `log_errors_max_len`) Allow values between 0 and 1000000 bytes. For example, with zend.exception_string_param_max_len=0, "" would represent the empty string, and "..." would represent something longer than the empty string. Previously, this was hardcoded as exactly 15 bytes. Discussion: https://externals.io/message/110717 Closes GH-5769
* Fix warnings of strict-prototypestwosee2020-07-231-1/+1
| | | | Closes GH-5887.
* Add missing zpp_none call in Exception::__wakeupNikita Popov2020-07-171-0/+2
|
* Introduce error notification callbacks that are run independant of zend_error_cbBenjamin Eberlei2020-07-171-3/+4
|
* Review the usage of apostrophes in error messagesMáté Kocsis2020-07-101-2/+2
| | | | Closes GH-5590
* Implement match expressionIlija Tovilo2020-07-091-0/+5
| | | | | | RFC: https://wiki.php.net/rfc/match_expression_v2 Closes GH-5371.
* Remove no_separation flagNikita Popov2020-07-071-1/+0
|
* Remove proto comments from C filesMax Semenik2020-07-061-26/+13
| | | | Closes GH-5758
* Merge branch 'PHP-7.4'Nikita Popov2020-06-301-2/+2
|\ | | | | | | | | * PHP-7.4: Fix leak when setting cyclic previous exception in finally
| * Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-06-301-1/+7
| |\ | | | | | | | | | | | | * PHP-7.3: Fix leak when setting cyclic previous exception in finally
| | * Fix leak when setting cyclic previous exception in finallyNikita Popov2020-06-301-1/+7
| | | | | | | | | | | | A curious exception handling pattern found in Symfony's HttpClient.
* | | Make exit() unwind properlyNikita Popov2020-06-291-1/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exit() is now internally implemented by throwing an exception, performing a normal stack unwind and a clean shutdown. This ensures that no persistent resource leaks occur. The exception is internal, cannot be caught and does not result in the execution of finally blocks. This may be relaxed in the future. Closes GH-5768.
* | | Add zend_call_known_function() API familyNikita Popov2020-06-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Fix BC break of zend_throw_exceptiontwosee2020-06-061-2/+4
| | | | | | | | | | | | | | | | | | This also fixes a SegFault Closes GH-5670
* | | Pass zend_string message to zend_error_cbNikita Popov2020-06-051-19/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the zend_error_cb API simpler, and avoid formatting the same message in multiple places. It should be noted that the passed zend_string is always non-persistent, so if you want to store it persistently somewhere, you may still need to duplicate it. The last_error_message is cleared a bit more aggressive, to make sure it doesn't hang around across allocator life-cycles. Closes GH-5639.
* | | Ensure Exception::getFile/getLine return type is correctNikita Popov2020-05-281-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | These return an untyped protected property, so we can't rely on the type being correct. Also add return types to the interface -- normally this would be a no-go, but Throwable is a special interface that can only be implemented internally, so we control all implementations.
* | | Make Exception::$previous a typed propertyNikita Popov2020-05-281-8/+5
| | | | | | | | | | | | | | | | | | Exception::$previous is a private property, so we can add a type: private ?Throwable $previous = null;
* | | Make Exception::$trace typed array propertyNikita Popov2020-05-281-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Extract code for declaring Exception/Error propertiesNikita Popov2020-05-281-16/+13
| | |
* | | Convert Exception::getMessage() result to stringNikita Popov2020-05-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We specify that the return type of Exception::getMessage() is a string. However, we don't currently ensure this, because Exception::$message is a protected member that can be set to any type. Fix this by performing an explicit type-cast. This also requires a temporary refcount increment in the __toString() object handler, because there is no additional owner of the object, and it may get released prematurely as part of the __toString() call.
* | | Improve language in error messagesMax Semenik2020-05-261-4/+4
| | | | | | | | | | | | Closes GH-5617
* | | Merge branch 'PHP-7.4'Xinchen Hui2020-04-291-2/+4
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fixed bug #79536 (zend_clear_exception prevent exception's destructor to be called).
| * | Fixed bug #79536 (zend_clear_exception prevent exception's destructor to be ↵Xinchen Hui2020-04-291-2/+4
| | | | | | | | | | | | called).
* | | Generate method entries from stubs for Zend classesMáté Kocsis2020-04-261-68/+23
| | | | | | | | | | | | Closes GH-5459
* | | Use the default type error message for Exception::__construct()Máté Kocsis2020-04-261-23/+2
| | | | | | | | | | | | Closes GH-5460
* | | Define Stringable with __toString():string methodNicolas Grekas2020-03-021-1/+1
| | |
* | | Make error messages more consistent by fixing capitalizationMáté Kocsis2020-01-171-1/+1
| | | | | | | | | | | | Closes GH-5066 As a first step, let's capitalize their initial letter when it is applicable.
* | | Convert zend_parse_parameters_none() to fast ZPPMáté Kocsis2020-01-031-14/+9
| | | | | | | | | | | | I've done the conversion in those extensions where fast ZPP is predominant.
* | | Use RETURN_THROWS() after zend_throw_error()Máté Kocsis2020-01-011-2/+2
| | |
* | | Merge branch 'PHP-7.4'Nikita Popov2019-10-281-2/+2
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Remove redundant variable rv and optimize code
| * | Remove redundant variable rv and optimize codeZiMuyang2019-10-281-2/+2
| | | | | | | | | | | | Closes GH-4864.
* | | Add Zend class/interface arginfo stubsChristoph M. Becker2019-10-151-37/+24
| | | | | | | | | | | | | | | | | | 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()`.
* | | Use clean shutdown on uncaught exceptionNikita Popov2019-10-111-3/+6
| | |
* | | add ValueErrorPeter Cowburn2019-09-091-0/+5
| | | | | | | | | | | | | | | | | | ValueError is intended to be thrown when a function or method receives an argument that has the right type (incorrect type should throw a TypeError) but an inappropriate value.