summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
Commit message (Collapse)AuthorAgeFilesLines
* Use ZEND_TOSTRING_FUNC_NAMEmoliata2020-06-181-1/+1
| | | | Closes GH-5736.
* Use zend_is_constructor()moliata2020-06-171-1/+1
|
* Use ZEND_UNREACHABLE() instead of ZEND_ASSERT(0)Christoph M. Becker2020-06-161-2/+2
| | | | | | | | | Instead of marking unreachable code with `ZEND_ASSERT(0)`, we introduce `ZEND_UNREACHABLE()`, so that MSVC which does not consider `assert(0)` to mark unreachable code does no longer trigger C4715[1] warnings in debug builds. This may be useful for other compilers as well. [1] <https://docs.microsoft.com/de-de/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4715?view=vs-2019>
* Add helper APIs for maybe-interned string creationtwosee2020-06-081-2/+2
| | | | | | | | | | | | Add ZVAL_CHAR/RETVAL_CHAR/RETURN_CHAR as a shortcut for using ZVAL_INTERNED_STRING and ZSTR_CHAR. Add zend_string_init_fast() as a helper for the empty string / one char interned string / zend_string_init() pattern. Also add corresponding ZVAL_STRINGL_FAST etc macros. Closes GH-5684.
* Fix bug #77966: Cannot alias a method named "namespace"Nikita Popov2020-06-081-1/+1
| | | | | | | | | | | | | | | | | | | | This is a bit tricky: In this cases we have "namespace as", which means that we will only recognize "namespace" as an identifier when the lookahead token is already at the "as". This means that zend_lex_tstring picks up the wrong identifier. We solve this by actually assigning the identifier as the semantic value on the parser stack -- as in almost all cases we will not actually need the identifier, this is just an (offset, size) reference, not a copy of the string. Additionally, we need to teach the lexer feedback mechanism used by tokenizer TOKEN_PARSE mode to apply feedback to something other than the very last token. To that purpose we pass through the token text and check the tokens in reverse order to find the right one. Closes GH-5668.
* Constify char * arguments of APIstwosee2020-06-081-1/+1
| | | | Closes GH-5676.
* Fix expression warnings and break warningstwosee2020-06-071-4/+4
| | | | Close GH-5675.
* Implement "Constructor Promotion" RFCNikita Popov2020-06-051-4/+81
| | | | | | RFC: https://wiki.php.net/rfc/constructor_promotion Closes GH-5291.
* Add AttributesBenjamin Eberlei2020-06-041-8/+85
| | | | Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
* Fix #79652 Ensure that the mixed type is displayed instead of the union of ↵Máté Kocsis2020-05-301-1/+1
| | | | | | all types Closes GH-56430
* Fix variable typeNikita Popov2020-05-261-4/+4
| | | | This is no longer a boolean.
* Allow generators to have a real return type of `mixed` or `object`Tyson Andre2020-05-261-3/+2
| | | | | | | | | | Fixes an edge case overlooked in https://github.com/php/php-src/pull/5313 Generators are objects, so `object` should have also been allowed in addition to `iterable` and `Traversable` Closes GH-5626
* Support catching exceptions without capturing them to variablesMax Semenik2020-05-261-4/+4
| | | | | | RFC: https://wiki.php.net/rfc/non-capturing_catches Closes GH-5345.
* Remove depreacted curly brace offset syntaxGeorge Peter Banyard2020-05-221-3/+2
| | | | Closes GH-5221
* Add support for the mixed typeMáté Kocsis2020-05-221-7/+28
| | | | | | | RFC: https://wiki.php.net/rfc/mixed_type_v2 Closes GH-5313 Co-authored-by: Dan Ackroyd <danack@basereality.com>
* Merge branch 'PHP-7.4'Nikita Popov2020-05-201-12/+22
|\ | | | | | | | | * PHP-7.4: Fix bug #79603, by retrying on RTD key collision
| * Fix bug #79603, by retrying on RTD key collisionNikita Popov2020-05-201-12/+22
| | | | | | | | | | | | | | This is a non-intrusive fix for 7.4, still trying to find a good solution for master. Closes GH-5597.
* | Use zend_zval_type_name() API where possibleNikita Popov2020-05-131-2/+2
| | | | | | | | Rather than zend_get_type_by_const(Z_TYPE_P()).
* | Make numeric operations on resources, arrays and objects type errorsNikita Popov2020-05-051-5/+3
| | | | | | | | | | | | RFC: https://wiki.php.net/rfc/arithmetic_operator_type_checks Closes GH-5331.
* | Completely remove disabled functions from function tableNikita Popov2020-04-301-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, disabling a function only replaces the internal function handler with one that throws a warning, and a few places in the engine special-case such functions, such as function_exists. This leaves us with a Schrödinger's function, which both does not exist (function_exists returns false) and does exist (you cannot define a function with the same name). In particular, this prevents the implementation of robust polyfills, as reported in https://bugs.php.net/bug.php?id=79382: if (!function_exists('getallheaders')) { function getallheaders(...) { ... } } If getallheaders() is a disabled function, this code will break. This patch changes disable_functions to remove the functions from the function table completely. For all intents and purposes, it will look like the function does not exist. This also renders two bits of PHP functionality obsolete and thus deprecated: * ReflectionFunction::isDisabled(), as it will no longer be possible to construct the ReflectionFunction of a disabled function in the first place. * get_defined_functions() with $exclude_disabled=false, as get_defined_functions() now never returns disabled functions. Fixed bug #79382. Closes GH-5473.
* | Check `__set_state` structureGabriel Caruso2020-04-281-0/+2
| | | | | | | | | | | | Fix Bug #79521. Closes GH-5462.
* | Slipt error messages while checking magic methods attributesGabriel Caruso2020-04-271-4/+10
| | | | | | | | Closes GH-5465
* | Avoid throw expression leaksNikita Popov2020-04-271-4/+10
| | | | | | | | | | | | | | | | | | Mark "throw" used in expression context with a flag, and don't treat it as a BB terminator in that case. This prevents us from optimizing away the following opcodes as unreachable, which may result in live ranges being dropped incorrectly. Close GH-5450.
* | Pass existing lcname to check_magic_method_implementationNikita Popov2020-04-271-4/+6
| |
* | Add case insensitive find_ptr hash functionsLevi Morrison2020-04-261-25/+11
| | | | | | | | | | | | | | | | | | - zend_hash_find_ptr_lc(ht, zend_string *key) - zend_hash_str_find_ptr_lc(ht, const char *str, size_t len) Note that zend_hash_str_find_ptr_lc used to exist in zend_compile.c as zend_hash_find_ptr_lc. When exporting this I figured it was best to use the same conventions as the rest of zend_hash.h.
* | Check Serialization magic methods structureGabriel Caruso2020-04-261-0/+4
| | | | | | | | Closes GH-5441
* | Use zend_make_tmp_result() helper in more placesNikita Popov2020-04-241-11/+5
| |
* | Accept result znode in zend_compile_class_decl()Nikita Popov2020-04-241-12/+8
| | | | | | | | Make this use the same pattern we use everywhere else.
* | Use return in compile_expr for consistencyIlija Tovilo2020-04-241-1/+1
| |
* | Make throw statement an expressionIlija Tovilo2020-04-231-4/+7
| | | | | | | | | | | | | | | | | | | | RFC: https://wiki.php.net/rfc/throw_expression This has an open issue with temporaries that are live at the time of the throw being leaked. Landing this now for easier testing and will revert if we cannot resolve the issue. Closes GH-5279.
* | Remove ZEND_ACC_DTOR flagNikita Popov2020-04-171-1/+0
| | | | | | | | | | | | | | | | | | | | This is only used in reflection, where doing a simple string check is acceptable. I'm also dropping the "dtor" printing in the reflection dump. Dtors are just one of many magic methods, I don't think there's a point in explicitly highlighting them, when the name is already unambiguous.
* | Fix magic method nameGabriel Caruso2020-04-161-1/+1
| |
* | Improve error messages for magic methods by appending method's classGabriel Caruso2020-04-161-13/+15
| | | | | | | | Closes GH-5397.
* | Add zend_string_concat2 APINikita Popov2020-04-141-10/+3
| |
* | Add zend_create_member_string() APINikita Popov2020-04-141-6/+10
| | | | | | | | This is a recurring pattern.
* | Export the zend_string_concat3() APINikita Popov2020-04-091-16/+3
| |
* | Make division by zero error check more accurateNikita Popov2020-04-011-1/+2
| | | | | | | | | | | | For division (rather than modulus) we should check the double value, otherwise the result might be zero after integer truncation, but not zero as a floating point value.
* | Unify checks for binary operator errors for ct evalNikita Popov2020-04-011-27/+29
| | | | | | | | | | Move everything into one function and share it with opcache. This fixes some discrepancies.
* | Check abstract method signatures coming from traitsNikita Popov2020-03-261-1/+1
| | | | | | | | | | | | RFC: https://wiki.php.net/rfc/abstract_trait_method_validation Closes GH-5068.
* | Revert "Fetch for read in nested property assignments"Nikita Popov2020-03-181-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit bb43a3822e42dbd15b1d416a166549d3980b379a. After thinking about this a bit more, this is now going to be a complete solution for the "readonly properties" case, for example: unset($foo->readOnly->bar); should also be legal and $foo->readOnly['bar'] = 42; should also be legal if $foo->readOnly is not an array but an ArrayAccess object. I think it may be better to distinguish better on the BP_VAR flag level. Reverting for now.
* | Fetch for read in nested property assignmentsNikita Popov2020-03-181-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $a->b->c = 'd'; is now compiled the same way as $b = $a->b; $b->c = 'd'; That is, we perform a read fetch on $a->b, rather than a write fetch. This is possible, because PHP 8 removed auto-vivification support for objects, so $a->b->c = 'd' may no longer modify $a->b proper (i.e. not counting interior mutability of the object). Closes GH-5250.
* | Merge branch 'PHP-7.4'Dmitry Stogov2020-03-131-3/+13
|\ \ | |/ | | | | | | | | | | | | * PHP-7.4: Check asserts early identation fix Call global code of preloaded script in global context Avoid "Anonymous class wasn't preloaded" error by lazely loading of not preloaded part of a preloaded script
| * Check asserts earlyDmitry Stogov2020-03-121-1/+1
| |
| * Avoid "Anonymous class wasn't preloaded" error by lazely loading of not ↵Dmitry Stogov2020-03-121-3/+13
| | | | | | | | preloaded part of a preloaded script
* | Store aliased name of trait methodNikita Popov2020-03-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, trait methods are aliased will continue to use the original function name. In a few places in the codebase, we will try to look up the actual method name instead. However, this does not work if an aliased method is used indirectly (https://bugs.php.net/bug.php?id=69180). I think it would be better to instead actually change the method name to the alias. This is in principle easy: We have to allow function_name to be changed even if op array is otherwise shared (similar to static_variables). This means we need to addref/release the function_name separately, but I don't think there is a performance concern here (especially as everything is usually interned). There is a bit of complication in opcache, where we need to make sure that the function name is released the correct number of times (interning may overwrite the name in the original op_array, but we need to release it as many times as the op_array is shared). Fixes bug #69180. Fixes bug #74939. Closes GH-5226.
* | Automatically implement Stringable interfaceNikita Popov2020-03-021-4/+23
| |
* | Define Stringable with __toString():string methodNicolas Grekas2020-03-021-7/+12
| |
* | Avoid more null arithmeticNikita Popov2020-02-271-3/+3
| |
* | Use EX_NUM_TO_VAR() in more placesNikita Popov2020-02-271-2/+2
| | | | | | | | Not sure why I missed these before.
* | Deprecate required param after optionalNikita Popov2020-02-181-0/+15
| | | | | | | | | | | | | | | | As an exception, we allow "Type $foo = null" to occur before a required parameter, because this pattern was used as a replacement for nullable types in PHP versions older than 7.1. Closes GH-5067.