diff --git a/Library/Optimizers/FunctionCall/IsPhpVersionOptimizer.php b/Library/Optimizers/FunctionCall/IsPhpVersionOptimizer.php new file mode 100644 index 0000000000..e05ed4a022 --- /dev/null +++ b/Library/Optimizers/FunctionCall/IsPhpVersionOptimizer.php @@ -0,0 +1,67 @@ + 1) zval_copy_ctor(param); else ZVAL_NULL(param); } while(0) #else diff --git a/ext/kernel/main.h b/ext/kernel/main.h index 936483008f..40e3c6ad3d 100644 --- a/ext/kernel/main.h +++ b/ext/kernel/main.h @@ -539,4 +539,6 @@ static inline char *_str_erealloc(char *str, size_t new_len, size_t old_len) { #define ZEPHIR_CHECK_POINTER(v) if (!v) fprintf(stderr, "%s:%d\n", __PRETTY_FUNCTION__, __LINE__); +#define zephir_is_php_version(id) ((PHP_VERSION_ID >= id && PHP_VERSION_ID <= (id + 10000)) ? 1 : 0) + #endif /* ZEPHIR_KERNEL_MAIN_H */ diff --git a/ext/kernel/object.c b/ext/kernel/object.c index 4f7d797b2f..a49a70b72f 100644 --- a/ext/kernel/object.c +++ b/ext/kernel/object.c @@ -1919,6 +1919,7 @@ int zephir_create_instance(zval *return_value, const zval *class_name TSRMLS_DC) ce = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); if (!ce) { + ZVAL_NULL(return_value); return FAILURE; } @@ -1950,6 +1951,7 @@ int zephir_create_instance_params(zval *return_value, const zval *class_name, zv ce = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); if (!ce) { + ZVAL_NULL(return_value); return FAILURE; } @@ -1969,21 +1971,19 @@ int zephir_create_instance_params(zval *return_value, const zval *class_name, zv if (likely(param_count) <= 10) { params_ptr = static_params; - } - else { + } else { params_arr = emalloc(param_count * sizeof(zval*)); params_ptr = ¶ms; } for ( zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(params), &pos); - zend_hash_get_current_data_ex(Z_ARRVAL_P(params), (void**)&item, &pos) == SUCCESS; + zend_hash_get_current_data_ex(Z_ARRVAL_P(params), (void**) &item, &pos) == SUCCESS; zend_hash_move_forward_ex(Z_ARRVAL_P(params), &pos), ++i ) { params_ptr[i] = *item; } - } - else { + } else { params_ptr = NULL; } diff --git a/unit-tests/Extension/BuiltIn/CharMethodTest.php b/unit-tests/Extension/BuiltIn/CharMethodTest.php index 3e5dd60436..6353f29dbb 100644 --- a/unit-tests/Extension/BuiltIn/CharMethodTest.php +++ b/unit-tests/Extension/BuiltIn/CharMethodTest.php @@ -27,7 +27,7 @@ public function testModifications() { $t = new CharMethods(); - //$this->assertEquals('61', $t->getHex()); - //$this->assertEquals('68656C6C6F', $t->getHexForString('hello')); + $this->assertEquals('61', $t->getHex()); + $this->assertEquals('68656C6C6F', $t->getHexForString('hello')); } }