From 2efc33cb2b7199714036b5f4d6afd84537aeb706 Mon Sep 17 00:00:00 2001 From: Steffen Date: Fri, 4 Dec 2015 22:30:47 +0100 Subject: [PATCH] chore(ze2): Finally remove support for PHP5.3 and deprecate 5.4, #475 --- .travis.yml | 1 - .../Backends/ZendEngine2/StringsManager.php | 63 +--- Library/Operators/Other/ConcatOperator.php | 2 +- Library/Statements/Let/StaticProperty.php | 2 +- kernels/ZendEngine2/fcall.c | 342 +----------------- kernels/ZendEngine2/filter.c | 5 - kernels/ZendEngine2/globals.h | 16 +- kernels/ZendEngine2/hash.c | 24 -- kernels/ZendEngine2/hash.h | 20 - kernels/ZendEngine2/main.c | 8 - kernels/ZendEngine2/main.h | 7 - kernels/ZendEngine2/memory.c | 14 +- kernels/ZendEngine2/object.c | 102 +----- kernels/ZendEngine2/operators.c | 23 +- kernels/ZendEngine2/operators.h | 14 - kernels/ZendEngine2/output.c | 32 -- kernels/ZendEngine2/string.c | 21 -- kernels/ZendEngine2/string.h | 9 - 18 files changed, 11 insertions(+), 694 deletions(-) diff --git a/.travis.yml b/.travis.yml index 68ca8966c4..af56180c92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ env: secure: lRYAjibgHrvbte19lJCP2AhoGCR1asJlSNeF+QAn/ZYdd+J+StqK7DybaBbgk6cs7uodJ34OuGlOsAmE3B/EG4Qb/r+nbjEt7cA0+6+YyUs0sBpHoQ3XeFbZSSRsYvY0jKVn5/yl24GTobTTejc6MOW5N1/KErJynmylyW6q+Z4= php: - - 5.3 - 5.4 - 5.5 - 5.6 diff --git a/Library/Backends/ZendEngine2/StringsManager.php b/Library/Backends/ZendEngine2/StringsManager.php index dadf837a72..a940ee1c73 100644 --- a/Library/Backends/ZendEngine2/StringsManager.php +++ b/Library/Backends/ZendEngine2/StringsManager.php @@ -191,68 +191,7 @@ public function genConcatCode() $code .= "}" . PHP_EOL . PHP_EOL; } - $code .= <<getType() == 'variable' && $right->getType() == 'variable') { - $compilationContext->codePrinter->output('zephir_concat_function(' . $expectedCode . ', ' . $variableLeft . ', ' . $variableRight . ' TSRMLS_CC);'); + $compilationContext->codePrinter->output('zephir_concat_function(' . $expectedCode . ', ' . $variableLeft . ', ' . $variableRight . ');'); } $expected->setDynamicTypes('string'); diff --git a/Library/Statements/Let/StaticProperty.php b/Library/Statements/Let/StaticProperty.php index 663fa66336..a33ceb0fcd 100644 --- a/Library/Statements/Let/StaticProperty.php +++ b/Library/Statements/Let/StaticProperty.php @@ -256,7 +256,7 @@ public function assignStatic($className, $property, CompiledExpression $resolved $expression->compile($compilationContext); $variableVariableCode = $compilationContext->backend->getVariableCode($variableVariable); $tempVariableCode = $compilationContext->backend->getVariableCode($tempVariable); - $compilationContext->codePrinter->output('zephir_concat_function(' . $variableVariableCode . ', ' . $tempVariableCode . ', ' . $variableVariableCode .' TSRMLS_CC);'); + $compilationContext->codePrinter->output('zephir_concat_function(' . $variableVariableCode . ', ' . $tempVariableCode . ', ' . $variableVariableCode .');'); //continue case 'assign': diff --git a/kernels/ZendEngine2/fcall.c b/kernels/ZendEngine2/fcall.c index 2076fc4bca..9d41677a90 100644 --- a/kernels/ZendEngine2/fcall.c +++ b/kernels/ZendEngine2/fcall.c @@ -34,7 +34,6 @@ #include "kernel/exception.h" #include "kernel/backtrace.h" -#if PHP_VERSION_ID >= 50500 static const unsigned char tolower_map[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, @@ -53,7 +52,6 @@ static const unsigned char tolower_map[256] = { 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; -#endif int zephir_has_constructor_ce(const zend_class_entry *ce) { @@ -230,11 +228,8 @@ static ulong zephir_make_fcall_key(char **result, size_t *length, const zend_cla for (i = 0; i < l; ++i) { char c = buf[i]; -#if PHP_VERSION_ID >= 50500 c = tolower_map[(unsigned char)c]; -#else - c = tolower(c); -#endif + buf[i] = c; hash = (hash << 5) + hash + c; } @@ -336,11 +331,8 @@ static ulong zephir_make_fcall_info_key(char **result, size_t *length, const zen for (i = 0; i < l; ++i) { char c = buf[i]; -#if PHP_VERSION_ID >= 50500 c = tolower_map[(unsigned char)c]; -#else - c = tolower(c); -#endif + buf[i] = c; hash = (hash << 5) + hash + c; } @@ -990,336 +982,6 @@ int zephir_call_user_func_array_noex(zval *return_value, zval *handler, zval *pa return status; } -#if PHP_VERSION_ID <= 50309 - -/** - * Latest version of zend_throw_exception_internal - */ -static void zephir_throw_exception_internal(zval *exception TSRMLS_DC) -{ - if (exception != NULL) { - zval *previous = EG(exception); - zend_exception_set_previous(exception, EG(exception) TSRMLS_CC); - EG(exception) = exception; - if (previous) { - return; - } - } - - if (!EG(current_execute_data)) { - if (EG(exception)) { - zend_exception_error(EG(exception), E_ERROR TSRMLS_CC); - } - zend_error(E_ERROR, "Exception thrown without a stack frame"); - } - - if (zend_throw_exception_hook) { - zend_throw_exception_hook(exception TSRMLS_CC); - } - - if (EG(current_execute_data)->opline == NULL || - (EG(current_execute_data)->opline + 1)->opcode == ZEND_HANDLE_EXCEPTION) { - /* no need to rethrow the exception */ - return; - } - - EG(opline_before_exception) = EG(current_execute_data)->opline; - EG(current_execute_data)->opline = EG(exception_op); -} - -int zephir_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC) { - - zend_uint i; - zval **original_return_value; - HashTable *calling_symbol_table; - zend_op_array *original_op_array; - zend_op **original_opline_ptr; - zend_class_entry *current_scope; - zend_class_entry *current_called_scope; - zend_class_entry *calling_scope = NULL; - zend_class_entry *called_scope = NULL; - zval *current_this; - zend_execute_data execute_data; - - *fci->retval_ptr_ptr = NULL; - - if (!EG(active)) { - return FAILURE; /* executor is already inactive */ - } - - if (EG(exception)) { - return FAILURE; /* we would result in an instable executor otherwise */ - } - - switch (fci->size) { - case sizeof(zend_fcall_info): - break; /* nothing to do currently */ - default: - zend_error(E_ERROR, "Corrupted fcall_info provided to zephir_call_function()"); - break; - } - - /* Initialize execute_data */ - if (EG(current_execute_data)) { - execute_data = *EG(current_execute_data); - EX(op_array) = NULL; - EX(opline) = NULL; - EX(object) = NULL; - } else { - /* This only happens when we're called outside any execute()'s - * It shouldn't be strictly necessary to NULL execute_data out, - * but it may make bugs easier to spot - */ - memset(&execute_data, 0, sizeof(zend_execute_data)); - } - - if (!fci_cache || !fci_cache->initialized) { - - zend_fcall_info_cache fci_cache_local; - char *callable_name; - char *error = NULL; - - if (!fci_cache) { - fci_cache = &fci_cache_local; - } - - if (!zend_is_callable_ex(fci->function_name, fci->object_ptr, IS_CALLABLE_CHECK_SILENT, &callable_name, NULL, fci_cache, &error TSRMLS_CC)) { - if (error) { - zend_error(E_WARNING, "Invalid callback %s, %s", callable_name, error); - efree(error); - } - if (callable_name) { - efree(callable_name); - } - return FAILURE; - } else { - if (error) { - /* Capitalize the first latter of the error message */ - if (error[0] >= 'a' && error[0] <= 'z') { - error[0] += ('A' - 'a'); - } - zend_error(E_STRICT, "%s", error); - efree(error); - } - } - efree(callable_name); - } - - EX(function_state).function = fci_cache->function_handler; - calling_scope = fci_cache->calling_scope; - called_scope = fci_cache->called_scope; - fci->object_ptr = fci_cache->object_ptr; - EX(object) = fci->object_ptr; - if (fci->object_ptr && Z_TYPE_P(fci->object_ptr) == IS_OBJECT && (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(fci->object_ptr)].valid)) { - return FAILURE; - } - - #ifndef ZEPHIR_RELEASE - if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) { - zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name); - return FAILURE; - } - #endif - - ZEND_VM_STACK_GROW_IF_NEEDED(fci->param_count + 1); - - for (i = 0; i < fci->param_count; i++) { - zval *param; - - if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION - && (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 - && !ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1) - && PZVAL_IS_REF(*fci->params[i])) { - ALLOC_ZVAL(param); - *param = **(fci->params[i]); - INIT_PZVAL(param); - zval_copy_ctor(param); - } else if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1) - && !PZVAL_IS_REF(*fci->params[i])) { - - if (Z_REFCOUNT_PP(fci->params[i]) > 1) { - zval *new_zval; - - if (fci->no_separation && - !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) { - if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == EG(argument_stack)->top)) { - /* hack to clean up the stack */ - zend_vm_stack_push_nocheck((void *) (zend_uintptr_t)i TSRMLS_CC); - #if PHP_VERSION_ID <= 50500 - zend_vm_stack_clear_multiple(TSRMLS_C); - #else - zend_vm_stack_clear_multiple(0 TSRMLS_C); - #endif - } - - zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given", - i+1, - EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "", - EX(function_state).function->common.scope ? "::" : "", - EX(function_state).function->common.function_name); - return FAILURE; - } - - ALLOC_ZVAL(new_zval); - *new_zval = **fci->params[i]; - zval_copy_ctor(new_zval); - Z_SET_REFCOUNT_P(new_zval, 1); - Z_DELREF_PP(fci->params[i]); - *fci->params[i] = new_zval; - } - Z_ADDREF_PP(fci->params[i]); - Z_SET_ISREF_PP(fci->params[i]); - param = *fci->params[i]; - } else if (*fci->params[i] != &EG(uninitialized_zval)) { - Z_ADDREF_PP(fci->params[i]); - param = *fci->params[i]; - } else { - ALLOC_ZVAL(param); - *param = **(fci->params[i]); - INIT_PZVAL(param); - } - zend_vm_stack_push_nocheck(param TSRMLS_CC); - } - - EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); - zend_vm_stack_push_nocheck((void*)(zend_uintptr_t)fci->param_count TSRMLS_CC); - - current_scope = EG(scope); - EG(scope) = calling_scope; - - current_this = EG(This); - - current_called_scope = EG(called_scope); - if (called_scope) { - EG(called_scope) = called_scope; - } else { - if (EX(function_state).function->type != ZEND_INTERNAL_FUNCTION) { - EG(called_scope) = NULL; - } - } - - if (fci->object_ptr) { - if ((EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { - EG(This) = NULL; - } else { - EG(This) = fci->object_ptr; - - if (!PZVAL_IS_REF(EG(This))) { - Z_ADDREF_P(EG(This)); /* For $this pointer */ - } else { - zval *this_ptr; - - ALLOC_ZVAL(this_ptr); - *this_ptr = *EG(This); - INIT_PZVAL(this_ptr); - zval_copy_ctor(this_ptr); - EG(This) = this_ptr; - } - } - } else { - EG(This) = NULL; - } - - EX(prev_execute_data) = EG(current_execute_data); - EG(current_execute_data) = &execute_data; - - if (EX(function_state).function->type == ZEND_USER_FUNCTION) { - - calling_symbol_table = EG(active_symbol_table); - EG(scope) = EX(function_state).function->common.scope; - if (fci->symbol_table) { - EG(active_symbol_table) = fci->symbol_table; - } else { - EG(active_symbol_table) = NULL; - } - - original_return_value = EG(return_value_ptr_ptr); - original_op_array = EG(active_op_array); - EG(return_value_ptr_ptr) = fci->retval_ptr_ptr; - EG(active_op_array) = (zend_op_array *) EX(function_state).function; - original_opline_ptr = EG(opline_ptr); - zend_execute(EG(active_op_array) TSRMLS_CC); - if (!fci->symbol_table && EG(active_symbol_table)) { - if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { - zend_hash_destroy(EG(active_symbol_table)); - FREE_HASHTABLE(EG(active_symbol_table)); - } else { - /* clean before putting into the cache, since clean - could call dtors, which could use cached hash */ - zend_hash_clean(EG(active_symbol_table)); - *(++EG(symtable_cache_ptr)) = EG(active_symbol_table); - } - } - EG(active_symbol_table) = calling_symbol_table; - EG(active_op_array) = original_op_array; - EG(return_value_ptr_ptr)=original_return_value; - EG(opline_ptr) = original_opline_ptr; - } else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { - int call_via_handler = (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; - ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr); - if (EX(function_state).function->common.scope) { - EG(scope) = EX(function_state).function->common.scope; - } - - ((zend_internal_function *) EX(function_state).function)->handler(fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); - /* We shouldn't fix bad extensions here, - because it can break proper ones (Bug #34045) - if (!EX(function_state).function->common.return_reference) - { - INIT_PZVAL(*fci->retval_ptr_ptr); - }*/ - if (EG(exception) && fci->retval_ptr_ptr) { - zval_ptr_dtor(fci->retval_ptr_ptr); - *fci->retval_ptr_ptr = NULL; - } - - if (call_via_handler) { - /* We must re-initialize function again */ - fci_cache->initialized = 0; - } - } else { - ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr); - - if (fci->object_ptr) { - Z_OBJ_HT_P(fci->object_ptr)->call_method(EX(function_state).function->common.function_name, fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); - } else { - zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); - return FAILURE; - } - - if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { - efree(EX(function_state).function->common.function_name); - } - efree(EX(function_state).function); - - if (EG(exception) && fci->retval_ptr_ptr) { - zval_ptr_dtor(fci->retval_ptr_ptr); - *fci->retval_ptr_ptr = NULL; - } - } - - #if PHP_VERSION_ID <= 50500 - zend_vm_stack_clear_multiple(TSRMLS_C); - #else - zend_vm_stack_clear_multiple(0 TSRMLS_C); - #endif - - if (EG(This)) { - zval_ptr_dtor(&EG(This)); - } - EG(called_scope) = current_called_scope; - EG(scope) = current_scope; - EG(This) = current_this; - EG(current_execute_data) = EX(prev_execute_data); - - if (EG(exception)) { - zephir_throw_exception_internal(NULL TSRMLS_CC); - } - return SUCCESS; -} - -#endif - /** * If a retval_ptr is specified, PHP's implementation of zend_eval_stringl * simply prepends a "return " which causes only the first statement to be executed diff --git a/kernels/ZendEngine2/filter.c b/kernels/ZendEngine2/filter.c index 7d27658d13..b1c21f7322 100644 --- a/kernels/ZendEngine2/filter.c +++ b/kernels/ZendEngine2/filter.c @@ -353,12 +353,7 @@ void zephir_escape_htmlattr(zval *return_value, zval *param) { * Escapes HTML replacing special chars by entities */ void zephir_escape_html(zval *return_value, zval *str, zval *quote_style, zval *charset TSRMLS_DC) { - - #if PHP_VERSION_ID < 50400 - int length; - #else size_t length; - #endif char *escaped; diff --git a/kernels/ZendEngine2/globals.h b/kernels/ZendEngine2/globals.h index bc3a677d36..7e1d553504 100644 --- a/kernels/ZendEngine2/globals.h +++ b/kernels/ZendEngine2/globals.h @@ -67,11 +67,7 @@ typedef zend_function zephir_fcall_cache_entry; #endif -#if PHP_VERSION_ID >= 50400 - #define ZEPHIR_INIT_FUNCS(class_functions) static const zend_function_entry class_functions[] = -#else - #define ZEPHIR_INIT_FUNCS(class_functions) static const function_entry class_functions[] = -#endif +#define ZEPHIR_INIT_FUNCS(class_functions) static const zend_function_entry class_functions[] = #ifndef PHP_FE_END #define PHP_FE_END { NULL, NULL, NULL, 0, 0 } @@ -164,16 +160,6 @@ typedef zend_function zephir_fcall_cache_entry; # define ZEPHIR_NO_OPT #endif -/*#if PHP_VERSION_ID > 50399 -# define ZLK_DC , const struct _zend_literal* key -# define ZLK_CC , key -# define ZLK_NULL_CC , NULL -#else -# define ZLK_DC -# define ZLK_CC -# define ZLK_NULL_CC -#endif*/ - #ifdef ZTS #define zephir_nts_static #else diff --git a/kernels/ZendEngine2/hash.c b/kernels/ZendEngine2/hash.c index 0f75d42125..bc74f62d5a 100644 --- a/kernels/ZendEngine2/hash.c +++ b/kernels/ZendEngine2/hash.c @@ -30,10 +30,6 @@ int zephir_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent) { -#if PHP_VERSION_ID < 50400 - Bucket **tmp; -#endif - if (nSize >= 0x80000000) { ht->nTableSize = 0x80000000; } else { @@ -48,11 +44,7 @@ int zephir_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_ ht->inconsistent = 0; #endif -#if PHP_VERSION_ID < 50400 - ht->nTableMask = ht->nTableSize - 1; -#else ht->nTableMask = 0; /* 0 means that ht->arBuckets is uninitialized */ -#endif ht->pDestructor = pDestructor; ht->arBuckets = NULL; ht->pListHead = NULL; @@ -64,22 +56,6 @@ int zephir_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_ ht->nApplyCount = 0; ht->bApplyProtection = 1; -#if PHP_VERSION_ID < 50400 - /* Uses ecalloc() so that Bucket* == NULL */ - if (persistent) { - tmp = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *)); - if (!tmp) { - return FAILURE; - } - ht->arBuckets = tmp; - } else { - tmp = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *)); - if (tmp) { - ht->arBuckets = tmp; - } - } -#endif - return SUCCESS; } diff --git a/kernels/ZendEngine2/hash.h b/kernels/ZendEngine2/hash.h index ab9dc665ce..5cd5cbb30a 100644 --- a/kernels/ZendEngine2/hash.h +++ b/kernels/ZendEngine2/hash.h @@ -40,8 +40,6 @@ int zephir_hash_unset(HashTable *ht, zval *offset); #define zephir_hash_move_forward_ex(ht, pos) *pos = (*pos ? (*pos)->pListNext : NULL) -#if PHP_VERSION_ID < 70000 - static zend_always_inline int zephir_hash_get_current_data_ex(HashTable *ht, void **pData, HashPosition *pos) { Bucket *p; @@ -54,24 +52,6 @@ static zend_always_inline int zephir_hash_get_current_data_ex(HashTable *ht, voi } } -#else - -static zend_always_inline zval *zephir_hash_get_current_data_ex(HashTable *ht, HashPosition *pos) -{ - uint idx = *pos; - Bucket *p; - - IS_CONSISTENT(ht); - if (idx != INVALID_IDX) { - p = ht->arData + idx; - return &p->val; - } else { - return NULL; - } -} - -#endif - static zend_always_inline int zephir_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) { #if PHP_VERSION_ID < 70000 diff --git a/kernels/ZendEngine2/main.c b/kernels/ZendEngine2/main.c index e39782e98b..64dbbeb80d 100644 --- a/kernels/ZendEngine2/main.c +++ b/kernels/ZendEngine2/main.c @@ -53,17 +53,9 @@ zend_class_entry *zephir_register_internal_interface_ex(zend_class_entry *orig_c * Initilializes super global variables if doesn't */ int zephir_init_global(char *global, unsigned int global_length TSRMLS_DC) { - - #if PHP_VERSION_ID < 50400 - zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays)); - if (jit_initialization) { - return zend_is_auto_global(global, global_length - 1 TSRMLS_CC); - } - #else if (PG(auto_globals_jit)) { return zend_is_auto_global(global, global_length - 1 TSRMLS_CC); } - #endif return SUCCESS; } diff --git a/kernels/ZendEngine2/main.h b/kernels/ZendEngine2/main.h index 4069a5b6e5..ec70ce0799 100644 --- a/kernels/ZendEngine2/main.h +++ b/kernels/ZendEngine2/main.h @@ -470,13 +470,6 @@ static inline char *_str_erealloc(char *str, size_t new_len, size_t old_len) { lower_ns## _ ##lcname## _ce->ce_flags |= flags; \ } -#if PHP_VERSION_ID < 50399 - #define object_properties_init(object, class_type) { \ - ALLOC_HASHTABLE_REL(object->properties); \ - zend_hash_init(object->properties, zend_hash_num_elements(&class_type->default_properties), NULL, ZVAL_PTR_DTOR, 0); \ - zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); \ - } -#endif #define ZEPHIR_CREATE_OBJECT(obj_ptr, class_type) \ { \ zend_object *object; \ diff --git a/kernels/ZendEngine2/memory.c b/kernels/ZendEngine2/memory.c index f61e824209..30ab3988c2 100644 --- a/kernels/ZendEngine2/memory.c +++ b/kernels/ZendEngine2/memory.c @@ -130,16 +130,10 @@ static void zephir_memory_restore_stack_common(zend_zephir_globals_def *g TSRMLS for (i = 0; i < active_memory->pointer; ++i) { if (active_memory->addresses[i] != NULL && *(active_memory->addresses[i]) != NULL) { zval **var = active_memory->addresses[i]; -#if PHP_VERSION_ID < 50400 - if (Z_TYPE_PP(var) > IS_CONSTANT_ARRAY) { - fprintf(stderr, "%s: observed variable #%d (%p) has invalid type %u [%s]\n", __func__, (int)i, *var, Z_TYPE_PP(var), active_memory->func); - } -#else + if (Z_TYPE_PP(var) > IS_CALLABLE) { fprintf(stderr, "%s: observed variable #%d (%p) has invalid type %u [%s]\n", __func__, (int)i, *var, Z_TYPE_PP(var), active_memory->func); } -#endif - if (Z_REFCOUNT_PP(var) == 0) { fprintf(stderr, "%s: observed variable #%d (%p) has 0 references, type=%d [%s]\n", __func__, (int)i, *var, Z_TYPE_PP(var), active_memory->func); } @@ -443,15 +437,9 @@ int zephir_cleanup_fcache(void *pDest TSRMLS_DC, int num_args, va_list args, zen } #endif -#if PHP_VERSION_ID >= 50400 if (scope && scope->type == ZEND_INTERNAL_CLASS && scope->info.internal.module->type != MODULE_PERSISTENT) { return ZEND_HASH_APPLY_REMOVE; } -#else - if (scope && scope->type == ZEND_INTERNAL_CLASS && scope->module->type != MODULE_PERSISTENT) { - return ZEND_HASH_APPLY_REMOVE; - } -#endif return ZEND_HASH_APPLY_KEEP; } diff --git a/kernels/ZendEngine2/object.c b/kernels/ZendEngine2/object.c index efa09566b1..d007478af1 100644 --- a/kernels/ZendEngine2/object.c +++ b/kernels/ZendEngine2/object.c @@ -329,11 +329,7 @@ int zephir_class_exists(const zval *class_name, int autoload TSRMLS_DC) { if (Z_TYPE_P(class_name) == IS_STRING) { if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &ce TSRMLS_CC) == SUCCESS) { -#if PHP_VERSION_ID < 50400 - return (((*ce)->ce_flags & ZEND_ACC_INTERFACE) == 0); -#else return ((*ce)->ce_flags & (ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT - ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) == 0; -#endif } return 0; } @@ -499,11 +495,7 @@ int zephir_read_property(zval **result, zval *object, const char *property_name, EG(scope) = ce; if (!Z_OBJ_HT_P(object)->read_property) { -#if PHP_VERSION_ID < 50400 - char *class_name; -#else const char *class_name; -#endif zend_uint class_name_len; zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC); @@ -513,11 +505,7 @@ int zephir_read_property(zval **result, zval *object, const char *property_name, MAKE_STD_ZVAL(property); ZVAL_STRINGL(property, property_name, property_length, 0); -#if PHP_VERSION_ID < 50400 - *result = Z_OBJ_HT_P(object)->read_property(object, property, silent ? BP_VAR_IS : BP_VAR_R TSRMLS_CC); -#else *result = Z_OBJ_HT_P(object)->read_property(object, property, silent ? BP_VAR_IS : BP_VAR_R, 0 TSRMLS_CC); -#endif Z_ADDREF_PP(result); @@ -553,16 +541,6 @@ zval* zephir_fetch_property_this_quick(zval *object, const char *property_name, zobj = zend_objects_get_address(object TSRMLS_CC); if (zephir_hash_quick_find(&ce->properties_info, property_name, property_length + 1, key, (void **) &property_info) == SUCCESS) { - - #if PHP_VERSION_ID < 50400 - - if (zephir_hash_quick_find(zobj->properties, property_info->name, property_info->name_length + 1, property_info->h, (void **) &zv) == SUCCESS) { - EG(scope) = old_scope; - return *zv; - } - - #else - int flag; if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && property_info->offset >= 0) { if (zobj->properties) { @@ -593,9 +571,6 @@ zval* zephir_fetch_property_this_quick(zval *object, const char *property_name, EG(scope) = old_scope; return *zv; } - - #endif - } EG(scope) = old_scope; @@ -632,27 +607,6 @@ int zephir_return_property_quick(zval *return_value, zval **return_value_ptr, zv zobj = zend_objects_get_address(object TSRMLS_CC); if (zephir_hash_quick_find(&ce->properties_info, property_name, property_length + 1, key, (void **) &property_info) == SUCCESS) { - - #if PHP_VERSION_ID < 50400 - - if (zephir_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &zv) == SUCCESS) { - - EG(scope) = old_scope; - - if (return_value_ptr) { - zval_ptr_dtor(return_value_ptr); - Z_ADDREF_PP(zv); - *return_value_ptr = *zv; - } - else { - ZVAL_ZVAL(return_value, *zv, 1, 0); - } - - return SUCCESS; - } - - #else - int flag; if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && property_info->offset >= 0) { if (zobj->properties) { @@ -693,9 +647,6 @@ int zephir_return_property_quick(zval *return_value, zval **return_value_ptr, zv return SUCCESS; } - - #endif - } EG(scope) = old_scope; @@ -807,11 +758,7 @@ int zephir_update_property_zval(zval *object, const char *property_name, unsigne EG(scope) = ce; if (!Z_OBJ_HT_P(object)->write_property) { -#if PHP_VERSION_ID < 50400 - char *class_name; -#else const char *class_name; -#endif zend_uint class_name_len; zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC); @@ -821,11 +768,7 @@ int zephir_update_property_zval(zval *object, const char *property_name, unsigne MAKE_STD_ZVAL(property); ZVAL_STRINGL(property, property_name, property_length, 0); -#if PHP_VERSION_ID < 50400 - Z_OBJ_HT_P(object)->write_property(object, property, value TSRMLS_CC); -#else Z_OBJ_HT_P(object)->write_property(object, property, value, 0 TSRMLS_CC); -#endif if (Z_REFCOUNT_P(property) > 1) { ZVAL_STRINGL(property, property_name, property_length, 1); @@ -861,33 +804,6 @@ int zephir_update_property_this_quick(zval *object, const char *property_name, z old_scope = EG(scope); EG(scope) = ce; - #if PHP_VERSION_ID < 50400 - - { - zval *property; - - if (!Z_OBJ_HT_P(object)->write_property) { - EG(scope) = old_scope; - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property %s of class %s cannot be updated", property_name, ce->name); - return FAILURE; - } - - MAKE_STD_ZVAL(property); - ZVAL_STRINGL(property, property_name, property_length, 0); - - Z_OBJ_HT_P(object)->write_property(object, property, value TSRMLS_CC); - - if (Z_REFCOUNT_P(property) > 1) { - ZVAL_STRINGL(property, property_name, property_length, 1); - } else { - ZVAL_NULL(property); - } - - zval_ptr_dtor(&property); - } - - #else - { zend_object *zobj; zval **variable_ptr; @@ -938,8 +854,6 @@ int zephir_update_property_this_quick(zval *object, const char *property_name, z } } - #endif - EG(scope) = old_scope; return SUCCESS; @@ -1229,11 +1143,7 @@ int zephir_unset_property(zval* object, const char* name TSRMLS_DC) old_scope = EG(scope); EG(scope) = Z_OBJCE_P(object); - #if PHP_VERSION_ID < 50400 - Z_OBJ_HT_P(object)->unset_property(object, &member TSRMLS_CC); - #else - Z_OBJ_HT_P(object)->unset_property(object, &member, 0 TSRMLS_CC); - #endif + Z_OBJ_HT_P(object)->unset_property(object, &member, 0 TSRMLS_CC); EG(scope) = old_scope; @@ -1352,7 +1262,6 @@ int zephir_read_static_property_ce(zval **result, zend_class_entry *ce, const ch return FAILURE; } -#if PHP_VERSION_ID >= 50400 static zval **zephir_std_get_static_property(zend_class_entry *ce, const char *property_name, int property_name_len, ulong hash_value, zend_bool silent, zend_property_info ** property_info TSRMLS_DC) { @@ -1406,7 +1315,6 @@ static zval **zephir_std_get_static_property(zend_class_entry *ce, const char *p return &CE_STATIC_MEMBERS(ce)[temp_property_info->offset]; } -#endif static int zephir_update_static_property_ex(zend_class_entry *scope, const char *name, int name_length, zval **value, zend_property_info **property_info TSRMLS_DC) { @@ -1444,11 +1352,7 @@ static int zephir_update_static_property_ex(zend_class_entry *scope, const char } EG(scope) = scope; -#if PHP_VERSION_ID < 50400 - property = zend_std_get_static_property(scope, name, name_length, 0 TSRMLS_CC); -#else property = zephir_std_get_static_property(scope, name, name_length, zend_inline_hash_func(name, name_length + 1), 0, property_info TSRMLS_CC); -#endif EG(scope) = old_scope; if (!property) { @@ -1821,10 +1725,6 @@ int zephir_create_closure_ex(zval *return_value, zval *this_ptr, zend_class_entr return FAILURE; } -#if PHP_VERSION_ID < 50400 - zend_create_closure(return_value, function_ptr TSRMLS_CC); -#else zend_create_closure(return_value, function_ptr, ce, this_ptr TSRMLS_CC); -#endif return SUCCESS; } diff --git a/kernels/ZendEngine2/operators.c b/kernels/ZendEngine2/operators.c index bf30db3ae8..d1839a1aed 100644 --- a/kernels/ZendEngine2/operators.c +++ b/kernels/ZendEngine2/operators.c @@ -372,11 +372,8 @@ int zephir_add_function_ex(zval *result, zval *op1, zval *op2 TSRMLS_DC) { int status; int ref_count = Z_REFCOUNT_P(result); int is_ref = Z_ISREF_P(result); -#if PHP_VERSION_ID < 50400 - status = add_function(result, op1, op2 TSRMLS_CC); -#else + status = fast_add_function(result, op1, op2 TSRMLS_CC); -#endif Z_SET_REFCOUNT_P(result, ref_count); Z_SET_ISREF_TO_P(result, is_ref); return status; @@ -448,9 +445,7 @@ long zephir_get_intval_ex(const zval *op) { return zend_hash_num_elements(Z_ARRVAL_P(op)) ? 1 : 0; break; -#if PHP_VERSION_ID > 50400 case IS_CALLABLE: -#endif case IS_RESOURCE: case IS_OBJECT: return 1; @@ -497,9 +492,8 @@ double zephir_get_doubleval_ex(const zval *op) { case IS_ARRAY: return zend_hash_num_elements(Z_ARRVAL_P(op)) ? (double) 1 : 0; break; -#if PHP_VERSION_ID > 50400 + case IS_CALLABLE: -#endif case IS_RESOURCE: case IS_OBJECT: return (double) 1; @@ -539,9 +533,8 @@ zend_bool zephir_get_boolval_ex(const zval *op) { case IS_ARRAY: return zend_hash_num_elements(Z_ARRVAL_P(op)) ? (zend_bool) 1 : 0; break; -#if PHP_VERSION_ID > 50400 + case IS_CALLABLE: -#endif case IS_RESOURCE: case IS_OBJECT: return (zend_bool) 1; @@ -598,12 +591,7 @@ int zephir_is_numeric_ex(const zval *op) { */ int zephir_is_equal(zval *op1, zval *op2 TSRMLS_DC) { zval result; - #if PHP_VERSION_ID < 50400 - is_equal_function(&result, op1, op2 TSRMLS_CC); - return Z_BVAL(result); - #else return fast_equal_function(&result, op1, op2 TSRMLS_CC); - #endif } /** @@ -611,12 +599,7 @@ int zephir_is_equal(zval *op1, zval *op2 TSRMLS_DC) { */ int zephir_less(zval *op1, zval *op2 TSRMLS_DC) { zval result; - #if PHP_VERSION_ID < 50400 - is_smaller_function(&result, op1, op2 TSRMLS_CC); - return Z_BVAL(result); - #else return fast_is_smaller_function(&result, op1, op2 TSRMLS_CC); - #endif } /** diff --git a/kernels/ZendEngine2/operators.h b/kernels/ZendEngine2/operators.h index 9878e3bbed..3168cc8ea7 100644 --- a/kernels/ZendEngine2/operators.h +++ b/kernels/ZendEngine2/operators.h @@ -71,27 +71,13 @@ #define ZEPHIR_STRING_OFFSET(op1, index) ((index >= 0 && index < Z_STRLEN_P(op1)) ? Z_STRVAL_P(op1)[index] : '\0') -#if PHP_VERSION_ID < 50400 -#define zephir_increment(var) increment_function(var) -#else #define zephir_increment(var) fast_increment_function(var) -#endif - -#if PHP_VERSION_ID < 50400 -#define zephir_decrement(var) decrement_function(var) -#else #define zephir_decrement(var) fast_decrement_function(var) -#endif void zephir_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy); #define zephir_add_function(result, left, right) zephir_add_function_ex(result, left, right TSRMLS_CC) - -#if PHP_VERSION_ID < 50400 -#define zephir_sub_function(result, left, right) sub_function(result, left, right TSRMLS_CC) -#else #define zephir_sub_function(result, left, right) fast_sub_function(result, left, right TSRMLS_CC) -#endif #if PHP_VERSION_ID < 50600 void zephir_pow_function_ex(zval *return_value, zval *zbase, zval *zexp TSRMLS_DC); diff --git a/kernels/ZendEngine2/output.c b/kernels/ZendEngine2/output.c index 5bcf8dcfd3..1721409ca4 100644 --- a/kernels/ZendEngine2/output.c +++ b/kernels/ZendEngine2/output.c @@ -32,20 +32,12 @@ void zephir_ob_start(TSRMLS_D) { -#if PHP_VERSION_ID < 50400 - php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC); -#else php_output_start_default(TSRMLS_C); -#endif } void zephir_ob_get_contents(zval *result TSRMLS_DC) { -#if PHP_VERSION_ID < 50400 - php_ob_get_buffer(result TSRMLS_CC); -#else php_output_get_contents(result TSRMLS_CC); -#endif } int zephir_ob_end_flush(TSRMLS_D) @@ -55,12 +47,7 @@ int zephir_ob_end_flush(TSRMLS_D) return FAILURE; } -#if PHP_VERSION_ID < 50400 - php_end_ob_buffer(1, 0 TSRMLS_CC); - return SUCCESS; -#else return php_output_end(TSRMLS_C); -#endif } int zephir_ob_end_clean(TSRMLS_D) @@ -70,12 +57,7 @@ int zephir_ob_end_clean(TSRMLS_D) return FAILURE; } -#if PHP_VERSION_ID < 50400 - php_end_ob_buffer(0, 0 TSRMLS_CC); - return SUCCESS; -#else return php_output_discard(TSRMLS_C); -#endif } int zephir_ob_flush(TSRMLS_D) @@ -85,12 +67,7 @@ int zephir_ob_flush(TSRMLS_D) return FAILURE; } -#if PHP_VERSION_ID < 50400 - php_end_ob_buffer(1, 1 TSRMLS_CC); - return SUCCESS; -#else return php_output_flush(TSRMLS_C); -#endif } int zephir_ob_clean(TSRMLS_D) @@ -100,19 +77,10 @@ int zephir_ob_clean(TSRMLS_D) return FAILURE; } -#if PHP_VERSION_ID < 50400 - php_end_ob_buffer(0, 1 TSRMLS_CC); - return SUCCESS; -#else return php_output_clean(TSRMLS_C); -#endif } int zephir_ob_get_level(TSRMLS_D) { -#if PHP_VERSION_ID < 50400 - return OG(ob_nesting_level); -#else return php_output_get_level(TSRMLS_C); -#endif } diff --git a/kernels/ZendEngine2/string.c b/kernels/ZendEngine2/string.c index e409cca0ac..c83888661b 100644 --- a/kernels/ZendEngine2/string.c +++ b/kernels/ZendEngine2/string.c @@ -1456,11 +1456,7 @@ int zephir_http_build_query(zval *return_value, zval *params, char *sep TSRMLS_D smart_str formstr = { NULL, 0, 0 }; int res; -#if PHP_VERSION_ID < 50400 - res = php_url_encode_hash_ex(HASH_OF(params), &formstr, NULL, 0, NULL, 0, NULL, 0, (Z_TYPE_P(params) == IS_OBJECT ? params : NULL), sep TSRMLS_CC); -#else res = php_url_encode_hash_ex(HASH_OF(params), &formstr, NULL, 0, NULL, 0, NULL, 0, (Z_TYPE_P(params) == IS_OBJECT ? params : NULL), sep, PHP_QUERY_RFC1738 TSRMLS_CC); -#endif if (res == SUCCESS) { if (!formstr.c) { @@ -1488,11 +1484,7 @@ void zephir_htmlspecialchars(zval *return_value, zval *string, zval *quoting, zv zval copy; char *escaped, *cs; int qs, use_copy = 0; -#if PHP_VERSION_ID < 50400 - int escaped_len; -#else size_t escaped_len; -#endif if (unlikely(Z_TYPE_P(string) != IS_STRING)) { zend_make_printable_zval(string, ©, &use_copy); @@ -1517,11 +1509,7 @@ void zephir_htmlentities(zval *return_value, zval *string, zval *quoting, zval * zval copy; char *escaped, *cs; int qs, use_copy = 0; -#if PHP_VERSION_ID < 50400 - int escaped_len; -#else size_t escaped_len; -#endif if (unlikely(Z_TYPE_P(string) != IS_STRING)) { zend_make_printable_zval(string, ©, &use_copy); @@ -1638,12 +1626,3 @@ void zephir_stripcslashes(zval *return_value, zval *str TSRMLS_DC) zval_dtor(©); } } - -#if PHP_VERSION_ID < 50400 - -const char* zend_new_interned_string(const char *arKey, int nKeyLength, int free_src TSRMLS_DC) -{ - return arKey; -} - -#endif diff --git a/kernels/ZendEngine2/string.h b/kernels/ZendEngine2/string.h index aecea8f0c7..cafb042083 100644 --- a/kernels/ZendEngine2/string.h +++ b/kernels/ZendEngine2/string.h @@ -107,13 +107,6 @@ void zephir_addslashes(zval *return_value, zval *str TSRMLS_DC); void zephir_stripslashes(zval *return_value, zval *str TSRMLS_DC); void zephir_stripcslashes(zval *return_value, zval *str TSRMLS_DC); -#if PHP_VERSION_ID < 50400 - -const char* zend_new_interned_string(const char *arKey, int nKeyLength, int free_src TSRMLS_DC); -#define ZEPHIR_ZVAL_MAYBE_INTERNED_STRING(pz, string) ZVAL_STRING(pz, string, 1); - -#else - #define ZEPHIR_ZVAL_MAYBE_INTERNED_STRING(pz, string) \ do { \ if (IS_INTERNED(string)) { \ @@ -124,6 +117,4 @@ const char* zend_new_interned_string(const char *arKey, int nKeyLength, int free } \ } while (0) -#endif /* PHP_VERSION_ID < 50400 */ - #endif /* ZEPHIR_KERNEL_STRING_H */