+
+#include "kernel/main.h"
+#include "kernel/object.h"
+#include "kernel/memory.h"
+#include "kernel/fcall.h"
+#include "kernel/array.h"
+#include "kernel/exception.h"
+#include "ext/spl/spl_exceptions.h"
+#include "kernel/operators.h"
+
+
+/**
+ * Service is intermediary between Model and Controller.
+ *
+ * @package Ice/Mvc
+ * @category Component
+ * @author Ice Team
+ * @copyright (c) 2014-2015 Ice Team
+ * @license http://iceframework.org/license
+ */
+ZEPHIR_INIT_CLASS(Ice_Mvc_Service) {
+
+ ZEPHIR_REGISTER_CLASS_EX(Ice\\Mvc, Service, ice, mvc_service, ice_di_access_ce, ice_mvc_service_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
+
+ zend_declare_property_null(ice_mvc_service_ce, SL("model"), ZEND_ACC_PRIVATE TSRMLS_CC);
+
+ return SUCCESS;
+
+}
+
+PHP_METHOD(Ice_Mvc_Service, setModel) {
+
+ zval *model;
+
+ zephir_fetch_params(0, 1, 0, &model);
+
+
+
+ zephir_update_property_this(this_ptr, SL("model"), model TSRMLS_CC);
+
+}
+
+PHP_METHOD(Ice_Mvc_Service, getModel) {
+
+
+ RETURN_MEMBER(this_ptr, "model");
+
+}
+
+/**
+ * Controller constructor. Run onConstruct() if method exist.
+ */
+PHP_METHOD(Ice_Mvc_Service, __construct) {
+
+ int ZEPHIR_LAST_CALL_STATUS;
+ zephir_fcall_cache_entry *_0 = NULL;
+
+ ZEPHIR_MM_GROW();
+
+ ZEPHIR_CALL_PARENT(NULL, ice_mvc_service_ce, this_ptr, "__construct", &_0, 29);
+ zephir_check_call_status();
+ if ((zephir_method_exists_ex(this_ptr, SS("onconstruct") TSRMLS_CC) == SUCCESS)) {
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0);
+ zephir_check_call_status();
+ }
+ ZEPHIR_MM_RESTORE();
+
+}
+
+/**
+ * Magic method to call model's method.
+ *
+ * @param string method
+ * @param mixed arguments
+ * @return mixed
+ */
+PHP_METHOD(Ice_Mvc_Service, __call) {
+
+ zval *_3;
+ int ZEPHIR_LAST_CALL_STATUS;
+ zend_bool _1;
+ zval *method_param = NULL, *arguments = NULL, *_0, *_2, *_4;
+ zval *method = NULL;
+
+ ZEPHIR_MM_GROW();
+ zephir_fetch_params(1, 1, 1, &method_param, &arguments);
+
+ if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) {
+ zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC);
+ RETURN_MM_NULL();
+ }
+ if (likely(Z_TYPE_P(method_param) == IS_STRING)) {
+ zephir_get_strval(method, method_param);
+ } else {
+ ZEPHIR_INIT_VAR(method);
+ ZVAL_EMPTY_STRING(method);
+ }
+ if (!arguments) {
+ arguments = ZEPHIR_GLOBAL(global_null);
+ }
+
+
+ ZEPHIR_OBS_VAR(_0);
+ zephir_read_property_this(&_0, this_ptr, SL("model"), PH_NOISY_CC);
+ _1 = Z_TYPE_P(_0) == IS_OBJECT;
+ if (_1) {
+ ZEPHIR_OBS_VAR(_2);
+ zephir_read_property_this(&_2, this_ptr, SL("model"), PH_NOISY_CC);
+ _1 = zephir_instance_of_ev(_2, ice_mvc_model_ce TSRMLS_CC);
+ }
+ if (_1) {
+ ZEPHIR_INIT_VAR(_3);
+ zephir_create_array(_3, 2, 0 TSRMLS_CC);
+ ZEPHIR_OBS_VAR(_4);
+ zephir_read_property_this(&_4, this_ptr, SL("model"), PH_NOISY_CC);
+ zephir_array_fast_append(_3, _4);
+ zephir_array_fast_append(_3, method);
+ ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _3, arguments);
+ zephir_check_call_status();
+ RETURN_MM();
+ } else {
+ ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "The `model` property must be instance of Model", "ice/mvc/service.zep", 45);
+ return;
+ }
+
+}
+
diff --git a/ext/ice/mvc/service.zep.h b/ext/ice/mvc/service.zep.h
new file mode 100644
index 00000000..b5933314
--- /dev/null
+++ b/ext/ice/mvc/service.zep.h
@@ -0,0 +1,26 @@
+
+extern zend_class_entry *ice_mvc_service_ce;
+
+ZEPHIR_INIT_CLASS(Ice_Mvc_Service);
+
+PHP_METHOD(Ice_Mvc_Service, setModel);
+PHP_METHOD(Ice_Mvc_Service, getModel);
+PHP_METHOD(Ice_Mvc_Service, __construct);
+PHP_METHOD(Ice_Mvc_Service, __call);
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_service_setmodel, 0, 0, 1)
+ ZEND_ARG_INFO(0, model)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_service___call, 0, 0, 1)
+ ZEND_ARG_INFO(0, method)
+ ZEND_ARG_INFO(0, arguments)
+ZEND_END_ARG_INFO()
+
+ZEPHIR_INIT_FUNCS(ice_mvc_service_method_entry) {
+ PHP_ME(Ice_Mvc_Service, setModel, arginfo_ice_mvc_service_setmodel, ZEND_ACC_PUBLIC)
+ PHP_ME(Ice_Mvc_Service, getModel, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Ice_Mvc_Service, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL|ZEND_ACC_CTOR)
+ PHP_ME(Ice_Mvc_Service, __call, arginfo_ice_mvc_service___call, ZEND_ACC_PUBLIC)
+ PHP_FE_END
+};
diff --git a/ext/ice/mvc/url.zep.c b/ext/ice/mvc/url.zep.c
index 42638cfa..efc1db75 100644
--- a/ext/ice/mvc/url.zep.c
+++ b/ext/ice/mvc/url.zep.c
@@ -17,8 +17,8 @@
#include "kernel/concat.h"
#include "kernel/fcall.h"
#include "kernel/operators.h"
-#include "kernel/array.h"
#include "kernel/string.h"
+#include "kernel/array.h"
/**
@@ -34,9 +34,9 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Url) {
ZEPHIR_REGISTER_CLASS(Ice\\Mvc, Url, ice, mvc_url, ice_mvc_url_method_entry, 0);
- zend_declare_property_string(ice_mvc_url_ce, SL("_baseUri"), "/", ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_string(ice_mvc_url_ce, SL("baseUri"), "/", ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_string(ice_mvc_url_ce, SL("_staticUri"), "/", ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_string(ice_mvc_url_ce, SL("staticUri"), "/", ZEND_ACC_PROTECTED TSRMLS_CC);
return SUCCESS;
@@ -45,7 +45,7 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Url) {
PHP_METHOD(Ice_Mvc_Url, getBaseUri) {
- RETURN_MEMBER(this_ptr, "_baseUri");
+ RETURN_MEMBER(this_ptr, "baseUri");
}
@@ -57,14 +57,14 @@ PHP_METHOD(Ice_Mvc_Url, setBaseUri) {
- zephir_update_property_this(this_ptr, SL("_baseUri"), baseUri TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("baseUri"), baseUri TSRMLS_CC);
}
PHP_METHOD(Ice_Mvc_Url, getStaticUri) {
- RETURN_MEMBER(this_ptr, "_staticUri");
+ RETURN_MEMBER(this_ptr, "staticUri");
}
@@ -76,7 +76,7 @@ PHP_METHOD(Ice_Mvc_Url, setStaticUri) {
- zephir_update_property_this(this_ptr, SL("_staticUri"), staticUri TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("staticUri"), staticUri TSRMLS_CC);
}
@@ -103,7 +103,7 @@ PHP_METHOD(Ice_Mvc_Url, getStatic) {
}
- ZEPHIR_CALL_METHOD(&_0, this_ptr, "getstaticuri", NULL);
+ ZEPHIR_CALL_METHOD(&_0, this_ptr, "getstaticuri", NULL, 0);
zephir_check_call_status();
ZEPHIR_CONCAT_VV(return_value, _0, uri);
RETURN_MM();
@@ -121,11 +121,11 @@ PHP_METHOD(Ice_Mvc_Url, getStatic) {
PHP_METHOD(Ice_Mvc_Url, get) {
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_4 = NULL, *_7 = NULL;
- zend_bool local, _5;
- zval *uri = NULL, *args = NULL, *local_param = NULL, *baseUri = NULL, *matched = NULL, *queryString = NULL, _0 = zval_used_for_init, *_1 = NULL, *_3 = NULL, *_GET, *_6 = NULL, *_8;
+ zend_bool local, _0, _4;
+ zval *uri = NULL, *args = NULL, *local_param = NULL, *baseUri = NULL, *matched = NULL, *queryString = NULL, _1 = zval_used_for_init, *_2 = NULL, *_3, *_GET, *_5 = NULL, *_6, *_7;
ZEPHIR_MM_GROW();
+ zephir_get_global(&_GET, SS("_GET") TSRMLS_CC);
zephir_fetch_params(1, 0, 3, &uri, &args, &local_param);
if (!uri) {
@@ -143,17 +143,21 @@ PHP_METHOD(Ice_Mvc_Url, get) {
}
- if (!(local)) {
- ZEPHIR_SINIT_VAR(_0);
- ZVAL_STRING(&_0, "://", 0);
- ZEPHIR_CALL_FUNCTION(&_1, "strstr", &_2, uri, &_0);
+ _0 = !local;
+ if (_0) {
+ _0 = !(zephir_start_with_str(uri, SL("mailto:")));
+ }
+ if (_0) {
+ ZEPHIR_SINIT_VAR(_1);
+ ZVAL_STRING(&_1, "://", 0);
+ ZEPHIR_CALL_FUNCTION(&_2, "strstr", NULL, 74, uri, &_1);
zephir_check_call_status();
- if (zephir_is_true(_1)) {
+ if (zephir_is_true(_2)) {
ZEPHIR_INIT_VAR(_3);
- ZVAL_STRING(_3, "/^[^:\\/?#]++:/", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_FUNCTION(&matched, "preg_match", &_4, _3, uri);
- zephir_check_temp_parameter(_3);
- zephir_check_call_status();
+ ZEPHIR_SINIT_NVAR(_1);
+ ZVAL_STRING(&_1, "/^[^:\\/?#]++:/", 0);
+ ZEPHIR_INIT_VAR(matched);
+ zephir_preg_match(matched, &_1, uri, _3, 0, 0 , 0 TSRMLS_CC);
if (zephir_is_true(matched)) {
local = 0;
} else {
@@ -163,44 +167,42 @@ PHP_METHOD(Ice_Mvc_Url, get) {
local = 1;
}
}
- ZEPHIR_CALL_METHOD(&baseUri, this_ptr, "getbaseuri", NULL);
+ ZEPHIR_CALL_METHOD(&baseUri, this_ptr, "getbaseuri", NULL, 0);
zephir_check_call_status();
if (local) {
- _5 = ZEPHIR_IS_FALSE_IDENTICAL(uri);
- if (_5) {
- zephir_get_global(&_GET, SS("_GET") TSRMLS_CC);
- _5 = zephir_array_isset_string(_GET, SS("_url"));
+ _4 = ZEPHIR_IS_FALSE_IDENTICAL(uri);
+ if (_4) {
+ _4 = zephir_array_isset_string(_GET, SS("_url"));
}
- if (_5) {
- zephir_get_global(&_GET, SS("_GET") TSRMLS_CC);
+ if (_4) {
ZEPHIR_OBS_NVAR(uri);
zephir_array_fetch_string(&uri, _GET, SL("_url"), PH_NOISY, "ice/mvc/url.zep", 62 TSRMLS_CC);
} else {
- ZEPHIR_INIT_VAR(_6);
- ZEPHIR_CONCAT_VV(_6, baseUri, uri);
- ZEPHIR_CPY_WRT(uri, _6);
+ ZEPHIR_INIT_VAR(_5);
+ ZEPHIR_CONCAT_VV(_5, baseUri, uri);
+ ZEPHIR_CPY_WRT(uri, _5);
}
}
if (zephir_is_true(args)) {
- ZEPHIR_CALL_FUNCTION(&queryString, "http_build_query", &_7, args);
+ ZEPHIR_CALL_FUNCTION(&queryString, "http_build_query", NULL, 19, args);
zephir_check_call_status();
- _5 = Z_TYPE_P(queryString) == IS_STRING;
- if (_5) {
- _5 = (zephir_fast_strlen_ev(queryString)) ? 1 : 0;
+ _4 = Z_TYPE_P(queryString) == IS_STRING;
+ if (_4) {
+ _4 = (zephir_fast_strlen_ev(queryString)) ? 1 : 0;
}
- if (_5) {
- ZEPHIR_SINIT_NVAR(_0);
- ZVAL_STRING(&_0, "?", 0);
- ZEPHIR_INIT_NVAR(_3);
- zephir_fast_strpos(_3, queryString, &_0, 0 );
- if (!ZEPHIR_IS_FALSE_IDENTICAL(_3)) {
- ZEPHIR_INIT_LNVAR(_6);
- ZEPHIR_CONCAT_SV(_6, "&", queryString);
- zephir_concat_self(&uri, _6 TSRMLS_CC);
+ if (_4) {
+ ZEPHIR_SINIT_NVAR(_1);
+ ZVAL_STRING(&_1, "?", 0);
+ ZEPHIR_INIT_VAR(_6);
+ zephir_fast_strpos(_6, queryString, &_1, 0 );
+ if (!ZEPHIR_IS_FALSE_IDENTICAL(_6)) {
+ ZEPHIR_INIT_LNVAR(_5);
+ ZEPHIR_CONCAT_SV(_5, "&", queryString);
+ zephir_concat_self(&uri, _5 TSRMLS_CC);
} else {
- ZEPHIR_INIT_VAR(_8);
- ZEPHIR_CONCAT_SV(_8, "?", queryString);
- zephir_concat_self(&uri, _8 TSRMLS_CC);
+ ZEPHIR_INIT_VAR(_7);
+ ZEPHIR_CONCAT_SV(_7, "?", queryString);
+ zephir_concat_self(&uri, _7 TSRMLS_CC);
}
}
}
diff --git a/ext/ice/mvc/url.zep.h b/ext/ice/mvc/url.zep.h
index 30922ba2..7a5eafe8 100644
--- a/ext/ice/mvc/url.zep.h
+++ b/ext/ice/mvc/url.zep.h
@@ -35,5 +35,5 @@ ZEPHIR_INIT_FUNCS(ice_mvc_url_method_entry) {
PHP_ME(Ice_Mvc_Url, setStaticUri, arginfo_ice_mvc_url_setstaticuri, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Mvc_Url, getStatic, arginfo_ice_mvc_url_getstatic, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Mvc_Url, get, arginfo_ice_mvc_url_get, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/mvc/view.zep.c b/ext/ice/mvc/view.zep.c
index 47e52f1f..0cc57c63 100644
--- a/ext/ice/mvc/view.zep.c
+++ b/ext/ice/mvc/view.zep.c
@@ -38,21 +38,21 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_View) {
ZEPHIR_REGISTER_CLASS_EX(Ice\\Mvc, View, ice, mvc_view, ice_arr_ce, ice_mvc_view_method_entry, 0);
- zend_declare_property_null(ice_mvc_view_ce, SL("_engines"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_ce, SL("engines"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_mvc_view_ce, SL("_content"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_ce, SL("content"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_string(ice_mvc_view_ce, SL("_mainView"), "index", ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_string(ice_mvc_view_ce, SL("mainView"), "index", ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_string(ice_mvc_view_ce, SL("_layoutsDir"), "layouts/", ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_string(ice_mvc_view_ce, SL("layoutsDir"), "layouts/", ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_string(ice_mvc_view_ce, SL("_partialsDir"), "partials/", ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_string(ice_mvc_view_ce, SL("partialsDir"), "partials/", ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_mvc_view_ce, SL("_viewsDir"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_ce, SL("viewsDir"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_mvc_view_ce, SL("_file"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_ce, SL("file"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_bool(ice_mvc_view_ce, SL("_silent"), 0, ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_bool(ice_mvc_view_ce, SL("silent"), 0, ZEND_ACC_PROTECTED TSRMLS_CC);
zend_class_implements(ice_mvc_view_ce TSRMLS_CC, 1, ice_mvc_view_viewinterface_ce);
return SUCCESS;
@@ -67,7 +67,7 @@ PHP_METHOD(Ice_Mvc_View, setEngines) {
- zephir_update_property_this(this_ptr, SL("_engines"), engines TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("engines"), engines TSRMLS_CC);
}
@@ -79,14 +79,14 @@ PHP_METHOD(Ice_Mvc_View, setContent) {
- zephir_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("content"), content TSRMLS_CC);
}
PHP_METHOD(Ice_Mvc_View, getContent) {
- RETURN_MEMBER(this_ptr, "_content");
+ RETURN_MEMBER(this_ptr, "content");
}
@@ -98,14 +98,14 @@ PHP_METHOD(Ice_Mvc_View, setMainView) {
- zephir_update_property_this(this_ptr, SL("_mainView"), mainView TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("mainView"), mainView TSRMLS_CC);
}
PHP_METHOD(Ice_Mvc_View, getMainView) {
- RETURN_MEMBER(this_ptr, "_mainView");
+ RETURN_MEMBER(this_ptr, "mainView");
}
@@ -117,14 +117,14 @@ PHP_METHOD(Ice_Mvc_View, setLayoutsDir) {
- zephir_update_property_this(this_ptr, SL("_layoutsDir"), layoutsDir TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("layoutsDir"), layoutsDir TSRMLS_CC);
}
PHP_METHOD(Ice_Mvc_View, getLayoutsDir) {
- RETURN_MEMBER(this_ptr, "_layoutsDir");
+ RETURN_MEMBER(this_ptr, "layoutsDir");
}
@@ -136,14 +136,14 @@ PHP_METHOD(Ice_Mvc_View, setPartialsDir) {
- zephir_update_property_this(this_ptr, SL("_partialsDir"), partialsDir TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("partialsDir"), partialsDir TSRMLS_CC);
}
PHP_METHOD(Ice_Mvc_View, getPartialsDir) {
- RETURN_MEMBER(this_ptr, "_partialsDir");
+ RETURN_MEMBER(this_ptr, "partialsDir");
}
@@ -155,14 +155,14 @@ PHP_METHOD(Ice_Mvc_View, setViewsDir) {
- zephir_update_property_this(this_ptr, SL("_viewsDir"), viewsDir TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("viewsDir"), viewsDir TSRMLS_CC);
}
PHP_METHOD(Ice_Mvc_View, getViewsDir) {
- RETURN_MEMBER(this_ptr, "_viewsDir");
+ RETURN_MEMBER(this_ptr, "viewsDir");
}
@@ -174,14 +174,14 @@ PHP_METHOD(Ice_Mvc_View, setFile) {
- zephir_update_property_this(this_ptr, SL("_file"), file TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("file"), file TSRMLS_CC);
}
PHP_METHOD(Ice_Mvc_View, getFile) {
- RETURN_MEMBER(this_ptr, "_file");
+ RETURN_MEMBER(this_ptr, "file");
}
@@ -193,7 +193,7 @@ PHP_METHOD(Ice_Mvc_View, setSilent) {
- zephir_update_property_this(this_ptr, SL("_silent"), silent TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("silent"), silent TSRMLS_CC);
}
@@ -206,7 +206,7 @@ PHP_METHOD(Ice_Mvc_View, setSilent) {
PHP_METHOD(Ice_Mvc_View, __construct) {
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_0 = NULL;
+ zephir_fcall_cache_entry *_0 = NULL;
zval *data = NULL;
zval *file = NULL, *data_param = NULL;
@@ -225,9 +225,9 @@ PHP_METHOD(Ice_Mvc_View, __construct) {
if (Z_TYPE_P(file) != IS_NULL) {
- zephir_update_property_this(this_ptr, SL("_file"), file TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("file"), file TSRMLS_CC);
}
- ZEPHIR_CALL_PARENT(NULL, ice_mvc_view_ce, this_ptr, "__construct", &_0, data);
+ ZEPHIR_CALL_PARENT(NULL, ice_mvc_view_ce, this_ptr, "__construct", &_0, 6, data);
zephir_check_call_status();
ZEPHIR_MM_RESTORE();
@@ -238,8 +238,7 @@ PHP_METHOD(Ice_Mvc_View, __construct) {
*/
PHP_METHOD(Ice_Mvc_View, getEngines) {
- zephir_fcall_cache_entry *_11 = NULL;
- zephir_nts_static zephir_fcall_cache_entry *_10 = NULL;
+ zephir_fcall_cache_entry *_10 = NULL, *_11 = NULL;
zval *_7 = NULL;
HashTable *_5;
HashPosition _4;
@@ -248,17 +247,17 @@ PHP_METHOD(Ice_Mvc_View, getEngines) {
ZEPHIR_MM_GROW();
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_engines"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("engines"), PH_NOISY_CC);
if (!(zephir_is_true(_0))) {
ZEPHIR_INIT_VAR(_1);
object_init_ex(_1, ice_mvc_view_engine_php_ce);
- ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, this_ptr);
+ ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 127, this_ptr);
zephir_check_call_status();
ZEPHIR_INIT_VAR(_2);
ZVAL_STRING(_2, ".phtml", 1);
- zephir_update_property_array(this_ptr, SL("_engines"), _2, _1 TSRMLS_CC);
+ zephir_update_property_array(this_ptr, SL("engines"), _2, _1 TSRMLS_CC);
}
- _3 = zephir_fetch_nproperty_this(this_ptr, SL("_engines"), PH_NOISY_CC);
+ _3 = zephir_fetch_nproperty_this(this_ptr, SL("engines"), PH_NOISY_CC);
zephir_is_iterable(_3, &_5, &_4, 0, 0, "ice/mvc/view.zep", 67);
for (
; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS
@@ -270,29 +269,29 @@ PHP_METHOD(Ice_Mvc_View, getEngines) {
if (zephir_instance_of_ev(engine, zend_ce_closure TSRMLS_CC)) {
ZEPHIR_INIT_NVAR(_1);
ZEPHIR_INIT_NVAR(_7);
- array_init_size(_7, 2);
+ zephir_create_array(_7, 1, 0 TSRMLS_CC);
zephir_array_fast_append(_7, this_ptr);
ZEPHIR_CALL_USER_FUNC_ARRAY(_1, engine, _7);
zephir_check_call_status();
- zephir_update_property_array(this_ptr, SL("_engines"), ext, _1 TSRMLS_CC);
+ zephir_update_property_array(this_ptr, SL("engines"), ext, _1 TSRMLS_CC);
}
} else {
if (Z_TYPE_P(engine) == IS_STRING) {
ZEPHIR_INIT_NVAR(_1);
ZEPHIR_INIT_NVAR(_7);
- array_init_size(_7, 2);
+ zephir_create_array(_7, 1, 0 TSRMLS_CC);
zephir_array_fast_append(_7, this_ptr);
ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(_1, engine, _7 TSRMLS_CC);
zephir_check_call_status();
- zephir_update_property_array(this_ptr, SL("_engines"), ext, _1 TSRMLS_CC);
+ zephir_update_property_array(this_ptr, SL("engines"), ext, _1 TSRMLS_CC);
} else {
ZEPHIR_INIT_NVAR(_1);
object_init_ex(_1, ice_exception_ce);
ZEPHIR_SINIT_NVAR(_8);
ZVAL_STRING(&_8, "Invalid template engine registration for '%s' extension", 0);
- ZEPHIR_CALL_FUNCTION(&_9, "sprintf", &_10, &_8, ext);
+ ZEPHIR_CALL_FUNCTION(&_9, "sprintf", &_10, 1, &_8, ext);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_11, _9);
+ ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_11, 2, _9);
zephir_check_call_status();
zephir_throw_exception_debug(_1, "ice/mvc/view.zep", 63 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
@@ -300,7 +299,7 @@ PHP_METHOD(Ice_Mvc_View, getEngines) {
}
}
}
- RETURN_MM_MEMBER(this_ptr, "_engines");
+ RETURN_MM_MEMBER(this_ptr, "engines");
}
@@ -313,12 +312,11 @@ PHP_METHOD(Ice_Mvc_View, getEngines) {
*/
PHP_METHOD(Ice_Mvc_View, render) {
- zephir_nts_static zephir_fcall_cache_entry *_12 = NULL;
- zephir_fcall_cache_entry *_6 = NULL, *_8 = NULL, *_13 = NULL;
+ zephir_fcall_cache_entry *_6 = NULL, *_8 = NULL, *_12 = NULL;
HashTable *_2;
HashPosition _1;
int ZEPHIR_LAST_CALL_STATUS;
- zend_bool exists, _9;
+ zend_bool exists = 0, _9;
zval *data = NULL;
zval *file = NULL, *data_param = NULL, *ext = NULL, *engine = NULL, *engines = NULL, *path = NULL, *content = NULL, *_0, **_3, *_4, *_5, *_7 = NULL, *_10, _11;
@@ -340,14 +338,14 @@ PHP_METHOD(Ice_Mvc_View, render) {
ZEPHIR_INIT_VAR(content);
ZVAL_NULL(content);
if (Z_TYPE_P(file) != IS_NULL) {
- zephir_update_property_this(this_ptr, SL("_file"), file TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("file"), file TSRMLS_CC);
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("file"), PH_NOISY_CC);
if (ZEPHIR_IS_EMPTY(_0)) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "You must set the file to use within your view before rendering", "ice/mvc/view.zep", 89);
return;
}
- ZEPHIR_CALL_METHOD(&engines, this_ptr, "getengines", NULL);
+ ZEPHIR_CALL_METHOD(&engines, this_ptr, "getengines", NULL, 0);
zephir_check_call_status();
zephir_is_iterable(engines, &_2, &_1, 0, 0, "ice/mvc/view.zep", 104);
for (
@@ -356,22 +354,22 @@ PHP_METHOD(Ice_Mvc_View, render) {
) {
ZEPHIR_GET_HMKEY(ext, _2, _1);
ZEPHIR_GET_HVALUE(engine, _3);
- _4 = zephir_fetch_nproperty_this(this_ptr, SL("_viewsDir"), PH_NOISY_CC);
- _5 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC);
+ _4 = zephir_fetch_nproperty_this(this_ptr, SL("viewsDir"), PH_NOISY_CC);
+ _5 = zephir_fetch_nproperty_this(this_ptr, SL("file"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(path);
ZEPHIR_CONCAT_VVV(path, _4, _5, ext);
if ((zephir_file_exists(path TSRMLS_CC) == SUCCESS)) {
exists = 1;
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", &_6, data);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", &_6, 0, data);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_7, this_ptr, "all", &_8);
+ ZEPHIR_CALL_METHOD(&_7, this_ptr, "all", &_8, 0);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&content, engine, "render", NULL, path, _7);
+ ZEPHIR_CALL_METHOD(&content, engine, "render", NULL, 0, path, _7);
zephir_check_call_status();
break;
}
}
- _4 = zephir_fetch_nproperty_this(this_ptr, SL("_silent"), PH_NOISY_CC);
+ _4 = zephir_fetch_nproperty_this(this_ptr, SL("silent"), PH_NOISY_CC);
_9 = !zephir_is_true(_4);
if (_9) {
_9 = !exists;
@@ -381,9 +379,9 @@ PHP_METHOD(Ice_Mvc_View, render) {
object_init_ex(_10, ice_exception_ce);
ZEPHIR_SINIT_VAR(_11);
ZVAL_STRING(&_11, "The requested view %s could not be found", 0);
- ZEPHIR_CALL_FUNCTION(&_7, "sprintf", &_12, &_11, path);
+ ZEPHIR_CALL_FUNCTION(&_7, "sprintf", NULL, 1, &_11, path);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, _10, "__construct", &_13, _7);
+ ZEPHIR_CALL_METHOD(NULL, _10, "__construct", &_12, 2, _7);
zephir_check_call_status();
zephir_throw_exception_debug(_10, "ice/mvc/view.zep", 105 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
@@ -414,7 +412,6 @@ PHP_METHOD(Ice_Mvc_View, load) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'file' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(file_param) == IS_STRING)) {
zephir_get_strval(file, file_param);
} else {
@@ -429,7 +426,7 @@ PHP_METHOD(Ice_Mvc_View, load) {
}
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, file, data);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, 0, file, data);
zephir_check_call_status();
RETURN_MM();
@@ -456,7 +453,6 @@ PHP_METHOD(Ice_Mvc_View, partial) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'file' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(file_param) == IS_STRING)) {
zephir_get_strval(file, file_param);
} else {
@@ -471,10 +467,10 @@ PHP_METHOD(Ice_Mvc_View, partial) {
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_partialsDir"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("partialsDir"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_1);
ZEPHIR_CONCAT_VV(_1, _0, file);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, _1, data);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, 0, _1, data);
zephir_check_call_status();
RETURN_MM();
@@ -511,12 +507,12 @@ PHP_METHOD(Ice_Mvc_View, layout) {
if (!(zephir_is_true(file))) {
ZEPHIR_OBS_NVAR(file);
- zephir_read_property_this(&file, this_ptr, SL("_mainView"), PH_NOISY_CC);
+ zephir_read_property_this(&file, this_ptr, SL("mainView"), PH_NOISY_CC);
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_layoutsDir"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("layoutsDir"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_1);
ZEPHIR_CONCAT_VV(_1, _0, file);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, _1, data);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, 0, _1, data);
zephir_check_call_status();
RETURN_MM();
@@ -541,7 +537,6 @@ PHP_METHOD(Ice_Mvc_View, setVar) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(name_param) == IS_STRING)) {
zephir_get_strval(name, name_param);
} else {
@@ -550,7 +545,7 @@ PHP_METHOD(Ice_Mvc_View, setVar) {
}
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, name, value);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, name, value);
zephir_check_call_status();
ZEPHIR_MM_RESTORE();
@@ -573,8 +568,7 @@ PHP_METHOD(Ice_Mvc_View, setVars) {
vars = vars_param;
-
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", NULL, vars);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", NULL, 0, vars);
zephir_check_call_status();
ZEPHIR_MM_RESTORE();
@@ -589,7 +583,7 @@ PHP_METHOD(Ice_Mvc_View, __toString) {
ZEPHIR_MM_GROW();
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, 0);
zephir_check_call_status();
RETURN_MM();
diff --git a/ext/ice/mvc/view.zep.h b/ext/ice/mvc/view.zep.h
index 12d69795..c126342f 100644
--- a/ext/ice/mvc/view.zep.h
+++ b/ext/ice/mvc/view.zep.h
@@ -117,5 +117,5 @@ ZEPHIR_INIT_FUNCS(ice_mvc_view_method_entry) {
PHP_ME(Ice_Mvc_View, setVar, arginfo_ice_mvc_view_setvar, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Mvc_View, setVars, arginfo_ice_mvc_view_setvars, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Mvc_View, __toString, NULL, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/mvc/view/engine.zep.c b/ext/ice/mvc/view/engine.zep.c
index f6f18e91..9de4e2ff 100644
--- a/ext/ice/mvc/view/engine.zep.c
+++ b/ext/ice/mvc/view/engine.zep.c
@@ -33,9 +33,9 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_View_Engine) {
ZEPHIR_REGISTER_CLASS_EX(Ice\\Mvc\\View, Engine, ice, mvc_view_engine, ice_di_access_ce, ice_mvc_view_engine_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
- zend_declare_property_null(ice_mvc_view_engine_ce, SL("_view"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_ce, SL("view"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_mvc_view_engine_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_ce, SL("options"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_class_implements(ice_mvc_view_engine_ce TSRMLS_CC, 1, ice_mvc_view_engine_engineinterface_ce);
return SUCCESS;
@@ -50,7 +50,7 @@ PHP_METHOD(Ice_Mvc_View_Engine, setOptions) {
- zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("options"), options TSRMLS_CC);
}
@@ -60,7 +60,7 @@ PHP_METHOD(Ice_Mvc_View_Engine, setOptions) {
PHP_METHOD(Ice_Mvc_View_Engine, __construct) {
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_0 = NULL;
+ zephir_fcall_cache_entry *_0 = NULL;
zval *view, *di = NULL;
ZEPHIR_MM_GROW();
@@ -71,8 +71,8 @@ PHP_METHOD(Ice_Mvc_View_Engine, __construct) {
}
- zephir_update_property_this(this_ptr, SL("_view"), view TSRMLS_CC);
- ZEPHIR_CALL_PARENT(NULL, ice_mvc_view_engine_ce, this_ptr, "__construct", &_0, di);
+ zephir_update_property_this(this_ptr, SL("view"), view TSRMLS_CC);
+ ZEPHIR_CALL_PARENT(NULL, ice_mvc_view_engine_ce, this_ptr, "__construct", &_0, 29, di);
zephir_check_call_status();
ZEPHIR_MM_RESTORE();
@@ -90,8 +90,8 @@ PHP_METHOD(Ice_Mvc_View_Engine, getContent) {
ZEPHIR_MM_GROW();
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_view"), PH_NOISY_CC);
- ZEPHIR_RETURN_CALL_METHOD(_0, "getcontent", NULL);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("view"), PH_NOISY_CC);
+ ZEPHIR_RETURN_CALL_METHOD(_0, "getcontent", NULL, 0);
zephir_check_call_status();
RETURN_MM();
@@ -117,7 +117,6 @@ PHP_METHOD(Ice_Mvc_View_Engine, load) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(path_param) == IS_STRING)) {
zephir_get_strval(path, path_param);
} else {
@@ -132,8 +131,8 @@ PHP_METHOD(Ice_Mvc_View_Engine, load) {
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_view"), PH_NOISY_CC);
- ZEPHIR_RETURN_CALL_METHOD(_0, "load", NULL, path, data);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("view"), PH_NOISY_CC);
+ ZEPHIR_RETURN_CALL_METHOD(_0, "load", NULL, 0, path, data);
zephir_check_call_status();
RETURN_MM();
@@ -159,7 +158,6 @@ PHP_METHOD(Ice_Mvc_View_Engine, partial) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(path_param) == IS_STRING)) {
zephir_get_strval(path, path_param);
} else {
@@ -174,8 +172,8 @@ PHP_METHOD(Ice_Mvc_View_Engine, partial) {
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_view"), PH_NOISY_CC);
- ZEPHIR_RETURN_CALL_METHOD(_0, "partial", NULL, path, data);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("view"), PH_NOISY_CC);
+ ZEPHIR_RETURN_CALL_METHOD(_0, "partial", NULL, 0, path, data);
zephir_check_call_status();
RETURN_MM();
diff --git a/ext/ice/mvc/view/engine.zep.h b/ext/ice/mvc/view/engine.zep.h
index 254491b2..bd9639f4 100644
--- a/ext/ice/mvc/view/engine.zep.h
+++ b/ext/ice/mvc/view/engine.zep.h
@@ -41,5 +41,5 @@ ZEPHIR_INIT_FUNCS(ice_mvc_view_engine_method_entry) {
PHP_ME(Ice_Mvc_View_Engine, load, arginfo_ice_mvc_view_engine_load, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Mvc_View_Engine, partial, arginfo_ice_mvc_view_engine_partial, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Mvc_View_Engine, render, arginfo_ice_mvc_view_engine_render, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/mvc/view/engine/engineinterface.zep.h b/ext/ice/mvc/view/engine/engineinterface.zep.h
index c2d4f340..8d9fef31 100644
--- a/ext/ice/mvc/view/engine/engineinterface.zep.h
+++ b/ext/ice/mvc/view/engine/engineinterface.zep.h
@@ -16,5 +16,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_mvc_view_engine_engineinterface_method_entry) {
PHP_ABSTRACT_ME(Ice_Mvc_View_Engine_EngineInterface, __construct, arginfo_ice_mvc_view_engine_engineinterface___construct)
PHP_ABSTRACT_ME(Ice_Mvc_View_Engine_EngineInterface, render, arginfo_ice_mvc_view_engine_engineinterface_render)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/mvc/view/engine/php.zep.c b/ext/ice/mvc/view/engine/php.zep.c
index c104c970..4a1e6003 100644
--- a/ext/ice/mvc/view/engine/php.zep.c
+++ b/ext/ice/mvc/view/engine/php.zep.c
@@ -47,7 +47,6 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_View_Engine_Php) {
PHP_METHOD(Ice_Mvc_View_Engine_Php, render) {
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_1 = NULL, *_2 = NULL;
zval *data = NULL;
zval *path_param = NULL, *data_param = NULL;
zval *path = NULL;
@@ -59,7 +58,6 @@ PHP_METHOD(Ice_Mvc_View_Engine_Php, render) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(path_param) == IS_STRING)) {
zephir_get_strval(path, path_param);
} else {
@@ -74,16 +72,16 @@ PHP_METHOD(Ice_Mvc_View_Engine_Php, render) {
}
- Z_SET_ISREF_P(data);
- ZEPHIR_CALL_FUNCTION(NULL, "extract", &_0, data);
- Z_UNSET_ISREF_P(data);
+ ZEPHIR_MAKE_REF(data);
+ ZEPHIR_CALL_FUNCTION(NULL, "extract", NULL, 128, data);
+ ZEPHIR_UNREF(data);
zephir_check_call_status();
- ZEPHIR_CALL_FUNCTION(NULL, "ob_start", &_1);
+ ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 129);
zephir_check_call_status();
if (zephir_require_zval(path TSRMLS_CC) == FAILURE) {
RETURN_MM_NULL();
}
- ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", &_2);
+ ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 130);
zephir_check_call_status();
RETURN_MM();
diff --git a/ext/ice/mvc/view/engine/php.zep.h b/ext/ice/mvc/view/engine/php.zep.h
index dcc0c521..561cb22d 100644
--- a/ext/ice/mvc/view/engine/php.zep.h
+++ b/ext/ice/mvc/view/engine/php.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_mvc_view_engine_php_method_entry) {
PHP_ME(Ice_Mvc_View_Engine_Php, render, arginfo_ice_mvc_view_engine_php_render, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/mvc/view/engine/sleet.zep.c b/ext/ice/mvc/view/engine/sleet.zep.c
index d1b68219..02875b1f 100644
--- a/ext/ice/mvc/view/engine/sleet.zep.c
+++ b/ext/ice/mvc/view/engine/sleet.zep.c
@@ -38,7 +38,7 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_View_Engine_Sleet) {
ZEPHIR_REGISTER_CLASS_EX(Ice\\Mvc\\View\\Engine, Sleet, ice, mvc_view_engine_sleet, ice_mvc_view_engine_ce, ice_mvc_view_engine_sleet_method_entry, 0);
- zend_declare_property_null(ice_mvc_view_engine_sleet_ce, SL("_compiler"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_sleet_ce, SL("compiler"), ZEND_ACC_PROTECTED TSRMLS_CC);
return SUCCESS;
@@ -47,7 +47,7 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_View_Engine_Sleet) {
PHP_METHOD(Ice_Mvc_View_Engine_Sleet, getCompiler) {
- RETURN_MEMBER(this_ptr, "_compiler");
+ RETURN_MEMBER(this_ptr, "compiler");
}
@@ -59,9 +59,9 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet, getCompiler) {
*/
PHP_METHOD(Ice_Mvc_View_Engine_Sleet, compile) {
+ zephir_fcall_cache_entry *_14 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_12 = NULL, *_13 = NULL, *_18 = NULL, *_19 = NULL, *_20 = NULL;
- zval *path_param = NULL, *compileDir, *compile = NULL, *trim, *dir, *file = NULL, *compiledPath, *old = NULL, *compiled = NULL, *_0, *_1, *_2, *_3, _4, *_5, *_6 = NULL, *_8 = NULL, _10, _11 = zval_used_for_init, *_14, *_15, *_16 = NULL, *_17 = NULL;
+ zval *path_param = NULL, *compileDir = NULL, *compile = NULL, *trim = NULL, *dir = NULL, *file = NULL, *compiledPath = NULL, *old = NULL, *compiled = NULL, *_0, *_1, *_2, *_3, _4, *_5, *_6 = NULL, *_7 = NULL, _8, _9 = zval_used_for_init, *_10, *_11, *_12 = NULL, *_13 = NULL;
zval *path = NULL;
ZEPHIR_MM_GROW();
@@ -71,7 +71,6 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet, compile) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(path_param) == IS_STRING)) {
zephir_get_strval(path, path_param);
} else {
@@ -81,31 +80,31 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet, compile) {
ZEPHIR_OBS_VAR(trim);
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC);
zephir_array_isset_string_fetch(&trim, _0, SS("trimPath"), 0 TSRMLS_CC);
ZEPHIR_OBS_VAR(compileDir);
- _1 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC);
zephir_array_isset_string_fetch(&compileDir, _1, SS("compileDir"), 0 TSRMLS_CC);
ZEPHIR_OBS_VAR(compile);
- _2 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
+ _2 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC);
zephir_array_isset_string_fetch(&compile, _2, SS("compile"), 0 TSRMLS_CC);
ZEPHIR_INIT_VAR(_3);
ZEPHIR_SINIT_VAR(_4);
ZVAL_STRING(&_4, "/", 0);
zephir_fast_trim(_3, compileDir, &_4, ZEPHIR_TRIM_RIGHT TSRMLS_CC);
ZEPHIR_INIT_VAR(_5);
- ZEPHIR_CALL_FUNCTION(&_6, "dirname", &_7, path);
+ ZEPHIR_CALL_FUNCTION(&_6, "dirname", NULL, 35, path);
zephir_check_call_status();
- ZEPHIR_CALL_FUNCTION(&_8, "realpath", &_9, _6);
+ ZEPHIR_CALL_FUNCTION(&_7, "realpath", NULL, 79, _6);
zephir_check_call_status();
- ZEPHIR_SINIT_VAR(_10);
- ZVAL_STRING(&_10, "", 0);
- zephir_fast_str_replace(_5, trim, &_10, _8 TSRMLS_CC);
+ ZEPHIR_SINIT_VAR(_8);
+ ZVAL_STRING(&_8, "", 0);
+ zephir_fast_str_replace(&_5, trim, &_8, _7 TSRMLS_CC);
ZEPHIR_INIT_VAR(dir);
ZEPHIR_CONCAT_VV(dir, _3, _5);
- ZEPHIR_SINIT_VAR(_11);
- ZVAL_STRING(&_11, ".sleet", 0);
- ZEPHIR_CALL_FUNCTION(&file, "basename", &_12, path, &_11);
+ ZEPHIR_SINIT_VAR(_9);
+ ZVAL_STRING(&_9, ".sleet", 0);
+ ZEPHIR_CALL_FUNCTION(&file, "basename", NULL, 36, path, &_9);
zephir_check_call_status();
ZEPHIR_INIT_VAR(compiledPath);
ZEPHIR_CONCAT_VSVS(compiledPath, dir, "/", file, ".phtml");
@@ -125,7 +124,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet, compile) {
ZEPHIR_INIT_NVAR(compile);
ZVAL_BOOL(compile, 1);
} else {
- ZEPHIR_CALL_FUNCTION(&compile, "md5_file", &_13, compiledPath);
+ ZEPHIR_CALL_FUNCTION(&compile, "md5_file", NULL, 37, compiledPath);
zephir_check_call_status();
}
break;
@@ -136,40 +135,40 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet, compile) {
} while(0);
if (zephir_is_true(compile)) {
- ZEPHIR_INIT_VAR(_14);
- object_init_ex(_14, ice_mvc_view_engine_sleet_compiler_ce);
- ZEPHIR_CALL_METHOD(NULL, _14, "__construct", NULL, this_ptr);
+ ZEPHIR_INIT_VAR(_10);
+ object_init_ex(_10, ice_mvc_view_engine_sleet_compiler_ce);
+ ZEPHIR_CALL_METHOD(NULL, _10, "__construct", NULL, 131, this_ptr);
zephir_check_call_status();
- zephir_update_property_this(this_ptr, SL("_compiler"), _14 TSRMLS_CC);
- _15 = zephir_fetch_nproperty_this(this_ptr, SL("_compiler"), PH_NOISY_CC);
- ZEPHIR_CALL_METHOD(&compiled, _15, "compile", NULL, path);
+ zephir_update_property_this(this_ptr, SL("compiler"), _10 TSRMLS_CC);
+ _11 = zephir_fetch_nproperty_this(this_ptr, SL("compiler"), PH_NOISY_CC);
+ ZEPHIR_CALL_METHOD(&compiled, _11, "compile", NULL, 0, path);
zephir_check_call_status();
if (Z_TYPE_P(compile) == IS_STRING) {
- ZEPHIR_INIT_VAR(_16);
- zephir_md5(_16, compiled);
- if (!ZEPHIR_IS_EQUAL(compile, _16)) {
+ ZEPHIR_INIT_VAR(_12);
+ zephir_md5(_12, compiled);
+ if (!ZEPHIR_IS_EQUAL(compile, _12)) {
ZEPHIR_INIT_NVAR(compile);
ZVAL_BOOL(compile, 1);
}
}
if (ZEPHIR_IS_TRUE_IDENTICAL(compile)) {
- ZEPHIR_CALL_FUNCTION(&_17, "is_dir", &_18, dir);
+ ZEPHIR_CALL_FUNCTION(&_13, "is_dir", NULL, 38, dir);
zephir_check_call_status();
- if (!(zephir_is_true(_17))) {
- ZEPHIR_SINIT_NVAR(_11);
- ZVAL_LONG(&_11, 0);
- ZEPHIR_CALL_FUNCTION(&old, "umask", &_19, &_11);
+ if (!(zephir_is_true(_13))) {
+ ZEPHIR_SINIT_NVAR(_9);
+ ZVAL_LONG(&_9, 0);
+ ZEPHIR_CALL_FUNCTION(&old, "umask", &_14, 39, &_9);
zephir_check_call_status();
- ZEPHIR_SINIT_NVAR(_11);
- ZVAL_LONG(&_11, 0777);
- ZEPHIR_CALL_FUNCTION(NULL, "mkdir", &_20, dir, &_11, ZEPHIR_GLOBAL(global_true));
+ ZEPHIR_SINIT_NVAR(_9);
+ ZVAL_LONG(&_9, 0777);
+ ZEPHIR_CALL_FUNCTION(NULL, "mkdir", NULL, 40, dir, &_9, ZEPHIR_GLOBAL(global_true));
zephir_check_call_status();
- ZEPHIR_CALL_FUNCTION(NULL, "umask", &_19, old);
+ ZEPHIR_CALL_FUNCTION(NULL, "umask", &_14, 39, old);
zephir_check_call_status();
}
- ZEPHIR_INIT_NVAR(_16);
- zephir_file_put_contents(_16, compiledPath, compiled TSRMLS_CC);
- if (ZEPHIR_IS_FALSE_IDENTICAL(_16)) {
+ ZEPHIR_INIT_NVAR(_12);
+ zephir_file_put_contents(_12, compiledPath, compiled TSRMLS_CC);
+ if (ZEPHIR_IS_FALSE_IDENTICAL(_12)) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Directory can't be written", "ice/mvc/view/engine/sleet.zep", 80);
return;
}
@@ -188,7 +187,6 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet, compile) {
*/
PHP_METHOD(Ice_Mvc_View_Engine_Sleet, render) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_3 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *data = NULL;
zval *path_param = NULL, *data_param = NULL, *_0 = NULL;
@@ -201,7 +199,6 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet, render) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(path_param) == IS_STRING)) {
zephir_get_strval(path, path_param);
} else {
@@ -216,19 +213,19 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet, render) {
}
- ZEPHIR_CALL_METHOD(&_0, this_ptr, "compile", NULL, path);
+ ZEPHIR_CALL_METHOD(&_0, this_ptr, "compile", NULL, 0, path);
zephir_check_call_status();
zephir_get_strval(path, _0);
- Z_SET_ISREF_P(data);
- ZEPHIR_CALL_FUNCTION(NULL, "extract", &_1, data);
- Z_UNSET_ISREF_P(data);
+ ZEPHIR_MAKE_REF(data);
+ ZEPHIR_CALL_FUNCTION(NULL, "extract", NULL, 128, data);
+ ZEPHIR_UNREF(data);
zephir_check_call_status();
- ZEPHIR_CALL_FUNCTION(NULL, "ob_start", &_2);
+ ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 129);
zephir_check_call_status();
if (zephir_require_zval(path TSRMLS_CC) == FAILURE) {
RETURN_MM_NULL();
}
- ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", &_3);
+ ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 130);
zephir_check_call_status();
RETURN_MM();
diff --git a/ext/ice/mvc/view/engine/sleet.zep.h b/ext/ice/mvc/view/engine/sleet.zep.h
index 3b209b57..ef6e6b6e 100644
--- a/ext/ice/mvc/view/engine/sleet.zep.h
+++ b/ext/ice/mvc/view/engine/sleet.zep.h
@@ -20,5 +20,5 @@ ZEPHIR_INIT_FUNCS(ice_mvc_view_engine_sleet_method_entry) {
PHP_ME(Ice_Mvc_View_Engine_Sleet, getCompiler, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Mvc_View_Engine_Sleet, compile, arginfo_ice_mvc_view_engine_sleet_compile, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Mvc_View_Engine_Sleet, render, arginfo_ice_mvc_view_engine_sleet_render, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/mvc/view/engine/sleet/compiler.zep.c b/ext/ice/mvc/view/engine/sleet/compiler.zep.c
index 50d2a817..86bc0801 100644
--- a/ext/ice/mvc/view/engine/sleet/compiler.zep.c
+++ b/ext/ice/mvc/view/engine/sleet/compiler.zep.c
@@ -32,13 +32,13 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_View_Engine_Sleet_Compiler) {
ZEPHIR_REGISTER_CLASS(Ice\\Mvc\\View\\Engine\\Sleet, Compiler, ice, mvc_view_engine_sleet_compiler, ice_mvc_view_engine_sleet_compiler_method_entry, 0);
- zend_declare_property_null(ice_mvc_view_engine_sleet_compiler_ce, SL("_view"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_sleet_compiler_ce, SL("view"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_mvc_view_engine_sleet_compiler_ce, SL("_content"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_sleet_compiler_ce, SL("content"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_mvc_view_engine_sleet_compiler_ce, SL("_parsed"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_sleet_compiler_ce, SL("parsed"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_mvc_view_engine_sleet_compiler_ce, SL("_parser"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_sleet_compiler_ce, SL("parser"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_class_constant_long(ice_mvc_view_engine_sleet_compiler_ce, SL("NEVER"), 0 TSRMLS_CC);
@@ -55,7 +55,7 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_View_Engine_Sleet_Compiler) {
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Compiler, getParser) {
- RETURN_MEMBER(this_ptr, "_parser");
+ RETURN_MEMBER(this_ptr, "parser");
}
@@ -77,12 +77,12 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Compiler, __construct) {
}
- zephir_update_property_this(this_ptr, SL("_view"), view TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("view"), view TSRMLS_CC);
ZEPHIR_INIT_VAR(_0);
object_init_ex(_0, ice_mvc_view_engine_sleet_parser_ce);
- ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL);
+ ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 132);
zephir_check_call_status();
- zephir_update_property_this(this_ptr, SL("_parser"), _0 TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("parser"), _0 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
@@ -96,7 +96,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Compiler, __construct) {
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Compiler, compile) {
int ZEPHIR_LAST_CALL_STATUS;
- zval *path_param = NULL, *content, *_0, *_1 = NULL;
+ zval *path_param = NULL, *content = NULL, *_0, *_1 = NULL;
zval *path = NULL;
ZEPHIR_MM_GROW();
@@ -107,12 +107,12 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Compiler, compile) {
ZEPHIR_INIT_VAR(content);
zephir_file_get_contents(content, path TSRMLS_CC);
- zephir_update_property_this(this_ptr, SL("_content"), content TSRMLS_CC);
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_parser"), PH_NOISY_CC);
- ZEPHIR_CALL_METHOD(&_1, _0, "text", NULL, content);
+ zephir_update_property_this(this_ptr, SL("content"), content TSRMLS_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("parser"), PH_NOISY_CC);
+ ZEPHIR_CALL_METHOD(&_1, _0, "text", NULL, 0, content);
zephir_check_call_status();
- zephir_update_property_this(this_ptr, SL("_parsed"), _1 TSRMLS_CC);
- RETURN_MM_MEMBER(this_ptr, "_parsed");
+ zephir_update_property_this(this_ptr, SL("parsed"), _1 TSRMLS_CC);
+ RETURN_MM_MEMBER(this_ptr, "parsed");
}
@@ -122,7 +122,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Compiler, compile) {
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Compiler, __toString) {
- RETURN_MEMBER(this_ptr, "_parsed");
+ RETURN_MEMBER(this_ptr, "parsed");
}
diff --git a/ext/ice/mvc/view/engine/sleet/compiler.zep.h b/ext/ice/mvc/view/engine/sleet/compiler.zep.h
index 47143907..3ae4ef43 100644
--- a/ext/ice/mvc/view/engine/sleet/compiler.zep.h
+++ b/ext/ice/mvc/view/engine/sleet/compiler.zep.h
@@ -21,5 +21,5 @@ ZEPHIR_INIT_FUNCS(ice_mvc_view_engine_sleet_compiler_method_entry) {
PHP_ME(Ice_Mvc_View_Engine_Sleet_Compiler, __construct, arginfo_ice_mvc_view_engine_sleet_compiler___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(Ice_Mvc_View_Engine_Sleet_Compiler, compile, arginfo_ice_mvc_view_engine_sleet_compiler_compile, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Mvc_View_Engine_Sleet_Compiler, __toString, NULL, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/mvc/view/engine/sleet/parser.zep.c b/ext/ice/mvc/view/engine/sleet/parser.zep.c
index 5479ba33..df95491d 100644
--- a/ext/ice/mvc/view/engine/sleet/parser.zep.c
+++ b/ext/ice/mvc/view/engine/sleet/parser.zep.c
@@ -13,25 +13,36 @@
#include "kernel/main.h"
#include "kernel/memory.h"
-#include "kernel/object.h"
#include "kernel/fcall.h"
#include "kernel/hash.h"
+#include "kernel/object.h"
#include "kernel/operators.h"
#include "kernel/concat.h"
#include "kernel/array.h"
#include "kernel/string.h"
#include "kernel/exception.h"
+
+/**
+ * Sleet file parser.
+ *
+ * @package Ice/View
+ * @category Component
+ * @author Ice Team
+ * @copyright (c) 2014-2015 Ice Team
+ * @license http://iceframework.org/license
+ */
ZEPHIR_INIT_CLASS(Ice_Mvc_View_Engine_Sleet_Parser) {
ZEPHIR_REGISTER_CLASS(Ice\\Mvc\\View\\Engine\\Sleet, Parser, ice, mvc_view_engine_sleet_parser, ice_mvc_view_engine_sleet_parser_method_entry, 0);
- zend_declare_property_null(ice_mvc_view_engine_sleet_parser_ce, SL("_functions"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_sleet_parser_ce, SL("functions"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_mvc_view_engine_sleet_parser_ce, SL("_filters"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_sleet_parser_ce, SL("filters"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_mvc_view_engine_sleet_parser_ce, SL("_env"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_mvc_view_engine_sleet_parser_ce, SL("env"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ ice_mvc_view_engine_sleet_parser_ce->create_object = zephir_init_properties_Ice_Mvc_View_Engine_Sleet_Parser;
zend_declare_class_constant_long(ice_mvc_view_engine_sleet_parser_ce, SL("NORMAL"), 0 TSRMLS_CC);
zend_declare_class_constant_long(ice_mvc_view_engine_sleet_parser_ce, SL("SHORTIF"), 1 TSRMLS_CC);
@@ -47,80 +58,64 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_View_Engine_Sleet_Parser) {
*/
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, __construct) {
- HashTable *_5;
- HashPosition _4;
+ HashTable *_2;
+ HashPosition _1;
int ZEPHIR_LAST_CALL_STATUS;
- zval *_1, *_2;
- zval *_0, *tag, *methods = NULL, *functions, *method = NULL, *_3 = NULL, **_6, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_14, *_15, *_16;
+ zval *tag = NULL, *methods = NULL, *functions = NULL, *method = NULL, *_0 = NULL, **_3, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11, *_12, *_13;
ZEPHIR_MM_GROW();
- ZEPHIR_INIT_VAR(_0);
- array_init(_0);
- zephir_update_property_this(this_ptr, SL("_env"), _0 TSRMLS_CC);
- ZEPHIR_INIT_VAR(_1);
- array_init_size(_1, 2);
- add_assoc_stringl_ex(_1, SS("capitalize"), SL("ucfirst"), 1);
- zephir_update_property_this(this_ptr, SL("_filters"), _1 TSRMLS_CC);
- ZEPHIR_INIT_VAR(_2);
- array_init_size(_2, 7);
- add_assoc_stringl_ex(_2, SS("content"), SL("$this->getContent"), 1);
- add_assoc_stringl_ex(_2, SS("partial"), SL("$this->partial"), 1);
- add_assoc_stringl_ex(_2, SS("load"), SL("$this->load"), 1);
- add_assoc_stringl_ex(_2, SS("dump"), SL("$this->dump->vars"), 1);
- add_assoc_stringl_ex(_2, SS("version"), SL("Ice\\Version::get"), 1);
- zephir_update_property_this(this_ptr, SL("_functions"), _2 TSRMLS_CC);
ZEPHIR_INIT_VAR(tag);
object_init_ex(tag, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC));
- ZEPHIR_INIT_VAR(_3);
- ZVAL_STRING(_3, "Ice\\Tag", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, tag, "__construct", NULL, _3);
- zephir_check_temp_parameter(_3);
+ ZEPHIR_INIT_VAR(_0);
+ ZVAL_STRING(_0, "Ice\\Tag", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(NULL, tag, "__construct", NULL, 133, _0);
+ zephir_check_temp_parameter(_0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_LONG(_3, 256);
- ZEPHIR_CALL_METHOD(&methods, tag, "getmethods", NULL, _3);
+ ZEPHIR_INIT_NVAR(_0);
+ ZVAL_LONG(_0, 256);
+ ZEPHIR_CALL_METHOD(&methods, tag, "getmethods", NULL, 134, _0);
zephir_check_call_status();
ZEPHIR_INIT_VAR(functions);
array_init(functions);
- zephir_is_iterable(methods, &_5, &_4, 0, 0, "ice/mvc/view/engine/sleet/parser.zep", 57);
+ zephir_is_iterable(methods, &_2, &_1, 0, 0, "ice/mvc/view/engine/sleet/parser.zep", 57);
for (
- ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS
- ; zephir_hash_move_forward_ex(_5, &_4)
+ ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
+ ; zephir_hash_move_forward_ex(_2, &_1)
) {
- ZEPHIR_GET_HVALUE(method, _6);
- ZEPHIR_OBS_NVAR(_7);
- zephir_read_property(&_7, method, SL("name"), PH_NOISY_CC);
+ ZEPHIR_GET_HVALUE(method, _3);
+ ZEPHIR_OBS_NVAR(_4);
+ zephir_read_property(&_4, method, SL("name"), PH_NOISY_CC);
do {
- if (ZEPHIR_IS_STRING(_7, "__construct")) {
+ if (ZEPHIR_IS_STRING(_4, "__construct")) {
continue;
}
+ ZEPHIR_OBS_NVAR(_5);
+ zephir_read_property(&_5, method, SL("name"), PH_NOISY_CC);
+ ZEPHIR_INIT_LNVAR(_6);
+ ZEPHIR_CONCAT_SV(_6, "$this->tag->", _5);
+ ZEPHIR_OBS_NVAR(_7);
+ zephir_read_property(&_7, method, SL("name"), PH_NOISY_CC);
+ zephir_array_update_zval(&functions, _7, &_6, PH_COPY | PH_SEPARATE);
ZEPHIR_OBS_NVAR(_8);
zephir_read_property(&_8, method, SL("name"), PH_NOISY_CC);
ZEPHIR_INIT_LNVAR(_9);
ZEPHIR_CONCAT_SV(_9, "$this->tag->", _8);
+ ZEPHIR_INIT_NVAR(_0);
ZEPHIR_OBS_NVAR(_10);
zephir_read_property(&_10, method, SL("name"), PH_NOISY_CC);
- zephir_array_update_zval(&functions, _10, &_9, PH_COPY | PH_SEPARATE);
- ZEPHIR_OBS_NVAR(_11);
- zephir_read_property(&_11, method, SL("name"), PH_NOISY_CC);
- ZEPHIR_INIT_LNVAR(_12);
- ZEPHIR_CONCAT_SV(_12, "$this->tag->", _11);
- ZEPHIR_INIT_NVAR(_3);
- ZEPHIR_OBS_NVAR(_13);
- zephir_read_property(&_13, method, SL("name"), PH_NOISY_CC);
- zephir_uncamelize(_3, _13);
- zephir_array_update_zval(&functions, _3, &_12, PH_COPY | PH_SEPARATE);
+ zephir_uncamelize(_0, _10);
+ zephir_array_update_zval(&functions, _0, &_9, PH_COPY | PH_SEPARATE);
} while(0);
}
- ZEPHIR_INIT_VAR(_14);
- _15 = zephir_fetch_nproperty_this(this_ptr, SL("_functions"), PH_NOISY_CC);
- zephir_fast_array_merge(_14, &(_15), &(functions) TSRMLS_CC);
- zephir_update_property_this(this_ptr, SL("_functions"), _14 TSRMLS_CC);
- ZEPHIR_INIT_ZVAL_NREF(_16);
- ZVAL_LONG(_16, 0);
- zephir_update_property_array_append(this_ptr, SL("_env"), _16 TSRMLS_CC);
+ ZEPHIR_INIT_VAR(_11);
+ _12 = zephir_fetch_nproperty_this(this_ptr, SL("functions"), PH_NOISY_CC);
+ zephir_fast_array_merge(_11, &(_12), &(functions) TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("functions"), _11 TSRMLS_CC);
+ ZEPHIR_INIT_ZVAL_NREF(_13);
+ ZVAL_LONG(_13, 0);
+ zephir_update_property_array_append(this_ptr, SL("env"), _13 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
@@ -137,7 +132,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, text) {
int ZEPHIR_LAST_CALL_STATUS;
HashTable *_3;
HashPosition _2;
- zval *text_param = NULL, *parsed, *key = NULL, *line = NULL, *_0, *_1, **_4, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_9 = NULL;
+ zval *text_param = NULL, *parsed = NULL, *key = NULL, *line = NULL, *_0, *_1, **_4, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_9 = NULL;
zval *text = NULL;
ZEPHIR_MM_GROW();
@@ -169,7 +164,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, text) {
}
ZEPHIR_INIT_NVAR(_7);
ZVAL_LONG(_7, (zephir_get_numberval(key) + 1));
- ZEPHIR_CALL_METHOD(&_6, this_ptr, "line", &_8, line, _7);
+ ZEPHIR_CALL_METHOD(&_6, this_ptr, "line", &_8, 0, line, _7);
zephir_check_call_status();
ZEPHIR_INIT_LNVAR(_9);
ZEPHIR_CONCAT_VV(_9, _5, _6);
@@ -188,11 +183,10 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, text) {
*/
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, line) {
- zephir_fcall_cache_entry *_12 = NULL, *_15 = NULL;
- zephir_nts_static zephir_fcall_cache_entry *_11 = NULL;
+ zephir_fcall_cache_entry *_11 = NULL, *_12 = NULL, *_15 = NULL;
unsigned char _1;
- int no, i, ZEPHIR_LAST_CALL_STATUS, _13;
- zval *line_param = NULL, *no_param = NULL, *pos = NULL, *start = NULL, *parsedLine, *end = NULL, *ch = NULL, _0, *_2 = NULL, _3 = zval_used_for_init, *_4 = NULL, _5 = zval_used_for_init, _6 = zval_used_for_init, *_7 = NULL, _8 = zval_used_for_init, _9 = zval_used_for_init, *_10 = NULL, *_14 = NULL, *_16 = NULL, _17 = zval_used_for_init, *_18 = NULL;
+ int no, i = 0, ZEPHIR_LAST_CALL_STATUS, _13;
+ zval *line_param = NULL, *no_param = NULL, *pos = NULL, *start = NULL, *parsedLine = NULL, *end = NULL, *ch = NULL, _0, *_2 = NULL, _3 = zval_used_for_init, *_4 = NULL, _5 = zval_used_for_init, _6 = zval_used_for_init, *_7 = NULL, _8 = zval_used_for_init, _9 = zval_used_for_init, *_10 = NULL, *_14 = NULL, *_16 = NULL, _17 = zval_used_for_init, *_18 = NULL;
zval *line = NULL;
ZEPHIR_MM_GROW();
@@ -225,7 +219,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, line) {
do {
if (ZEPHIR_IS_LONG(ch, '{')) {
ZEPHIR_INIT_LNVAR(_2);
- sub_function(_2, start, pos TSRMLS_CC);
+ zephir_sub_function(_2, start, pos);
ZEPHIR_SINIT_NVAR(_3);
ZVAL_LONG(&_3, zephir_get_intval(_2));
ZEPHIR_INIT_NVAR(_4);
@@ -244,9 +238,9 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, line) {
ZVAL_STRING(&_8, "Unclosed tag on the line %d", 0);
ZEPHIR_SINIT_NVAR(_9);
ZVAL_LONG(&_9, (no + 1));
- ZEPHIR_CALL_FUNCTION(&_10, "sprintf", &_11, &_8, &_9);
+ ZEPHIR_CALL_FUNCTION(&_10, "sprintf", &_11, 1, &_8, &_9);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_12, _10);
+ ZEPHIR_CALL_METHOD(NULL, _7, "__construct", &_12, 2, _10);
zephir_check_call_status();
zephir_throw_exception_debug(_7, "ice/mvc/view/engine/sleet/parser.zep", 107 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
@@ -256,19 +250,19 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, line) {
ZEPHIR_INIT_NVAR(end);
ZVAL_LONG(end, _13);
ZEPHIR_INIT_LNVAR(_14);
- sub_function(_14, end, start TSRMLS_CC);
+ zephir_sub_function(_14, end, start);
ZEPHIR_SINIT_NVAR(_8);
ZVAL_LONG(&_8, zephir_get_intval(_14));
ZEPHIR_INIT_NVAR(_7);
zephir_substr(_7, line, zephir_get_intval(start), zephir_get_intval(&_8), 0);
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "parse", &_15, _7);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "parse", &_15, 0, _7);
zephir_check_call_status();
zephir_concat_self(&parsedLine, _10 TSRMLS_CC);
break;
}
if (ZEPHIR_IS_LONG(ch, '%')) {
ZEPHIR_INIT_LNVAR(_2);
- sub_function(_2, start, pos TSRMLS_CC);
+ zephir_sub_function(_2, start, pos);
ZEPHIR_SINIT_NVAR(_3);
ZVAL_LONG(&_3, zephir_get_intval(_2));
ZEPHIR_INIT_NVAR(_4);
@@ -287,9 +281,9 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, line) {
ZVAL_STRING(&_9, "Unclosed tag on the line %d", 0);
ZEPHIR_SINIT_NVAR(_17);
ZVAL_LONG(&_17, (no + 1));
- ZEPHIR_CALL_FUNCTION(&_18, "sprintf", &_11, &_9, &_17);
+ ZEPHIR_CALL_FUNCTION(&_18, "sprintf", &_11, 1, &_9, &_17);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, _16, "__construct", &_12, _18);
+ ZEPHIR_CALL_METHOD(NULL, _16, "__construct", &_12, 2, _18);
zephir_check_call_status();
zephir_throw_exception_debug(_16, "ice/mvc/view/engine/sleet/parser.zep", 120 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
@@ -299,19 +293,19 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, line) {
ZEPHIR_INIT_NVAR(end);
ZVAL_LONG(end, _13);
ZEPHIR_INIT_LNVAR(_14);
- sub_function(_14, end, start TSRMLS_CC);
+ zephir_sub_function(_14, end, start);
ZEPHIR_SINIT_NVAR(_8);
ZVAL_LONG(&_8, zephir_get_intval(_14));
ZEPHIR_INIT_NVAR(_7);
zephir_substr(_7, line, zephir_get_intval(start), zephir_get_intval(&_8), 0);
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "parse", &_15, _7);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "parse", &_15, 0, _7);
zephir_check_call_status();
zephir_concat_self(&parsedLine, _10 TSRMLS_CC);
break;
}
if (ZEPHIR_IS_LONG(ch, '#')) {
ZEPHIR_INIT_LNVAR(_2);
- sub_function(_2, start, pos TSRMLS_CC);
+ zephir_sub_function(_2, start, pos);
ZEPHIR_SINIT_NVAR(_3);
ZVAL_LONG(&_3, zephir_get_intval(_2));
ZEPHIR_INIT_NVAR(_4);
@@ -330,9 +324,9 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, line) {
ZVAL_STRING(&_9, "Unclosed comment block on the line %d", 0);
ZEPHIR_SINIT_NVAR(_17);
ZVAL_LONG(&_17, (no + 1));
- ZEPHIR_CALL_FUNCTION(&_18, "sprintf", &_11, &_9, &_17);
+ ZEPHIR_CALL_FUNCTION(&_18, "sprintf", &_11, 1, &_9, &_17);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, _16, "__construct", &_12, _18);
+ ZEPHIR_CALL_METHOD(NULL, _16, "__construct", &_12, 2, _18);
zephir_check_call_status();
zephir_throw_exception_debug(_16, "ice/mvc/view/engine/sleet/parser.zep", 133 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
@@ -344,7 +338,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, line) {
break;
}
ZEPHIR_SINIT_NVAR(_3);
- sub_function(&_3, start, pos TSRMLS_CC);
+ zephir_sub_function(&_3, start, pos);
ZEPHIR_SINIT_NVAR(_5);
ZVAL_LONG(&_5, (zephir_get_numberval(&_3) + 1));
ZEPHIR_INIT_NVAR(_4);
@@ -379,9 +373,9 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parse) {
zend_bool _7;
HashTable *_5;
HashPosition _4;
- zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL;
+ zephir_fcall_cache_entry *_3 = NULL, *_10 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
- zval *expression_param = NULL, *php, *tokenized = NULL, *tokens, *token = NULL, *first = NULL, _0 = zval_used_for_init, _1 = zval_used_for_init, *_2 = NULL, **_6, *_8, *_9;
+ zval *expression_param = NULL, *php = NULL, *tokenized = NULL, *tokens = NULL, *token = NULL, *first = NULL, _0 = zval_used_for_init, _1 = zval_used_for_init, *_2 = NULL, **_6, *_8, *_9;
zval *expression = NULL;
ZEPHIR_MM_GROW();
@@ -408,13 +402,13 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parse) {
zephir_substr(_2, expression, 2 , -2 , 0);
ZEPHIR_CONCAT_SV(php, "");
RETURN_MM();
@@ -530,7 +523,6 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseControl) {
*/
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseEcho) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *expression, *_0 = NULL;
@@ -539,7 +531,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseEcho) {
- ZEPHIR_CALL_METHOD(&_0, this_ptr, "_parse", &_1, expression);
+ ZEPHIR_CALL_METHOD(&_0, this_ptr, "doparse", NULL, 140, expression);
zephir_check_call_status();
ZEPHIR_CONCAT_SVS(return_value, "");
RETURN_MM();
@@ -554,7 +546,6 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseEcho) {
*/
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseSet) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *expression, *_0 = NULL;
@@ -563,7 +554,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseSet) {
- ZEPHIR_CALL_METHOD(&_0, this_ptr, "_parse", &_1, expression);
+ ZEPHIR_CALL_METHOD(&_0, this_ptr, "doparse", NULL, 140, expression);
zephir_check_call_status();
ZEPHIR_CONCAT_SVS(return_value, "");
RETURN_MM();
@@ -578,7 +569,6 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseSet) {
*/
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseUse) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *expression, *_0 = NULL;
@@ -587,7 +577,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseUse) {
- ZEPHIR_CALL_METHOD(&_0, this_ptr, "_parse", &_1, expression);
+ ZEPHIR_CALL_METHOD(&_0, this_ptr, "doparse", NULL, 140, expression);
zephir_check_call_status();
ZEPHIR_CONCAT_SVS(return_value, "");
RETURN_MM();
@@ -600,12 +590,11 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseUse) {
* @param array tokens
* @return string
*/
-PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _parse) {
+PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, doParse) {
- zephir_nts_static zephir_fcall_cache_entry *_17 = NULL;
- zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_19 = NULL, *_20 = NULL;
+ zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_17 = NULL, *_19 = NULL, *_20 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
- zval *tokens, *i, *parsed, *prev = NULL, *next = NULL, *token = NULL, *filter = NULL, *seek = NULL, *filters = NULL, *_0 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_10 = NULL, *_11 = NULL, *_12, *_13, *_14, *_15 = NULL, *_16 = NULL, *_18 = NULL;
+ zval *tokens, *i = NULL, *parsed = NULL, *prev = NULL, *next = NULL, *token = NULL, *filter = NULL, *seek = NULL, *filters = NULL, *_0 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_10 = NULL, *_11 = NULL, *_12, *_13, *_14, *_15 = NULL, *_16 = NULL, *_18 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 1, 0, &tokens);
@@ -614,49 +603,49 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _parse) {
ZEPHIR_INIT_VAR(i);
object_init_ex(i, zephir_get_internal_ce(SS("arrayiterator") TSRMLS_CC));
- ZEPHIR_CALL_METHOD(NULL, i, "__construct", NULL, tokens);
+ ZEPHIR_CALL_METHOD(NULL, i, "__construct", NULL, 3, tokens);
zephir_check_call_status();
ZEPHIR_INIT_VAR(parsed);
ZVAL_STRING(parsed, "", 1);
ZEPHIR_INIT_VAR(prev);
ZVAL_STRING(prev, "", 1);
while (1) {
- ZEPHIR_CALL_METHOD(&_0, i, "valid", &_1);
+ ZEPHIR_CALL_METHOD(&_0, i, "valid", &_1, 141);
zephir_check_call_status();
if (!(zephir_is_true(_0))) {
break;
}
- ZEPHIR_CALL_METHOD(&token, i, "current", &_2);
+ ZEPHIR_CALL_METHOD(&token, i, "current", &_2, 142);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_4, i, "key", &_5);
+ ZEPHIR_CALL_METHOD(&_4, i, "key", &_5, 143);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_6);
ZVAL_LONG(_6, (zephir_get_numberval(_4) + 1));
- ZEPHIR_CALL_METHOD(&_3, i, "offsetexists", &_7, _6);
+ ZEPHIR_CALL_METHOD(&_3, i, "offsetexists", &_7, 144, _6);
zephir_check_call_status();
if (zephir_is_true(_3)) {
- ZEPHIR_CALL_METHOD(&_8, i, "key", &_5);
+ ZEPHIR_CALL_METHOD(&_8, i, "key", &_5, 143);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_6);
ZVAL_LONG(_6, (zephir_get_numberval(_8) + 1));
- ZEPHIR_CALL_METHOD(&next, i, "offsetget", &_9, _6);
+ ZEPHIR_CALL_METHOD(&next, i, "offsetget", &_9, 145, _6);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(next);
ZVAL_NULL(next);
}
if (ZEPHIR_IS_STRING(next, "|")) {
- ZEPHIR_CALL_METHOD(&_10, i, "key", &_5);
+ ZEPHIR_CALL_METHOD(&_10, i, "key", &_5, 143);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(seek);
ZVAL_LONG(seek, (zephir_get_numberval(_10) + 2));
- ZEPHIR_CALL_METHOD(&filter, i, "offsetget", &_9, seek);
+ ZEPHIR_CALL_METHOD(&filter, i, "offsetget", &_9, 145, seek);
zephir_check_call_status();
ZEPHIR_INIT_LNVAR(_11);
- _12 = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC);
+ _12 = zephir_fetch_nproperty_this(this_ptr, SL("filters"), PH_NOISY_CC);
zephir_array_fetch_long(&_13, filter, 1, PH_READONLY, "ice/mvc/view/engine/sleet/parser.zep", 294 TSRMLS_CC);
if (zephir_array_isset(_12, _13)) {
- _14 = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC);
+ _14 = zephir_fetch_nproperty_this(this_ptr, SL("filters"), PH_NOISY_CC);
ZEPHIR_OBS_NVAR(_11);
ZEPHIR_OBS_NVAR(_15);
zephir_array_fetch_long(&_15, filter, 1, PH_NOISY, "ice/mvc/view/engine/sleet/parser.zep", 294 TSRMLS_CC);
@@ -667,7 +656,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _parse) {
}
ZEPHIR_CPY_WRT(filter, _11);
ZEPHIR_INIT_NVAR(filters);
- array_init_size(filters, 22);
+ zephir_create_array(filters, 17, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_6);
ZVAL_STRING(_6, "camelize", 1);
zephir_array_fast_append(filters, _6);
@@ -720,13 +709,13 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _parse) {
ZVAL_STRING(_6, "unstrip_special", 1);
zephir_array_fast_append(filters, _6);
if (zephir_fast_in_array(filter, filters TSRMLS_CC)) {
- ZEPHIR_CALL_METHOD(&_16, this_ptr, "_token", &_17, token, prev, next);
+ ZEPHIR_CALL_METHOD(&_16, this_ptr, "token", &_17, 146, token, prev, next);
zephir_check_call_status();
ZEPHIR_INIT_LNVAR(_11);
ZEPHIR_CONCAT_SVSVS(_11, "$this->filter->sanitize(", _16, ", '", filter, "'");
zephir_concat_self(&parsed, _11 TSRMLS_CC);
} else {
- ZEPHIR_CALL_METHOD(&_16, this_ptr, "_token", &_17, token, prev, next);
+ ZEPHIR_CALL_METHOD(&_16, this_ptr, "token", &_17, 146, token, prev, next);
zephir_check_call_status();
ZEPHIR_INIT_LNVAR(_18);
ZEPHIR_CONCAT_VSV(_18, filter, "(", _16);
@@ -734,12 +723,12 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _parse) {
}
ZEPHIR_INIT_NVAR(_6);
ZVAL_LONG(_6, (zephir_get_numberval(seek) + 1));
- ZEPHIR_CALL_METHOD(&_16, i, "offsetexists", &_7, _6);
+ ZEPHIR_CALL_METHOD(&_16, i, "offsetexists", &_7, 144, _6);
zephir_check_call_status();
if (zephir_is_true(_16)) {
ZEPHIR_INIT_NVAR(_6);
ZVAL_LONG(_6, (zephir_get_numberval(seek) + 1));
- ZEPHIR_CALL_METHOD(&next, i, "offsetget", &_9, _6);
+ ZEPHIR_CALL_METHOD(&next, i, "offsetget", &_9, 145, _6);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(next);
@@ -752,17 +741,17 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _parse) {
} else {
zephir_concat_self_str(&parsed, SL(")") TSRMLS_CC);
}
- ZEPHIR_CALL_METHOD(NULL, i, "seek", &_19, seek);
+ ZEPHIR_CALL_METHOD(NULL, i, "seek", &_19, 147, seek);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, i, "next", &_20);
+ ZEPHIR_CALL_METHOD(NULL, i, "next", &_20, 148);
zephir_check_call_status();
continue;
}
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "_token", &_17, token, prev, next);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "token", &_17, 146, token, prev, next);
zephir_check_call_status();
zephir_concat_self(&parsed, _10 TSRMLS_CC);
ZEPHIR_CPY_WRT(prev, token);
- ZEPHIR_CALL_METHOD(NULL, i, "next", &_20);
+ ZEPHIR_CALL_METHOD(NULL, i, "next", &_20, 148);
zephir_check_call_status();
}
RETURN_CCTOR(parsed);
@@ -777,9 +766,9 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _parse) {
* @param mixed next
* @return mixed
*/
-PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _token) {
+PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, token) {
- zephir_nts_static zephir_fcall_cache_entry *_16 = NULL, *_17 = NULL;
+ zephir_fcall_cache_entry *_16 = NULL, *_17 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
unsigned char _12;
zend_bool _4, _5, _6, _10, _11, _15;
@@ -831,9 +820,9 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _token) {
}
if (_4) {
ZEPHIR_INIT_VAR(_7);
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_functions"), PH_NOISY_CC);
+ _8 = zephir_fetch_nproperty_this(this_ptr, SL("functions"), PH_NOISY_CC);
if (zephir_array_isset(_8, str)) {
- _9 = zephir_fetch_nproperty_this(this_ptr, SL("_functions"), PH_NOISY_CC);
+ _9 = zephir_fetch_nproperty_this(this_ptr, SL("functions"), PH_NOISY_CC);
zephir_array_fetch(&_7, _9, str, PH_NOISY, "ice/mvc/view/engine/sleet/parser.zep", 355 TSRMLS_CC);
} else {
ZEPHIR_CPY_WRT(_7, str);
@@ -873,7 +862,7 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _token) {
_12 = ZEPHIR_STRING_OFFSET(str, 0);
ZEPHIR_SINIT_VAR(_13);
ZVAL_LONG(&_13, _12);
- ZEPHIR_CALL_FUNCTION(&_14, "ctype_upper", NULL, &_13);
+ ZEPHIR_CALL_FUNCTION(&_14, "ctype_upper", NULL, 149, &_13);
zephir_check_call_status();
_15 = zephir_is_true(_14);
if (_15) {
@@ -909,17 +898,17 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _token) {
RETURN_MM_STRING("->", 1);
}
if (ZEPHIR_IS_STRING(token, ":")) {
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_env"), PH_NOISY_CC);
- Z_SET_ISREF_P(_8);
- ZEPHIR_CALL_FUNCTION(&_14, "end", &_16, _8);
- Z_UNSET_ISREF_P(_8);
+ _8 = zephir_fetch_nproperty_this(this_ptr, SL("env"), PH_NOISY_CC);
+ ZEPHIR_MAKE_REF(_8);
+ ZEPHIR_CALL_FUNCTION(&_14, "end", &_16, 90, _8);
+ ZEPHIR_UNREF(_8);
zephir_check_call_status();
do {
if (ZEPHIR_IS_LONG(_14, 1)) {
- _9 = zephir_fetch_nproperty_this(this_ptr, SL("_env"), PH_NOISY_CC);
- Z_SET_ISREF_P(_9);
- ZEPHIR_CALL_FUNCTION(NULL, "array_pop", &_17, _9);
- Z_UNSET_ISREF_P(_9);
+ _9 = zephir_fetch_nproperty_this(this_ptr, SL("env"), PH_NOISY_CC);
+ ZEPHIR_MAKE_REF(_9);
+ ZEPHIR_CALL_FUNCTION(NULL, "array_pop", &_17, 150, _9);
+ ZEPHIR_UNREF(_9);
zephir_check_call_status();
RETURN_MM_STRING(" : ", 1);
}
@@ -930,27 +919,27 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _token) {
if (ZEPHIR_IS_STRING(token, "?")) {
ZEPHIR_INIT_ZVAL_NREF(_8);
ZVAL_LONG(_8, 1);
- zephir_update_property_array_append(this_ptr, SL("_env"), _8 TSRMLS_CC);
+ zephir_update_property_array_append(this_ptr, SL("env"), _8 TSRMLS_CC);
RETURN_MM_STRING(" ? ", 1);
}
if (ZEPHIR_IS_STRING(token, "[")) {
ZEPHIR_INIT_ZVAL_NREF(_8);
ZVAL_LONG(_8, 2);
- zephir_update_property_array_append(this_ptr, SL("_env"), _8 TSRMLS_CC);
+ zephir_update_property_array_append(this_ptr, SL("env"), _8 TSRMLS_CC);
RETVAL_ZVAL(token, 1, 0);
RETURN_MM();
}
if (ZEPHIR_IS_STRING(token, "]")) {
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_env"), PH_NOISY_CC);
- Z_SET_ISREF_P(_8);
- ZEPHIR_CALL_FUNCTION(&_14, "end", &_16, _8);
- Z_UNSET_ISREF_P(_8);
+ _8 = zephir_fetch_nproperty_this(this_ptr, SL("env"), PH_NOISY_CC);
+ ZEPHIR_MAKE_REF(_8);
+ ZEPHIR_CALL_FUNCTION(&_14, "end", &_16, 90, _8);
+ ZEPHIR_UNREF(_8);
zephir_check_call_status();
if (ZEPHIR_IS_LONG(_14, 2)) {
- _9 = zephir_fetch_nproperty_this(this_ptr, SL("_env"), PH_NOISY_CC);
- Z_SET_ISREF_P(_9);
- ZEPHIR_CALL_FUNCTION(NULL, "array_pop", &_17, _9);
- Z_UNSET_ISREF_P(_9);
+ _9 = zephir_fetch_nproperty_this(this_ptr, SL("env"), PH_NOISY_CC);
+ ZEPHIR_MAKE_REF(_9);
+ ZEPHIR_CALL_FUNCTION(NULL, "array_pop", &_17, 150, _9);
+ ZEPHIR_UNREF(_9);
zephir_check_call_status();
}
RETVAL_ZVAL(token, 1, 0);
@@ -965,3 +954,43 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _token) {
}
+static zend_object_value zephir_init_properties_Ice_Mvc_View_Engine_Sleet_Parser(zend_class_entry *class_type TSRMLS_DC) {
+
+ zval *_3 = NULL;
+ zval *_0, *_1, *_2, *_4;
+
+ ZEPHIR_MM_GROW();
+
+ {
+ zval *this_ptr = NULL;
+ ZEPHIR_CREATE_OBJECT(this_ptr, class_type);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("env"), PH_NOISY_CC);
+ if (Z_TYPE_P(_0) == IS_NULL) {
+ ZEPHIR_INIT_VAR(_1);
+ array_init(_1);
+ zephir_update_property_this(this_ptr, SL("env"), _1 TSRMLS_CC);
+ }
+ _2 = zephir_fetch_nproperty_this(this_ptr, SL("filters"), PH_NOISY_CC);
+ if (Z_TYPE_P(_2) == IS_NULL) {
+ ZEPHIR_INIT_VAR(_3);
+ zephir_create_array(_3, 1, 0 TSRMLS_CC);
+ add_assoc_stringl_ex(_3, SS("capitalize"), SL("ucfirst"), 1);
+ zephir_update_property_this(this_ptr, SL("filters"), _3 TSRMLS_CC);
+ }
+ _4 = zephir_fetch_nproperty_this(this_ptr, SL("functions"), PH_NOISY_CC);
+ if (Z_TYPE_P(_4) == IS_NULL) {
+ ZEPHIR_INIT_NVAR(_3);
+ zephir_create_array(_3, 5, 0 TSRMLS_CC);
+ add_assoc_stringl_ex(_3, SS("content"), SL("$this->getContent"), 1);
+ add_assoc_stringl_ex(_3, SS("partial"), SL("$this->partial"), 1);
+ add_assoc_stringl_ex(_3, SS("load"), SL("$this->load"), 1);
+ add_assoc_stringl_ex(_3, SS("dump"), SL("$this->dump->vars"), 1);
+ add_assoc_stringl_ex(_3, SS("version"), SL("Ice\\Version::get"), 1);
+ zephir_update_property_this(this_ptr, SL("functions"), _3 TSRMLS_CC);
+ }
+ ZEPHIR_MM_RESTORE();
+ return Z_OBJVAL_P(this_ptr);
+ }
+
+}
+
diff --git a/ext/ice/mvc/view/engine/sleet/parser.zep.h b/ext/ice/mvc/view/engine/sleet/parser.zep.h
index 96dac268..7e13cf3e 100644
--- a/ext/ice/mvc/view/engine/sleet/parser.zep.h
+++ b/ext/ice/mvc/view/engine/sleet/parser.zep.h
@@ -11,8 +11,9 @@ PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseControl);
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseEcho);
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseSet);
PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, parseUse);
-PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _parse);
-PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, _token);
+PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, doParse);
+PHP_METHOD(Ice_Mvc_View_Engine_Sleet_Parser, token);
+static zend_object_value zephir_init_properties_Ice_Mvc_View_Engine_Sleet_Parser(zend_class_entry *class_type TSRMLS_DC);
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_view_engine_sleet_parser_text, 0, 0, 1)
ZEND_ARG_INFO(0, text)
@@ -44,11 +45,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_view_engine_sleet_parser_parseuse, 0, 0,
ZEND_ARG_INFO(0, expression)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_view_engine_sleet_parser__parse, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_view_engine_sleet_parser_doparse, 0, 0, 1)
ZEND_ARG_INFO(0, tokens)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_view_engine_sleet_parser__token, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_view_engine_sleet_parser_token, 0, 0, 1)
ZEND_ARG_INFO(0, token)
ZEND_ARG_INFO(0, prev)
ZEND_ARG_INFO(0, next)
@@ -63,7 +64,7 @@ ZEPHIR_INIT_FUNCS(ice_mvc_view_engine_sleet_parser_method_entry) {
PHP_ME(Ice_Mvc_View_Engine_Sleet_Parser, parseEcho, arginfo_ice_mvc_view_engine_sleet_parser_parseecho, ZEND_ACC_PRIVATE)
PHP_ME(Ice_Mvc_View_Engine_Sleet_Parser, parseSet, arginfo_ice_mvc_view_engine_sleet_parser_parseset, ZEND_ACC_PRIVATE)
PHP_ME(Ice_Mvc_View_Engine_Sleet_Parser, parseUse, arginfo_ice_mvc_view_engine_sleet_parser_parseuse, ZEND_ACC_PRIVATE)
- PHP_ME(Ice_Mvc_View_Engine_Sleet_Parser, _parse, arginfo_ice_mvc_view_engine_sleet_parser__parse, ZEND_ACC_PRIVATE)
- PHP_ME(Ice_Mvc_View_Engine_Sleet_Parser, _token, arginfo_ice_mvc_view_engine_sleet_parser__token, ZEND_ACC_PRIVATE)
- PHP_FE_END
+ PHP_ME(Ice_Mvc_View_Engine_Sleet_Parser, doParse, arginfo_ice_mvc_view_engine_sleet_parser_doparse, ZEND_ACC_PRIVATE)
+ PHP_ME(Ice_Mvc_View_Engine_Sleet_Parser, token, arginfo_ice_mvc_view_engine_sleet_parser_token, ZEND_ACC_PRIVATE)
+ PHP_FE_END
};
diff --git a/ext/ice/mvc/view/viewinterface.zep.h b/ext/ice/mvc/view/viewinterface.zep.h
index 9320c3cf..273b7097 100644
--- a/ext/ice/mvc/view/viewinterface.zep.h
+++ b/ext/ice/mvc/view/viewinterface.zep.h
@@ -11,5 +11,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_mvc_view_viewinterface_method_entry) {
PHP_ABSTRACT_ME(Ice_Mvc_View_ViewInterface, getEngines, NULL)
PHP_ABSTRACT_ME(Ice_Mvc_View_ViewInterface, render, arginfo_ice_mvc_view_viewinterface_render)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/pagination.zep.c b/ext/ice/pagination.zep.c
index 5b507a4a..111f4815 100644
--- a/ext/ice/pagination.zep.c
+++ b/ext/ice/pagination.zep.c
@@ -17,6 +17,7 @@
#include "kernel/memory.h"
#include "kernel/operators.h"
#include "kernel/exception.h"
+#include "kernel/math.h"
#include "kernel/array.h"
#include "kernel/concat.h"
#include "kernel/hash.h"
@@ -36,9 +37,9 @@ ZEPHIR_INIT_CLASS(Ice_Pagination) {
ZEPHIR_REGISTER_CLASS_EX(Ice, Pagination, ice, pagination, ice_arr_ce, ice_pagination_method_entry, 0);
- zend_declare_property_null(ice_pagination_ce, SL("_di"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_pagination_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_pagination_ce, SL("_tag"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_pagination_ce, SL("tag"), ZEND_ACC_PROTECTED TSRMLS_CC);
return SUCCESS;
@@ -47,14 +48,14 @@ ZEPHIR_INIT_CLASS(Ice_Pagination) {
PHP_METHOD(Ice_Pagination, getDi) {
- RETURN_MEMBER(this_ptr, "_di");
+ RETURN_MEMBER(this_ptr, "di");
}
PHP_METHOD(Ice_Pagination, getTag) {
- RETURN_MEMBER(this_ptr, "_tag");
+ RETURN_MEMBER(this_ptr, "tag");
}
@@ -66,8 +67,8 @@ PHP_METHOD(Ice_Pagination, getTag) {
PHP_METHOD(Ice_Pagination, __construct) {
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_1 = NULL;
- zval *options_param = NULL, *di = NULL, *_2 = NULL;
+ zephir_fcall_cache_entry *_0 = NULL, *_1 = NULL;
+ zval *options_param = NULL, *di = NULL, *_2 = NULL, *_3, *_4, *_5;
zval *options = NULL;
ZEPHIR_MM_GROW();
@@ -81,14 +82,21 @@ PHP_METHOD(Ice_Pagination, __construct) {
}
- ZEPHIR_CALL_PARENT(NULL, ice_pagination_ce, this_ptr, "__construct", &_0, options);
+ ZEPHIR_CALL_PARENT(NULL, ice_pagination_ce, this_ptr, "__construct", &_0, 6, options);
zephir_check_call_status();
- ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_1);
+ ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_1, 8);
zephir_check_call_status();
- zephir_update_property_this(this_ptr, SL("_di"), di TSRMLS_CC);
- ZEPHIR_CALL_METHOD(&_2, di, "gettag", NULL);
+ zephir_update_property_this(this_ptr, SL("di"), di TSRMLS_CC);
+ ZEPHIR_INIT_VAR(_3);
+ ZVAL_STRING(_3, "tag", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_VAR(_4);
+ ZVAL_NULL(_4);
+ ZEPHIR_INIT_VAR(_5);
+ ZVAL_BOOL(_5, 1);
+ ZEPHIR_CALL_METHOD(&_2, di, "get", NULL, 0, _3, _4, _5);
+ zephir_check_temp_parameter(_3);
zephir_check_call_status();
- zephir_update_property_this(this_ptr, SL("_tag"), _2 TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("tag"), _2 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
@@ -100,11 +108,10 @@ PHP_METHOD(Ice_Pagination, __construct) {
*/
PHP_METHOD(Ice_Pagination, calculate) {
- zval *_13;
- zephir_nts_static zephir_fcall_cache_entry *_11 = NULL;
+ zval *_11;
zend_bool _2;
- int limit, page, pages, total, previous, next, ZEPHIR_LAST_CALL_STATUS;
- zval *items = NULL, *data = NULL, *_0, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, _6, _7, _8, _9, *_10 = NULL, *_12;
+ int limit = 0, page = 0, pages = 0, total = 0, previous = 0, next = 0, ZEPHIR_LAST_CALL_STATUS;
+ zval *items = NULL, *data = NULL, *_0, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, _7, _8, _9, *_10 = NULL;
ZEPHIR_MM_GROW();
@@ -112,7 +119,7 @@ PHP_METHOD(Ice_Pagination, calculate) {
array_init(_0);
ZEPHIR_INIT_VAR(_1);
ZVAL_STRING(_1, "data", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&items, this_ptr, "get", NULL, _1, _0);
+ ZEPHIR_CALL_METHOD(&items, this_ptr, "get", NULL, 0, _1, _0);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
_2 = Z_TYPE_P(items) != IS_ARRAY;
@@ -124,7 +131,7 @@ PHP_METHOD(Ice_Pagination, calculate) {
return;
}
if (zephir_instance_of_ev(items, ice_arr_ce TSRMLS_CC)) {
- ZEPHIR_CALL_METHOD(&data, items, "all", NULL);
+ ZEPHIR_CALL_METHOD(&data, items, "all", NULL, 0);
zephir_check_call_status();
} else {
ZEPHIR_CPY_WRT(data, items);
@@ -133,7 +140,7 @@ PHP_METHOD(Ice_Pagination, calculate) {
ZVAL_STRING(_1, "limit", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_VAR(_4);
ZVAL_LONG(_4, 10);
- ZEPHIR_CALL_METHOD(&_3, this_ptr, "get", NULL, _1, _4);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "get", NULL, 27, _1, _4);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
limit = zephir_get_intval(_3);
@@ -141,18 +148,22 @@ PHP_METHOD(Ice_Pagination, calculate) {
ZVAL_STRING(_1, "page", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_NVAR(_4);
ZVAL_LONG(_4, 1);
- ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", NULL, _1, _4);
+ ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", NULL, 27, _1, _4);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
page = zephir_get_intval(_5);
total = zephir_fast_count_int(items TSRMLS_CC);
- ZEPHIR_INIT_NVAR(_1);
- ZEPHIR_SINIT_VAR(_6);
- ZVAL_LONG(&_6, limit);
+ ZEPHIR_INIT_VAR(_6);
+ if (limit) {
+ ZEPHIR_INIT_NVAR(_6);
+ ZVAL_LONG(_6, limit);
+ } else {
+ ZEPHIR_INIT_NVAR(_6);
+ ZVAL_LONG(_6, 1);
+ }
ZEPHIR_SINIT_VAR(_7);
- ZVAL_DOUBLE(&_7, zephir_safe_div_long_long(total, zephir_get_intval(&_6) TSRMLS_CC));
- zephir_ceil(_1, &_7 TSRMLS_CC);
- pages = zephir_get_intval(_1);
+ ZVAL_DOUBLE(&_7, zephir_safe_div_long_long(total, zephir_get_intval(_6) TSRMLS_CC));
+ pages = (int) zephir_ceil(&_7 TSRMLS_CC);
if (page <= 0) {
page = 1;
}
@@ -160,54 +171,244 @@ PHP_METHOD(Ice_Pagination, calculate) {
ZVAL_LONG(&_8, (limit * ((page - 1))));
ZEPHIR_SINIT_VAR(_9);
ZVAL_LONG(&_9, limit);
- ZEPHIR_CALL_FUNCTION(&_10, "array_slice", &_11, data, &_8, &_9);
+ ZEPHIR_CALL_FUNCTION(&_10, "array_slice", NULL, 95, data, &_8, &_9);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_4);
- ZVAL_STRING(_4, "items", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, _4, _10);
- zephir_check_temp_parameter(_4);
+ ZEPHIR_INIT_NVAR(_1);
+ ZVAL_STRING(_1, "items", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, _1, _10);
+ zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (page < pages) {
next = (page + 1);
} else {
next = pages;
}
+ ZEPHIR_INIT_NVAR(_1);
+ ZVAL_STRING(_1, "next", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_NVAR(_4);
- ZVAL_STRING(_4, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_INIT_VAR(_12);
- ZVAL_LONG(_12, next);
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, _4, _12);
- zephir_check_temp_parameter(_4);
+ ZVAL_LONG(_4, next);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, _1, _4);
+ zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (page > 1) {
previous = (page - 1);
} else {
previous = 1;
}
- ZEPHIR_INIT_VAR(_13);
- array_init_size(_13, 8);
- add_assoc_long_ex(_13, SS("first"), 1);
- ZEPHIR_INIT_NVAR(_4);
- ZVAL_LONG(_4, previous);
- zephir_array_update_string(&_13, SL("previous"), &_4, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_NVAR(_4);
- ZVAL_LONG(_4, page);
- zephir_array_update_string(&_13, SL("current"), &_4, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_NVAR(_4);
- ZVAL_LONG(_4, pages);
- zephir_array_update_string(&_13, SL("last"), &_4, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_NVAR(_4);
- ZVAL_LONG(_4, pages);
- zephir_array_update_string(&_13, SL("pages"), &_4, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_NVAR(_4);
- ZVAL_LONG(_4, total);
- zephir_array_update_string(&_13, SL("total"), &_4, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", NULL, _13);
+ ZEPHIR_INIT_VAR(_11);
+ zephir_create_array(_11, 6, 0 TSRMLS_CC);
+ add_assoc_long_ex(_11, SS("first"), 1);
+ ZEPHIR_INIT_NVAR(_1);
+ ZVAL_LONG(_1, previous);
+ zephir_array_update_string(&_11, SL("previous"), &_1, PH_COPY | PH_SEPARATE);
+ ZEPHIR_INIT_NVAR(_1);
+ ZVAL_LONG(_1, page);
+ zephir_array_update_string(&_11, SL("current"), &_1, PH_COPY | PH_SEPARATE);
+ ZEPHIR_INIT_NVAR(_1);
+ ZVAL_LONG(_1, pages);
+ zephir_array_update_string(&_11, SL("last"), &_1, PH_COPY | PH_SEPARATE);
+ ZEPHIR_INIT_NVAR(_1);
+ ZVAL_LONG(_1, pages);
+ zephir_array_update_string(&_11, SL("pages"), &_1, PH_COPY | PH_SEPARATE);
+ ZEPHIR_INIT_NVAR(_1);
+ ZVAL_LONG(_1, total);
+ zephir_array_update_string(&_11, SL("total"), &_1, PH_COPY | PH_SEPARATE);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", NULL, 0, _11);
zephir_check_call_status();
RETURN_THIS();
}
+/**
+ * Prepare list button.
+ *
+ * @param mixed page Name or page number
+ * @param string url URL with pagination
+ * @param boolean active If active create link else span
+ * @param string symbol HTML symbol to add
+ * @return string HTML
+ */
+PHP_METHOD(Ice_Pagination, prepareButton) {
+
+ zval *_7 = NULL;
+ int ZEPHIR_LAST_CALL_STATUS;
+ zend_bool active, pages, _9;
+ zval *url = NULL;
+ zval *page = NULL, *url_param = NULL, *active_param = NULL, *symbol = NULL, *query = NULL, *i18n = NULL, *title = NULL, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5, *_6, *_8 = NULL, *_10 = NULL, *_11 = NULL, *_12, *_13;
+
+ ZEPHIR_MM_GROW();
+ zephir_fetch_params(1, 1, 3, &page, &url_param, &active_param, &symbol);
+
+ ZEPHIR_SEPARATE_PARAM(page);
+ if (!url_param) {
+ ZEPHIR_INIT_VAR(url);
+ ZVAL_EMPTY_STRING(url);
+ } else {
+ zephir_get_strval(url, url_param);
+ }
+ if (!active_param) {
+ active = 0;
+ } else {
+ active = zephir_get_boolval(active_param);
+ }
+ if (!symbol) {
+ ZEPHIR_CPY_WRT(symbol, ZEPHIR_GLOBAL(global_null));
+ } else {
+ ZEPHIR_SEPARATE_PARAM(symbol);
+ }
+
+
+ pages = 0;
+ do {
+ if (ZEPHIR_IS_STRING(page, "first")) {
+ ZEPHIR_INIT_NVAR(symbol);
+ ZVAL_STRING(symbol, "«", 1);
+ break;
+ }
+ if (ZEPHIR_IS_STRING(page, "previous")) {
+ ZEPHIR_INIT_NVAR(symbol);
+ ZVAL_STRING(symbol, "‹", 1);
+ break;
+ }
+ if (ZEPHIR_IS_STRING(page, "next")) {
+ ZEPHIR_INIT_NVAR(symbol);
+ ZVAL_STRING(symbol, "›", 1);
+ break;
+ }
+ if (ZEPHIR_IS_STRING(page, "last")) {
+ ZEPHIR_INIT_NVAR(symbol);
+ ZVAL_STRING(symbol, "»", 1);
+ break;
+ }
+ ZEPHIR_INIT_VAR(_0);
+ if (!(zephir_is_true(symbol))) {
+ ZEPHIR_CPY_WRT(_0, page);
+ } else {
+ ZEPHIR_CPY_WRT(_0, symbol);
+ }
+ ZEPHIR_CPY_WRT(symbol, _0);
+ pages = 1;
+ break;
+ } while(0);
+
+ if (!(active)) {
+ ZEPHIR_INIT_LNVAR(_0);
+ if (pages) {
+ ZEPHIR_INIT_NVAR(_0);
+ ZVAL_STRING(_0, "active", 1);
+ } else {
+ ZEPHIR_INIT_NVAR(_0);
+ ZVAL_STRING(_0, "disabled", 1);
+ }
+ ZEPHIR_CONCAT_SVSVS(return_value, "", symbol, " ");
+ RETURN_MM();
+ }
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
+ ZEPHIR_INIT_VAR(_3);
+ ZVAL_STRING(_3, "request", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_VAR(_4);
+ ZVAL_NULL(_4);
+ ZEPHIR_INIT_VAR(_5);
+ ZVAL_BOOL(_5, 1);
+ ZEPHIR_CALL_METHOD(&_2, _1, "get", NULL, 0, _3, _4, _5);
+ zephir_check_temp_parameter(_3);
+ zephir_check_call_status();
+ ZEPHIR_CALL_METHOD(&query, _2, "getquery", NULL, 0);
+ zephir_check_call_status();
+ _6 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
+ ZEPHIR_INIT_NVAR(_3);
+ ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&i18n, _6, "get", NULL, 0, _3);
+ zephir_check_temp_parameter(_3);
+ zephir_check_call_status();
+ ZEPHIR_INIT_VAR(title);
+ if (pages) {
+ if (zephir_is_true(i18n)) {
+ ZEPHIR_INIT_VAR(_7);
+ zephir_create_array(_7, 1, 0 TSRMLS_CC);
+ zephir_array_fast_append(_7, page);
+ ZEPHIR_INIT_NVAR(_3);
+ ZVAL_STRING(_3, "page: %d", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, 0, _3, _7);
+ zephir_check_temp_parameter(_3);
+ zephir_check_call_status();
+ } else {
+ ZVAL_NULL(title);
+ }
+ } else {
+ if (zephir_is_true(i18n)) {
+ ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, 0, page);
+ zephir_check_call_status();
+ } else {
+ ZEPHIR_INIT_NVAR(title);
+ ZVAL_NULL(title);
+ }
+ ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", NULL, 0, page);
+ zephir_check_call_status();
+ ZEPHIR_CPY_WRT(page, _8);
+ }
+ ZEPHIR_INIT_NVAR(_3);
+ ZVAL_STRING(_3, "query", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_8, this_ptr, "has", NULL, 0, _3);
+ zephir_check_temp_parameter(_3);
+ zephir_check_call_status();
+ _9 = zephir_is_true(_8);
+ if (_9) {
+ ZEPHIR_INIT_NVAR(_3);
+ ZVAL_STRING(_3, "query", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "get", NULL, 27, _3);
+ zephir_check_temp_parameter(_3);
+ zephir_check_call_status();
+ _9 = !zephir_is_true(_10);
+ }
+ if (_9) {
+ ZEPHIR_INIT_LNVAR(_0);
+ if (!(!url) && Z_STRLEN_P(url)) {
+ ZEPHIR_INIT_NVAR(_0);
+ ZVAL_STRING(_0, "/", 1);
+ } else {
+ ZEPHIR_INIT_NVAR(_0);
+ ZVAL_STRING(_0, "", 1);
+ }
+ ZEPHIR_INIT_NVAR(_3);
+ ZVAL_STRING(_3, "hash", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_11, this_ptr, "get", NULL, 27, _3);
+ zephir_check_temp_parameter(_3);
+ zephir_check_call_status();
+ ZEPHIR_INIT_VAR(_12);
+ ZEPHIR_CONCAT_VVV(_12, _0, page, _11);
+ zephir_concat_self(&url, _12 TSRMLS_CC);
+ } else {
+ if (ZEPHIR_GT_LONG(page, 1)) {
+ ZEPHIR_INIT_NVAR(_3);
+ ZVAL_STRING(_3, "page", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(NULL, query, "set", NULL, 0, _3, page);
+ zephir_check_temp_parameter(_3);
+ zephir_check_call_status();
+ } else {
+ ZEPHIR_INIT_NVAR(_3);
+ ZVAL_STRING(_3, "page", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(NULL, query, "remove", NULL, 0, _3);
+ zephir_check_temp_parameter(_3);
+ zephir_check_call_status();
+ }
+ }
+ _13 = zephir_fetch_nproperty_this(this_ptr, SL("tag"), PH_NOISY_CC);
+ ZEPHIR_INIT_NVAR(_7);
+ zephir_create_array(_7, 4, 0 TSRMLS_CC);
+ zephir_array_fast_append(_7, url);
+ zephir_array_fast_append(_7, symbol);
+ zephir_array_fast_append(_7, title);
+ ZEPHIR_CALL_METHOD(&_11, query, "all", NULL, 0);
+ zephir_check_call_status();
+ zephir_array_update_string(&_7, SL("query"), &_11, PH_COPY | PH_SEPARATE);
+ ZEPHIR_CALL_METHOD(&_8, _13, "a", NULL, 0, _7);
+ zephir_check_call_status();
+ ZEPHIR_CONCAT_SVS(return_value, "", _8, " ");
+ RETURN_MM();
+
+}
+
/**
* Prepare minimal pagination.
* Previous 1 [2] 3 4 5 6 Next
@@ -218,11 +419,11 @@ PHP_METHOD(Ice_Pagination, calculate) {
*/
PHP_METHOD(Ice_Pagination, minimal) {
- zephir_fcall_cache_entry *_17 = NULL, *_19 = NULL, *_20 = NULL, *_22 = NULL, *_23 = NULL;
- zend_bool _14;
- int i, ZEPHIR_LAST_CALL_STATUS, _15;
- zval *parameters = NULL, *_1, *_11 = NULL, *_21 = NULL;
- zval *url_param = NULL, *parameters_param = NULL, *html = NULL, *query = NULL, *i18n = NULL, *title = NULL, *_0, *_2 = NULL, *_3, *_4 = NULL, *_5, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9, *_10 = NULL, *_12 = NULL, *_13 = NULL, *_16 = NULL, *_18 = NULL, _24 = zval_used_for_init, *_25 = NULL, *_26 = NULL, *_27 = NULL;
+ zend_bool _9;
+ zephir_fcall_cache_entry *_7 = NULL;
+ int i = 0, ZEPHIR_LAST_CALL_STATUS, _10;
+ zval *parameters = NULL, *_1;
+ zval *url_param = NULL, *parameters_param = NULL, *html = NULL, *_0, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_8 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL, *_15, *_16 = NULL;
zval *url = NULL;
ZEPHIR_MM_GROW();
@@ -242,217 +443,91 @@ PHP_METHOD(Ice_Pagination, minimal) {
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("tag"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_1);
- array_init_size(_1, 2);
+ zephir_create_array(_1, 1, 0 TSRMLS_CC);
add_assoc_stringl_ex(_1, SS("class"), SL("pagination"), 1);
ZEPHIR_INIT_VAR(_2);
ZVAL_STRING(_2, "ul", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&html, _0, "taghtml", NULL, _2, parameters, _1);
+ ZEPHIR_CALL_METHOD(&html, _0, "taghtml", NULL, 0, _2, parameters, _1);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- _3 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
- ZEPHIR_CALL_METHOD(&_4, _3, "getrequest", NULL);
- zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&query, _4, "getquery", NULL);
- zephir_check_call_status();
- _5 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _5, "get", NULL, _2);
+ ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_6, this_ptr, "get", NULL, _2);
+ ZVAL_STRING(_2, "previous", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "previous", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, this_ptr, "get", NULL, _2);
+ ZEPHIR_INIT_VAR(_6);
+ ZVAL_BOOL(_6, ZEPHIR_GT(_4, _5));
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "preparebutton", &_7, 0, _2, url, _6);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- if (ZEPHIR_GT(_6, _7)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "previous", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", NULL, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "set", NULL, _2, _8);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "previous", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _9 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_VAR(_11);
- array_init_size(_11, 7);
- zephir_array_fast_append(_11, url);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "‹", 1);
- zephir_array_fast_append(_11, _2);
- zephir_array_fast_append(_11, title);
- ZEPHIR_CALL_METHOD(&_12, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_11, SL("query"), &_12, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_11, SS("rel"), SL("prev"), 1);
- ZEPHIR_CALL_METHOD(&_10, _9, "a", NULL, _11);
- zephir_check_call_status();
- ZEPHIR_INIT_VAR(_13);
- ZEPHIR_CONCAT_SVS(_13, "", _10, " ");
- zephir_concat_self(&html, _13 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("‹ ") TSRMLS_CC);
- }
+ zephir_concat_self(&html, _3 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "pages", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(_16, _8);
- _15 = 1;
- _14 = 0;
- if (ZEPHIR_GE_LONG(_16, _15)) {
+ ZEPHIR_CPY_WRT(_11, _8);
+ _10 = 1;
+ _9 = 0;
+ if (ZEPHIR_GE_LONG(_11, _10)) {
while (1) {
- if (_14) {
- _15++;
- if (!(ZEPHIR_GE_LONG(_16, _15))) {
+ if (_9) {
+ _10++;
+ if (!(ZEPHIR_GE_LONG(_11, _10))) {
break;
}
} else {
- _14 = 1;
+ _9 = 1;
}
- i = _15;
+ i = _10;
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", &_17, _2);
+ ZEPHIR_CALL_METHOD(&_12, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(title);
- if (!ZEPHIR_IS_LONG_IDENTICAL(_8, i)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_INIT_NVAR(_18);
- ZVAL_LONG(_18, i);
- ZEPHIR_CALL_METHOD(NULL, query, "set", &_19, _2, _18);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_11);
- array_init_size(_11, 2);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_LONG(_2, i);
- zephir_array_fast_append(_11, _2);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page: %d", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", &_20, _2, _11);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZVAL_NULL(title);
- }
- _9 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_21);
- array_init_size(_21, 6);
- zephir_array_fast_append(_21, url);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_LONG(_2, i);
- zephir_array_fast_append(_21, _2);
- zephir_array_fast_append(_21, title);
- ZEPHIR_CALL_METHOD(&_12, query, "all", &_22);
- zephir_check_call_status();
- zephir_array_update_string(&_21, SL("query"), &_12, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_METHOD(&_10, _9, "a", NULL, _21);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_13);
- ZEPHIR_CONCAT_SVS(_13, "", _10, " ");
- zephir_concat_self(&html, _13 TSRMLS_CC);
- } else {
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", &_23, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- ZEPHIR_SINIT_NVAR(_24);
- ZVAL_LONG(&_24, i);
- ZEPHIR_INIT_LNVAR(_25);
- ZEPHIR_CONCAT_SVSVS(_25, "", &_24, " ");
- zephir_concat_self(&html, _25 TSRMLS_CC);
- }
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, i);
+ ZEPHIR_INIT_NVAR(_6);
+ ZVAL_BOOL(_6, !ZEPHIR_IS_LONG_IDENTICAL(_12, i));
+ ZEPHIR_CALL_METHOD(&_8, this_ptr, "preparebutton", &_7, 0, _2, url, _6);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _8 TSRMLS_CC);
}
}
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", &_17, _2);
+ ZEPHIR_CALL_METHOD(&_13, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "get", &_17, _2);
+ ZEPHIR_CALL_METHOD(&_14, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- if (ZEPHIR_LT(_8, _10)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_12, this_ptr, "get", &_17, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "set", NULL, _2, _12);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _9 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_11);
- array_init_size(_11, 7);
- zephir_array_fast_append(_11, url);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "›", 1);
- zephir_array_fast_append(_11, _2);
- zephir_array_fast_append(_11, title);
- ZEPHIR_CALL_METHOD(&_27, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_11, SL("query"), &_27, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_11, SS("rel"), SL("next"), 1);
- ZEPHIR_CALL_METHOD(&_26, _9, "a", NULL, _11);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_13);
- ZEPHIR_CONCAT_SVS(_13, "", _26, " ");
- zephir_concat_self(&html, _13 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("› ") TSRMLS_CC);
- }
- _9 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "next", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_NVAR(_6);
+ ZVAL_BOOL(_6, ZEPHIR_LT(_13, _14));
+ ZEPHIR_CALL_METHOD(&_12, this_ptr, "preparebutton", &_7, 0, _2, url, _6);
+ zephir_check_temp_parameter(_2);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _12 TSRMLS_CC);
+ _15 = zephir_fetch_nproperty_this(this_ptr, SL("tag"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "ul", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, _9, "endtag", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_16, _15, "endtag", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- zephir_concat_self(&html, _8 TSRMLS_CC);
+ zephir_concat_self(&html, _16 TSRMLS_CC);
RETURN_CCTOR(html);
}
@@ -467,11 +542,11 @@ PHP_METHOD(Ice_Pagination, minimal) {
*/
PHP_METHOD(Ice_Pagination, basic) {
- zephir_fcall_cache_entry *_19 = NULL, *_21 = NULL, *_22 = NULL, *_24 = NULL, *_25 = NULL;
- zend_bool _16;
- int i, ZEPHIR_LAST_CALL_STATUS, _17;
- zval *parameters = NULL, *_1, *_10 = NULL, *_23 = NULL;
- zval *url_param = NULL, *parameters_param = NULL, *html = NULL, *query = NULL, *i18n = NULL, *title = NULL, *_0, *_2 = NULL, *_3, *_4 = NULL, *_5, *_6 = NULL, *_7 = NULL, *_8, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL, *_15 = NULL, *_18 = NULL, *_20 = NULL, _26 = zval_used_for_init, *_27 = NULL;
+ zend_bool _12;
+ zephir_fcall_cache_entry *_7 = NULL;
+ int i = 0, ZEPHIR_LAST_CALL_STATUS, _13;
+ zval *parameters = NULL, *_1;
+ zval *url_param = NULL, *parameters_param = NULL, *html = NULL, *_0, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL, *_17 = NULL, *_18 = NULL, *_19 = NULL, *_20 = NULL, *_21, *_22 = NULL;
zval *url = NULL;
ZEPHIR_MM_GROW();
@@ -491,314 +566,127 @@ PHP_METHOD(Ice_Pagination, basic) {
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("tag"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_1);
- array_init_size(_1, 2);
+ zephir_create_array(_1, 1, 0 TSRMLS_CC);
add_assoc_stringl_ex(_1, SS("class"), SL("pagination"), 1);
ZEPHIR_INIT_VAR(_2);
ZVAL_STRING(_2, "ul", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&html, _0, "taghtml", NULL, _2, parameters, _1);
+ ZEPHIR_CALL_METHOD(&html, _0, "taghtml", NULL, 0, _2, parameters, _1);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- _3 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
- ZEPHIR_CALL_METHOD(&_4, _3, "getrequest", NULL);
- zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&query, _4, "getquery", NULL);
- zephir_check_call_status();
- _5 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _5, "get", NULL, _2);
+ ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_6, this_ptr, "get", NULL, _2);
+ ZVAL_STRING(_2, "first", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "first", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, this_ptr, "get", NULL, _2);
+ ZEPHIR_INIT_VAR(_6);
+ ZVAL_BOOL(_6, !ZEPHIR_IS_EQUAL(_4, _5));
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "preparebutton", &_7, 0, _2, url, _6);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- if (!ZEPHIR_IS_EQUAL(_6, _7)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "remove", NULL, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "first", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_VAR(_10);
- array_init_size(_10, 7);
- zephir_array_fast_append(_10, url);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "«", 1);
- zephir_array_fast_append(_10, _2);
- zephir_array_fast_append(_10, title);
- ZEPHIR_CALL_METHOD(&_11, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_10, SL("query"), &_11, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_10, SS("rel"), SL("first"), 1);
- ZEPHIR_CALL_METHOD(&_9, _8, "a", NULL, _10);
- zephir_check_call_status();
- ZEPHIR_INIT_VAR(_12);
- ZEPHIR_CONCAT_SVS(_12, "", _9, " ");
- zephir_concat_self(&html, _12 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("« ") TSRMLS_CC);
- }
+ zephir_concat_self(&html, _3 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_9, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_9, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "previous", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_11, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- if (ZEPHIR_GT(_9, _11)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "previous", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_13, this_ptr, "get", NULL, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "set", NULL, _2, _13);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "previous", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_10);
- array_init_size(_10, 7);
- zephir_array_fast_append(_10, url);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "‹", 1);
- zephir_array_fast_append(_10, _2);
- zephir_array_fast_append(_10, title);
- ZEPHIR_CALL_METHOD(&_15, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_10, SL("query"), &_15, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_10, SS("rel"), SL("prev"), 1);
- ZEPHIR_CALL_METHOD(&_14, _8, "a", NULL, _10);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_12);
- ZEPHIR_CONCAT_SVS(_12, "", _14, " ");
- zephir_concat_self(&html, _12 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("‹ ") TSRMLS_CC);
- }
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "previous", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_NVAR(_6);
+ ZVAL_BOOL(_6, ZEPHIR_GT(_9, _10));
+ ZEPHIR_CALL_METHOD(&_8, this_ptr, "preparebutton", &_7, 0, _2, url, _6);
+ zephir_check_temp_parameter(_2);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _8 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "pages", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_9, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_11, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(_18, _9);
- _17 = 1;
- _16 = 0;
- if (ZEPHIR_GE_LONG(_18, _17)) {
+ ZEPHIR_CPY_WRT(_14, _11);
+ _13 = 1;
+ _12 = 0;
+ if (ZEPHIR_GE_LONG(_14, _13)) {
while (1) {
- if (_16) {
- _17++;
- if (!(ZEPHIR_GE_LONG(_18, _17))) {
+ if (_12) {
+ _13++;
+ if (!(ZEPHIR_GE_LONG(_14, _13))) {
break;
}
} else {
- _16 = 1;
+ _12 = 1;
}
- i = _17;
+ i = _13;
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_9, this_ptr, "get", &_19, _2);
+ ZEPHIR_CALL_METHOD(&_15, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(title);
- if (!ZEPHIR_IS_LONG_IDENTICAL(_9, i)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_INIT_NVAR(_20);
- ZVAL_LONG(_20, i);
- ZEPHIR_CALL_METHOD(NULL, query, "set", &_21, _2, _20);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_10);
- array_init_size(_10, 2);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_LONG(_2, i);
- zephir_array_fast_append(_10, _2);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page: %d", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", &_22, _2, _10);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZVAL_NULL(title);
- }
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_23);
- array_init_size(_23, 6);
- zephir_array_fast_append(_23, url);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_LONG(_2, i);
- zephir_array_fast_append(_23, _2);
- zephir_array_fast_append(_23, title);
- ZEPHIR_CALL_METHOD(&_13, query, "all", &_24);
- zephir_check_call_status();
- zephir_array_update_string(&_23, SL("query"), &_13, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_METHOD(&_11, _8, "a", NULL, _23);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_12);
- ZEPHIR_CONCAT_SVS(_12, "", _11, " ");
- zephir_concat_self(&html, _12 TSRMLS_CC);
- } else {
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", &_25, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- ZEPHIR_SINIT_NVAR(_26);
- ZVAL_LONG(&_26, i);
- ZEPHIR_INIT_LNVAR(_27);
- ZEPHIR_CONCAT_SVSVS(_27, "", &_26, " ");
- zephir_concat_self(&html, _27 TSRMLS_CC);
- }
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, i);
+ ZEPHIR_INIT_NVAR(_6);
+ ZVAL_BOOL(_6, !ZEPHIR_IS_LONG_IDENTICAL(_15, i));
+ ZEPHIR_CALL_METHOD(&_11, this_ptr, "preparebutton", &_7, 0, _2, url, _6);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _11 TSRMLS_CC);
}
}
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_9, this_ptr, "get", &_19, _2);
+ ZEPHIR_CALL_METHOD(&_16, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_11, this_ptr, "get", &_19, _2);
+ ZEPHIR_CALL_METHOD(&_17, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- if (ZEPHIR_LT(_9, _11)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_13, this_ptr, "get", &_19, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "set", NULL, _2, _13);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_10);
- array_init_size(_10, 7);
- zephir_array_fast_append(_10, url);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "›", 1);
- zephir_array_fast_append(_10, _2);
- zephir_array_fast_append(_10, title);
- ZEPHIR_CALL_METHOD(&_15, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_10, SL("query"), &_15, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_10, SS("rel"), SL("next"), 1);
- ZEPHIR_CALL_METHOD(&_14, _8, "a", NULL, _10);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_12);
- ZEPHIR_CONCAT_SVS(_12, "", _14, " ");
- zephir_concat_self(&html, _12 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("› ") TSRMLS_CC);
- }
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "next", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_NVAR(_6);
+ ZVAL_BOOL(_6, ZEPHIR_LT(_16, _17));
+ ZEPHIR_CALL_METHOD(&_15, this_ptr, "preparebutton", &_7, 0, _2, url, _6);
+ zephir_check_temp_parameter(_2);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _15 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_9, this_ptr, "get", &_19, _2);
+ ZEPHIR_CALL_METHOD(&_19, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "last", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_11, this_ptr, "get", &_19, _2);
+ ZEPHIR_CALL_METHOD(&_20, this_ptr, "get", NULL, 27, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- if (!ZEPHIR_IS_EQUAL(_9, _11)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "last", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_13, this_ptr, "get", &_19, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "set", NULL, _2, _13);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "last", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _2);
- zephir_check_temp_parameter(_2);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_10);
- array_init_size(_10, 7);
- zephir_array_fast_append(_10, url);
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "»", 1);
- zephir_array_fast_append(_10, _2);
- zephir_array_fast_append(_10, title);
- ZEPHIR_CALL_METHOD(&_15, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_10, SL("query"), &_15, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_10, SS("rel"), SL("last"), 1);
- ZEPHIR_CALL_METHOD(&_14, _8, "a", NULL, _10);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_12);
- ZEPHIR_CONCAT_SVS(_12, "", _14, " ");
- zephir_concat_self(&html, _12 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("» ") TSRMLS_CC);
- }
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "last", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_NVAR(_6);
+ ZVAL_BOOL(_6, !ZEPHIR_IS_EQUAL(_19, _20));
+ ZEPHIR_CALL_METHOD(&_18, this_ptr, "preparebutton", &_7, 0, _2, url, _6);
+ zephir_check_temp_parameter(_2);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _18 TSRMLS_CC);
+ _21 = zephir_fetch_nproperty_this(this_ptr, SL("tag"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "ul", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_9, _8, "endtag", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_22, _21, "endtag", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- zephir_concat_self(&html, _9 TSRMLS_CC);
+ zephir_concat_self(&html, _22 TSRMLS_CC);
RETURN_CCTOR(html);
}
@@ -815,14 +703,13 @@ PHP_METHOD(Ice_Pagination, basic) {
*/
PHP_METHOD(Ice_Pagination, floating) {
- zephir_fcall_cache_entry *_43 = NULL, *_44 = NULL, *_45 = NULL, *_47 = NULL, *_48 = NULL;
- HashTable *_41;
- HashPosition _40;
- zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL;
- zend_bool useMiddle, useN3, useN6, _10, _13, _15, _18, _22;
- int countOut, countIn, n1, n3, n6, i, ZEPHIR_LAST_CALL_STATUS, _16;
- zval *parameters = NULL, *_26, *_34 = NULL, *_46 = NULL;
- zval *url_param = NULL, *parameters_param = NULL, *countOut_param = NULL, *countIn_param = NULL, *html = NULL, *query = NULL, *i18n = NULL, *title = NULL, *links, *number = NULL, *content = NULL, *n2 = NULL, *n4 = NULL, *n5 = NULL, *n7 = NULL, *n8 = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9, *_11, *_12, *_14, *_17 = NULL, *_19 = NULL, *_20 = NULL, *_21 = NULL, *_23 = NULL, *_24 = NULL, *_25, *_27, *_28 = NULL, *_29, *_30 = NULL, *_31 = NULL, *_32, *_33 = NULL, *_35 = NULL, *_36 = NULL, *_37 = NULL, *_38 = NULL, *_39 = NULL, **_42, *_49 = NULL;
+ HashTable *_36;
+ HashPosition _35;
+ zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL, *_31 = NULL;
+ zend_bool useMiddle = 0, useN3 = 0, useN6 = 0, _10, _13, _15, _18, _22;
+ int countOut, countIn, n1 = 0, n3 = 0, n6 = 0, i = 0, ZEPHIR_LAST_CALL_STATUS, _16;
+ zval *parameters = NULL, *_26;
+ zval *url_param = NULL, *parameters_param = NULL, *countOut_param = NULL, *countIn_param = NULL, *html = NULL, *links = NULL, *page = NULL, *content = NULL, *n2 = NULL, *n4 = NULL, *n5 = NULL, *n7 = NULL, *n8 = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9, *_11, *_12, *_14, *_17 = NULL, *_19 = NULL, *_20 = NULL, *_21 = NULL, *_23 = NULL, *_24 = NULL, *_25, *_27 = NULL, *_28 = NULL, *_29 = NULL, *_30 = NULL, *_32 = NULL, *_33 = NULL, *_34 = NULL, **_37, *_38 = NULL, *_39 = NULL, *_40 = NULL, *_41 = NULL, *_42 = NULL, *_43 = NULL, *_44, *_45 = NULL;
zval *url = NULL;
ZEPHIR_MM_GROW();
@@ -854,7 +741,7 @@ PHP_METHOD(Ice_Pagination, floating) {
ZEPHIR_INIT_VAR(_1);
ZVAL_STRING(_1, "pages", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_0, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_0, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (ZEPHIR_LT_LONG(_0, 2)) {
@@ -863,69 +750,69 @@ PHP_METHOD(Ice_Pagination, floating) {
n1 = 1;
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "pages", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_2, this_ptr, "get", NULL, 27, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_LONG(_1, countOut);
- ZEPHIR_CALL_FUNCTION(&n2, "min", &_3, _1, _2);
+ ZEPHIR_CALL_FUNCTION(&n2, "min", &_3, 151, _1, _2);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "pages", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_4, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "get", NULL, 27, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_LONG(_1, 1);
ZEPHIR_INIT_VAR(_5);
ZVAL_LONG(_5, ((zephir_get_numberval(_4) - countOut) + 1));
- ZEPHIR_CALL_FUNCTION(&n7, "max", &_6, _1, _5);
+ ZEPHIR_CALL_FUNCTION(&n7, "max", &_6, 32, _1, _5);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "pages", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&n8, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&n8, this_ptr, "get", NULL, 27, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_7, this_ptr, "get", NULL, 27, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_LONG(_1, (zephir_get_numberval(n2) + 1));
ZEPHIR_INIT_NVAR(_5);
ZVAL_LONG(_5, (zephir_get_numberval(_7) - countIn));
- ZEPHIR_CALL_FUNCTION(&n4, "max", &_6, _1, _5);
+ ZEPHIR_CALL_FUNCTION(&n4, "max", &_6, 32, _1, _5);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", NULL, 27, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_LONG(_1, (zephir_get_numberval(n7) - 1));
ZEPHIR_INIT_NVAR(_5);
ZVAL_LONG(_5, (zephir_get_numberval(_8) + countIn));
- ZEPHIR_CALL_FUNCTION(&n5, "min", &_3, _1, _5);
+ ZEPHIR_CALL_FUNCTION(&n5, "min", &_3, 151, _1, _5);
zephir_check_call_status();
useMiddle = (ZEPHIR_GE(n5, n4));
ZEPHIR_INIT_VAR(_9);
- zephir_add_function_ex(_9, n2, n4 TSRMLS_CC);
+ zephir_add_function(_9, n2, n4);
n3 = (int) zephir_safe_div_zval_long(_9, 2 TSRMLS_CC);
_10 = useMiddle;
if (_10) {
ZEPHIR_INIT_VAR(_11);
- sub_function(_11, n4, n2 TSRMLS_CC);
+ zephir_sub_function(_11, n4, n2);
_10 = ZEPHIR_GT_LONG(_11, 1);
}
useN3 = _10;
ZEPHIR_INIT_VAR(_12);
- zephir_add_function_ex(_12, n5, n7 TSRMLS_CC);
+ zephir_add_function(_12, n5, n7);
n6 = (int) zephir_safe_div_zval_long(_12, 2 TSRMLS_CC);
_13 = useMiddle;
if (_13) {
ZEPHIR_INIT_VAR(_14);
- sub_function(_14, n7, n5 TSRMLS_CC);
+ zephir_sub_function(_14, n7, n5);
_13 = ZEPHIR_GT_LONG(_14, 1);
}
useN6 = _13;
@@ -947,13 +834,13 @@ PHP_METHOD(Ice_Pagination, floating) {
i = _16;
ZEPHIR_INIT_NVAR(_1);
ZVAL_LONG(_1, i);
- zephir_array_update_long(&links, i, &_1, PH_COPY | PH_SEPARATE, "ice/pagination.zep", 278);
+ zephir_array_update_long(&links, i, &_1, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
}
}
if (useN3) {
ZEPHIR_INIT_NVAR(_5);
ZVAL_STRING(_5, "…", 1);
- zephir_array_update_long(&links, n3, &_5, PH_COPY | PH_SEPARATE, "ice/pagination.zep", 282);
+ zephir_array_update_long(&links, n3, &_5, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
}
ZEPHIR_CPY_WRT(_20, n5);
ZEPHIR_CPY_WRT(_19, n4);
@@ -972,13 +859,13 @@ PHP_METHOD(Ice_Pagination, floating) {
i = zephir_get_numberval(_19);
ZEPHIR_INIT_NVAR(_21);
ZVAL_LONG(_21, i);
- zephir_array_update_long(&links, i, &_21, PH_COPY | PH_SEPARATE, "ice/pagination.zep", 286);
+ zephir_array_update_long(&links, i, &_21, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
}
}
if (useN6) {
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "…", 1);
- zephir_array_update_long(&links, n6, &_21, PH_COPY | PH_SEPARATE, "ice/pagination.zep", 290);
+ zephir_array_update_long(&links, n6, &_21, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
}
ZEPHIR_CPY_WRT(_24, n8);
ZEPHIR_CPY_WRT(_23, n7);
@@ -997,305 +884,115 @@ PHP_METHOD(Ice_Pagination, floating) {
i = zephir_get_numberval(_23);
ZEPHIR_INIT_NVAR(_21);
ZVAL_LONG(_21, i);
- zephir_array_update_long(&links, i, &_21, PH_COPY | PH_SEPARATE, "ice/pagination.zep", 294);
+ zephir_array_update_long(&links, i, &_21, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
}
}
- _25 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
+ _25 = zephir_fetch_nproperty_this(this_ptr, SL("tag"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_26);
- array_init_size(_26, 2);
+ zephir_create_array(_26, 1, 0 TSRMLS_CC);
add_assoc_stringl_ex(_26, SS("class"), SL("pagination"), 1);
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "ul", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&html, _25, "taghtml", NULL, _21, parameters, _26);
+ ZEPHIR_CALL_METHOD(&html, _25, "taghtml", NULL, 0, _21, parameters, _26);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
- _27 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
- ZEPHIR_CALL_METHOD(&_28, _27, "getrequest", NULL);
- zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&query, _28, "getquery", NULL);
- zephir_check_call_status();
- _29 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _29, "get", NULL, _21);
+ ZVAL_STRING(_21, "current", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_28, this_ptr, "get", NULL, 27, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_30, this_ptr, "get", NULL, _21);
+ ZVAL_STRING(_21, "first", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_29, this_ptr, "get", NULL, 27, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "first", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_31, this_ptr, "get", NULL, _21);
+ ZEPHIR_INIT_VAR(_30);
+ ZVAL_BOOL(_30, !ZEPHIR_IS_EQUAL(_28, _29));
+ ZEPHIR_CALL_METHOD(&_27, this_ptr, "preparebutton", &_31, 0, _21, url, _30);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
- if (!ZEPHIR_IS_EQUAL(_30, _31)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "remove", NULL, _21);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "first", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _21);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _32 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_VAR(_34);
- array_init_size(_34, 7);
- zephir_array_fast_append(_34, url);
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "«", 1);
- zephir_array_fast_append(_34, _21);
- zephir_array_fast_append(_34, title);
- ZEPHIR_CALL_METHOD(&_35, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_34, SL("query"), &_35, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_34, SS("rel"), SL("first"), 1);
- ZEPHIR_CALL_METHOD(&_33, _32, "a", NULL, _34);
- zephir_check_call_status();
- ZEPHIR_INIT_VAR(_36);
- ZEPHIR_CONCAT_SVS(_36, "", _33, " ");
- zephir_concat_self(&html, _36 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("« ") TSRMLS_CC);
- }
+ zephir_concat_self(&html, _27 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_33, this_ptr, "get", NULL, _21);
+ ZEPHIR_CALL_METHOD(&_33, this_ptr, "get", NULL, 27, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "previous", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_35, this_ptr, "get", NULL, _21);
+ ZEPHIR_CALL_METHOD(&_34, this_ptr, "get", NULL, 27, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
- if (ZEPHIR_GT(_33, _35)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "previous", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_37, this_ptr, "get", NULL, _21);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "set", NULL, _21, _37);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "previous", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _21);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _32 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_34);
- array_init_size(_34, 7);
- zephir_array_fast_append(_34, url);
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "‹", 1);
- zephir_array_fast_append(_34, _21);
- zephir_array_fast_append(_34, title);
- ZEPHIR_CALL_METHOD(&_39, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_34, SL("query"), &_39, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_34, SS("rel"), SL("prev"), 1);
- ZEPHIR_CALL_METHOD(&_38, _32, "a", NULL, _34);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_36);
- ZEPHIR_CONCAT_SVS(_36, "", _38, " ");
- zephir_concat_self(&html, _36 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("‹ ") TSRMLS_CC);
- }
- zephir_is_iterable(links, &_41, &_40, 0, 0, "ice/pagination.zep", 336);
+ ZEPHIR_INIT_NVAR(_21);
+ ZVAL_STRING(_21, "previous", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_NVAR(_30);
+ ZVAL_BOOL(_30, ZEPHIR_GT(_33, _34));
+ ZEPHIR_CALL_METHOD(&_32, this_ptr, "preparebutton", &_31, 0, _21, url, _30);
+ zephir_check_temp_parameter(_21);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _32 TSRMLS_CC);
+ zephir_is_iterable(links, &_36, &_35, 0, 0, "ice/pagination.zep", 312);
for (
- ; zephir_hash_get_current_data_ex(_41, (void**) &_42, &_40) == SUCCESS
- ; zephir_hash_move_forward_ex(_41, &_40)
+ ; zephir_hash_get_current_data_ex(_36, (void**) &_37, &_35) == SUCCESS
+ ; zephir_hash_move_forward_ex(_36, &_35)
) {
- ZEPHIR_GET_HMKEY(number, _41, _40);
- ZEPHIR_GET_HVALUE(content, _42);
+ ZEPHIR_GET_HMKEY(page, _36, _35);
+ ZEPHIR_GET_HVALUE(content, _37);
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_33, this_ptr, "get", &_43, _21);
+ ZEPHIR_CALL_METHOD(&_39, this_ptr, "get", NULL, 27, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(title);
- if (!ZEPHIR_IS_IDENTICAL(number, _33)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "set", &_44, _21, number);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_34);
- array_init_size(_34, 2);
- zephir_array_fast_append(_34, number);
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "page: %d", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", &_45, _21, _34);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- } else {
- ZVAL_NULL(title);
- }
- _32 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_46);
- array_init_size(_46, 7);
- zephir_array_fast_append(_46, url);
- zephir_array_fast_append(_46, content);
- zephir_array_fast_append(_46, title);
- ZEPHIR_CALL_METHOD(&_37, query, "all", &_47);
- zephir_check_call_status();
- zephir_array_update_string(&_46, SL("query"), &_37, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_LNVAR(_36);
- if (ZEPHIR_IS_STRING(content, "…")) {
- ZEPHIR_INIT_NVAR(_36);
- ZVAL_STRING(_36, "text-muted", 1);
- } else {
- ZEPHIR_INIT_NVAR(_36);
- ZVAL_STRING(_36, "", 1);
- }
- zephir_array_update_string(&_46, SL("class"), &_36, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_METHOD(&_35, _32, "a", NULL, _46);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_36);
- ZEPHIR_CONCAT_SVS(_36, "", _35, " ");
- zephir_concat_self(&html, _36 TSRMLS_CC);
- } else {
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", &_48, _21);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- ZEPHIR_INIT_LNVAR(_49);
- ZEPHIR_CONCAT_SVSVS(_49, "", content, " ");
- zephir_concat_self(&html, _49 TSRMLS_CC);
- }
+ ZEPHIR_INIT_NVAR(_21);
+ ZVAL_BOOL(_21, !ZEPHIR_IS_IDENTICAL(page, _39));
+ ZEPHIR_CALL_METHOD(&_38, this_ptr, "preparebutton", &_31, 0, page, url, _21, content);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _38 TSRMLS_CC);
}
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_33, this_ptr, "get", &_43, _21);
+ ZEPHIR_CALL_METHOD(&_39, this_ptr, "get", NULL, 27, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_35, this_ptr, "get", &_43, _21);
+ ZEPHIR_CALL_METHOD(&_40, this_ptr, "get", NULL, 27, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
- if (ZEPHIR_LT(_33, _35)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_37, this_ptr, "get", &_43, _21);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "set", NULL, _21, _37);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "next", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _21);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _32 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_34);
- array_init_size(_34, 7);
- zephir_array_fast_append(_34, url);
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "›", 1);
- zephir_array_fast_append(_34, _21);
- zephir_array_fast_append(_34, title);
- ZEPHIR_CALL_METHOD(&_39, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_34, SL("query"), &_39, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_34, SS("rel"), SL("next"), 1);
- ZEPHIR_CALL_METHOD(&_38, _32, "a", NULL, _34);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_36);
- ZEPHIR_CONCAT_SVS(_36, "", _38, " ");
- zephir_concat_self(&html, _36 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("› ") TSRMLS_CC);
- }
+ ZEPHIR_INIT_NVAR(_21);
+ ZVAL_STRING(_21, "next", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_NVAR(_30);
+ ZVAL_BOOL(_30, ZEPHIR_LT(_39, _40));
+ ZEPHIR_CALL_METHOD(&_38, this_ptr, "preparebutton", &_31, 0, _21, url, _30);
+ zephir_check_temp_parameter(_21);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _38 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "current", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_33, this_ptr, "get", &_43, _21);
+ ZEPHIR_CALL_METHOD(&_42, this_ptr, "get", NULL, 27, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "last", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_35, this_ptr, "get", &_43, _21);
+ ZEPHIR_CALL_METHOD(&_43, this_ptr, "get", NULL, 27, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
- if (!ZEPHIR_IS_EQUAL(_33, _35)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "last", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_37, this_ptr, "get", &_43, _21);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "page", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(NULL, query, "set", NULL, _21, _37);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- if (zephir_is_true(i18n)) {
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "last", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&title, i18n, "translate", NULL, _21);
- zephir_check_temp_parameter(_21);
- zephir_check_call_status();
- } else {
- ZEPHIR_INIT_NVAR(title);
- ZVAL_NULL(title);
- }
- _32 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_34);
- array_init_size(_34, 7);
- zephir_array_fast_append(_34, url);
- ZEPHIR_INIT_NVAR(_21);
- ZVAL_STRING(_21, "»", 1);
- zephir_array_fast_append(_34, _21);
- zephir_array_fast_append(_34, title);
- ZEPHIR_CALL_METHOD(&_39, query, "all", NULL);
- zephir_check_call_status();
- zephir_array_update_string(&_34, SL("query"), &_39, PH_COPY | PH_SEPARATE);
- add_assoc_stringl_ex(_34, SS("rel"), SL("last"), 1);
- ZEPHIR_CALL_METHOD(&_38, _32, "a", NULL, _34);
- zephir_check_call_status();
- ZEPHIR_INIT_LNVAR(_36);
- ZEPHIR_CONCAT_SVS(_36, "", _38, " ");
- zephir_concat_self(&html, _36 TSRMLS_CC);
- } else {
- zephir_concat_self_str(&html, SL("» ") TSRMLS_CC);
- }
- _32 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC);
+ ZEPHIR_INIT_NVAR(_21);
+ ZVAL_STRING(_21, "last", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_NVAR(_30);
+ ZVAL_BOOL(_30, !ZEPHIR_IS_EQUAL(_42, _43));
+ ZEPHIR_CALL_METHOD(&_41, this_ptr, "preparebutton", &_31, 0, _21, url, _30);
+ zephir_check_temp_parameter(_21);
+ zephir_check_call_status();
+ zephir_concat_self(&html, _41 TSRMLS_CC);
+ _44 = zephir_fetch_nproperty_this(this_ptr, SL("tag"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_21);
ZVAL_STRING(_21, "ul", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_33, _32, "endtag", NULL, _21);
+ ZEPHIR_CALL_METHOD(&_45, _44, "endtag", NULL, 0, _21);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
- zephir_concat_self(&html, _33 TSRMLS_CC);
+ zephir_concat_self(&html, _45 TSRMLS_CC);
RETURN_CCTOR(html);
}
diff --git a/ext/ice/pagination.zep.h b/ext/ice/pagination.zep.h
index 85795ba6..06ddf070 100644
--- a/ext/ice/pagination.zep.h
+++ b/ext/ice/pagination.zep.h
@@ -7,6 +7,7 @@ PHP_METHOD(Ice_Pagination, getDi);
PHP_METHOD(Ice_Pagination, getTag);
PHP_METHOD(Ice_Pagination, __construct);
PHP_METHOD(Ice_Pagination, calculate);
+PHP_METHOD(Ice_Pagination, prepareButton);
PHP_METHOD(Ice_Pagination, minimal);
PHP_METHOD(Ice_Pagination, basic);
PHP_METHOD(Ice_Pagination, floating);
@@ -15,6 +16,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_pagination___construct, 0, 0, 0)
ZEND_ARG_ARRAY_INFO(0, options, 1)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_pagination_preparebutton, 0, 0, 1)
+ ZEND_ARG_INFO(0, page)
+ ZEND_ARG_INFO(0, url)
+ ZEND_ARG_INFO(0, active)
+ ZEND_ARG_INFO(0, symbol)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_pagination_minimal, 0, 0, 0)
ZEND_ARG_INFO(0, url)
ZEND_ARG_ARRAY_INFO(0, parameters, 1)
@@ -37,8 +45,9 @@ ZEPHIR_INIT_FUNCS(ice_pagination_method_entry) {
PHP_ME(Ice_Pagination, getTag, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Pagination, __construct, arginfo_ice_pagination___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(Ice_Pagination, calculate, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Ice_Pagination, prepareButton, arginfo_ice_pagination_preparebutton, ZEND_ACC_PROTECTED)
PHP_ME(Ice_Pagination, minimal, arginfo_ice_pagination_minimal, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Pagination, basic, arginfo_ice_pagination_basic, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Pagination, floating, arginfo_ice_pagination_floating, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/session.zep.c b/ext/ice/session.zep.c
index 4cc6c79f..d8ad6ff0 100644
--- a/ext/ice/session.zep.c
+++ b/ext/ice/session.zep.c
@@ -32,7 +32,7 @@ ZEPHIR_INIT_CLASS(Ice_Session) {
ZEPHIR_REGISTER_CLASS_EX(Ice, Session, ice, session, ice_arr_ce, ice_session_method_entry, 0);
- zend_declare_property_bool(ice_session_ce, SL("_started"), 0, ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_bool(ice_session_ce, SL("started"), 0, ZEND_ACC_PROTECTED TSRMLS_CC);
return SUCCESS;
@@ -47,7 +47,7 @@ PHP_METHOD(Ice_Session, __construct) {
ZEPHIR_MM_GROW();
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "start", NULL);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "start", NULL, 0);
zephir_check_call_status();
ZEPHIR_MM_RESTORE();
@@ -61,17 +61,20 @@ PHP_METHOD(Ice_Session, __construct) {
PHP_METHOD(Ice_Session, start) {
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
zval *_0 = NULL;
ZEPHIR_MM_GROW();
- ZEPHIR_CALL_FUNCTION(&_0, "headers_sent", &_1);
+ ZEPHIR_CALL_FUNCTION(&_0, "headers_sent", NULL, 108);
zephir_check_call_status();
if (!(zephir_is_true(_0))) {
- ZEPHIR_CALL_FUNCTION(NULL, "session_start", NULL);
+ ZEPHIR_CALL_FUNCTION(NULL, "session_start", NULL, 152);
zephir_check_call_status();
- zephir_update_property_this(this_ptr, SL("_started"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
+ if (1) {
+ zephir_update_property_this(this_ptr, SL("started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
+ } else {
+ zephir_update_property_this(this_ptr, SL("started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
+ }
RETURN_MM_BOOL(1);
}
RETURN_MM_BOOL(0);
@@ -86,7 +89,7 @@ PHP_METHOD(Ice_Session, start) {
PHP_METHOD(Ice_Session, isStarted) {
- RETURN_MEMBER(this_ptr, "_started");
+ RETURN_MEMBER(this_ptr, "started");
}
@@ -101,7 +104,7 @@ PHP_METHOD(Ice_Session, getId) {
ZEPHIR_MM_GROW();
- ZEPHIR_RETURN_CALL_FUNCTION("session_id", NULL);
+ ZEPHIR_RETURN_CALL_FUNCTION("session_id", NULL, 153);
zephir_check_call_status();
RETURN_MM();
@@ -118,7 +121,7 @@ PHP_METHOD(Ice_Session, regenerate) {
ZEPHIR_MM_GROW();
- ZEPHIR_RETURN_CALL_FUNCTION("session_regenerate_id", NULL);
+ ZEPHIR_RETURN_CALL_FUNCTION("session_regenerate_id", NULL, 154);
zephir_check_call_status();
RETURN_MM();
@@ -135,8 +138,12 @@ PHP_METHOD(Ice_Session, destroy) {
ZEPHIR_MM_GROW();
- zephir_update_property_this(this_ptr, SL("_started"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
- ZEPHIR_RETURN_CALL_FUNCTION("session_destroy", NULL);
+ if (0) {
+ zephir_update_property_this(this_ptr, SL("started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
+ } else {
+ zephir_update_property_this(this_ptr, SL("started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
+ }
+ ZEPHIR_RETURN_CALL_FUNCTION("session_destroy", NULL, 155);
zephir_check_call_status();
RETURN_MM();
@@ -152,12 +159,12 @@ PHP_METHOD(Ice_Session, has) {
zval *key = NULL;
ZEPHIR_MM_GROW();
+ zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
zephir_fetch_params(1, 1, 0, &key_param);
zephir_get_strval(key, key_param);
- zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
RETURN_MM_BOOL(zephir_array_isset(_SESSION, key));
}
@@ -167,19 +174,25 @@ PHP_METHOD(Ice_Session, has) {
*/
PHP_METHOD(Ice_Session, get) {
- zval *key_param = NULL, *defaultValue = NULL, *value, *_SESSION;
+ zend_bool required;
+ zval *key_param = NULL, *defaultValue = NULL, *required_param = NULL, *value = NULL, *_SESSION;
zval *key = NULL;
ZEPHIR_MM_GROW();
- zephir_fetch_params(1, 1, 1, &key_param, &defaultValue);
+ zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
+ zephir_fetch_params(1, 1, 2, &key_param, &defaultValue, &required_param);
zephir_get_strval(key, key_param);
if (!defaultValue) {
defaultValue = ZEPHIR_GLOBAL(global_null);
}
+ if (!required_param) {
+ required = 0;
+ } else {
+ required = zephir_get_boolval(required_param);
+ }
- zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
if (zephir_array_isset_fetch(&value, _SESSION, key, 1 TSRMLS_CC)) {
RETURN_CTOR(value);
}
@@ -198,12 +211,12 @@ PHP_METHOD(Ice_Session, set) {
zval *key = NULL;
ZEPHIR_MM_GROW();
+ zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
zephir_fetch_params(1, 2, 0, &key_param, &value);
zephir_get_strval(key, key_param);
- zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
_0 = zephir_maybe_separate_zval(&_SESSION);
zephir_array_update_zval(&_SESSION, key, &value, PH_COPY | PH_SEPARATE);
if (_0) {
@@ -222,12 +235,12 @@ PHP_METHOD(Ice_Session, remove) {
zval *key = NULL;
ZEPHIR_MM_GROW();
+ zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
zephir_fetch_params(1, 1, 0, &key_param);
zephir_get_strval(key, key_param);
- zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
zephir_array_unset(&_SESSION, key, PH_SEPARATE);
ZEPHIR_MM_RESTORE();
diff --git a/ext/ice/session.zep.h b/ext/ice/session.zep.h
index 9c1a4952..9ae3e6d8 100644
--- a/ext/ice/session.zep.h
+++ b/ext/ice/session.zep.h
@@ -21,6 +21,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_session_get, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, defaultValue)
+ ZEND_ARG_INFO(0, required)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_session_set, 0, 0, 2)
@@ -43,5 +44,5 @@ ZEPHIR_INIT_FUNCS(ice_session_method_entry) {
PHP_ME(Ice_Session, get, arginfo_ice_session_get, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Session, set, arginfo_ice_session_set, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Session, remove, arginfo_ice_session_remove, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/tag.zep.c b/ext/ice/tag.zep.c
index 7b0f7762..4f754497 100644
--- a/ext/ice/tag.zep.c
+++ b/ext/ice/tag.zep.c
@@ -38,18 +38,21 @@ ZEPHIR_INIT_CLASS(Ice_Tag) {
ZEPHIR_REGISTER_CLASS(Ice, Tag, ice, tag, ice_tag_method_entry, 0);
- zend_declare_property_null(ice_tag_ce, SL("_di"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_tag_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_tag_ce, SL("_values"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_tag_ce, SL("values"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_long(ice_tag_ce, SL("_docType"), 5, ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_long(ice_tag_ce, SL("docType"), 5, ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_tag_ce, SL("_title"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_tag_ce, SL("title"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_string(ice_tag_ce, SL("_titleSeparator"), " - ", ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_string(ice_tag_ce, SL("titleSeparator"), " - ", ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_bool(ice_tag_ce, SL("_escape"), 1, ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_tag_ce, SL("meta"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_bool(ice_tag_ce, SL("escape"), 1, ZEND_ACC_PROTECTED TSRMLS_CC);
+
+ ice_tag_ce->create_object = zephir_init_properties_Ice_Tag;
zend_declare_class_constant_long(ice_tag_ce, SL("HTML32"), 1 TSRMLS_CC);
zend_declare_class_constant_long(ice_tag_ce, SL("HTML401_STRICT"), 2 TSRMLS_CC);
@@ -79,14 +82,14 @@ ZEPHIR_INIT_CLASS(Ice_Tag) {
PHP_METHOD(Ice_Tag, getDi) {
- RETURN_MEMBER(this_ptr, "_di");
+ RETURN_MEMBER(this_ptr, "di");
}
PHP_METHOD(Ice_Tag, getValues) {
- RETURN_MEMBER(this_ptr, "_values");
+ RETURN_MEMBER(this_ptr, "values");
}
@@ -98,7 +101,7 @@ PHP_METHOD(Ice_Tag, setDocType) {
- zephir_update_property_this(this_ptr, SL("_docType"), docType TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("docType"), docType TSRMLS_CC);
}
@@ -110,14 +113,14 @@ PHP_METHOD(Ice_Tag, setTitle) {
- zephir_update_property_this(this_ptr, SL("_title"), title TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("title"), title TSRMLS_CC);
}
PHP_METHOD(Ice_Tag, getTitle) {
- RETURN_MEMBER(this_ptr, "_title");
+ RETURN_MEMBER(this_ptr, "title");
}
@@ -129,14 +132,21 @@ PHP_METHOD(Ice_Tag, setTitleSeparator) {
- zephir_update_property_this(this_ptr, SL("_titleSeparator"), titleSeparator TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("titleSeparator"), titleSeparator TSRMLS_CC);
}
PHP_METHOD(Ice_Tag, getTitleSeparator) {
- RETURN_MEMBER(this_ptr, "_titleSeparator");
+ RETURN_MEMBER(this_ptr, "titleSeparator");
+
+}
+
+PHP_METHOD(Ice_Tag, getMeta) {
+
+
+ RETURN_MEMBER(this_ptr, "meta");
}
@@ -148,7 +158,7 @@ PHP_METHOD(Ice_Tag, setEscape) {
- zephir_update_property_this(this_ptr, SL("_escape"), escape TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("escape"), escape TSRMLS_CC);
}
@@ -158,14 +168,14 @@ PHP_METHOD(Ice_Tag, setEscape) {
PHP_METHOD(Ice_Tag, __construct) {
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
+ zephir_fcall_cache_entry *_1 = NULL;
zval *_0 = NULL;
ZEPHIR_MM_GROW();
- ZEPHIR_CALL_CE_STATIC(&_0, ice_di_ce, "fetch", &_1);
+ ZEPHIR_CALL_CE_STATIC(&_0, ice_di_ce, "fetch", &_1, 8);
zephir_check_call_status();
- zephir_update_property_this(this_ptr, SL("_di"), _0 TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("di"), _0 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
@@ -194,17 +204,17 @@ PHP_METHOD(Ice_Tag, appendTitle) {
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_title"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("title"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_1);
- if (separator && Z_STRLEN_P(separator)) {
+ if (!(!separator) && Z_STRLEN_P(separator)) {
ZEPHIR_CPY_WRT(_1, separator);
} else {
ZEPHIR_OBS_NVAR(_1);
- zephir_read_property_this(&_1, this_ptr, SL("_titleSeparator"), PH_NOISY_CC);
+ zephir_read_property_this(&_1, this_ptr, SL("titleSeparator"), PH_NOISY_CC);
}
ZEPHIR_INIT_VAR(_2);
ZEPHIR_CONCAT_VVV(_2, _0, _1, title);
- zephir_update_property_this(this_ptr, SL("_title"), _2 TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("title"), _2 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
@@ -234,29 +244,61 @@ PHP_METHOD(Ice_Tag, prependTitle) {
ZEPHIR_INIT_VAR(_0);
- if (separator && Z_STRLEN_P(separator)) {
+ if (!(!separator) && Z_STRLEN_P(separator)) {
ZEPHIR_CPY_WRT(_0, separator);
} else {
ZEPHIR_OBS_NVAR(_0);
- zephir_read_property_this(&_0, this_ptr, SL("_titleSeparator"), PH_NOISY_CC);
+ zephir_read_property_this(&_0, this_ptr, SL("titleSeparator"), PH_NOISY_CC);
}
- _1 = zephir_fetch_nproperty_this(this_ptr, SL("_title"), PH_NOISY_CC);
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("title"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_2);
ZEPHIR_CONCAT_VVV(_2, title, _0, _1);
- zephir_update_property_this(this_ptr, SL("_title"), _2 TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("title"), _2 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
+/**
+ * Add meta tag to the container.
+ *
+ * @param array parameters
+ * @return object this
+ */
+PHP_METHOD(Ice_Tag, addMeta) {
+
+ int ZEPHIR_LAST_CALL_STATUS;
+ zval *parameters_param = NULL, *_0 = NULL;
+ zval *parameters = NULL;
+
+ ZEPHIR_MM_GROW();
+ zephir_fetch_params(1, 1, 0, ¶meters_param);
+
+ zephir_get_arrval(parameters, parameters_param);
+
+
+ ZEPHIR_CALL_METHOD(&_0, this_ptr, "meta", NULL, 0, parameters);
+ zephir_check_call_status();
+ zephir_update_property_array_append(this_ptr, SL("meta"), _0 TSRMLS_CC);
+ RETURN_THIS();
+
+}
+
/**
* Builds a HTML INPUT[type="text"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->textField(['some', 'some_value']);
+ *
+ * // Sleet
+ * {{ text_field(['some', 'some_value', 'id' => 'some1', 'class' => 'field', 'style' => 'width: 100%']) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, textField) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *parameters_param = NULL, *_0;
zval *parameters = NULL;
@@ -269,7 +311,7 @@ PHP_METHOD(Ice_Tag, textField) {
ZEPHIR_INIT_VAR(_0);
ZVAL_STRING(_0, "text", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", &_1, _0, parameters);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", NULL, 156, _0, parameters);
zephir_check_temp_parameter(_0);
zephir_check_call_status();
RETURN_MM();
@@ -279,12 +321,19 @@ PHP_METHOD(Ice_Tag, textField) {
/**
* Builds a HTML INPUT[type="password"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->passwordField(['pass', 'class': 'form-control']);
+ *
+ * // Sleet
+ * {{ password_field(['pass', 'placeholder': 'My secret password']) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, passwordField) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *parameters_param = NULL, *_0;
zval *parameters = NULL;
@@ -297,7 +346,7 @@ PHP_METHOD(Ice_Tag, passwordField) {
ZEPHIR_INIT_VAR(_0);
ZVAL_STRING(_0, "password", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", &_1, _0, parameters);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", NULL, 156, _0, parameters);
zephir_check_temp_parameter(_0);
zephir_check_call_status();
RETURN_MM();
@@ -307,12 +356,19 @@ PHP_METHOD(Ice_Tag, passwordField) {
/**
* Builds a HTML INPUT[type="hidden"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->hiddenField(['secret', 'some value']);
+ *
+ * // Sleet
+ * {{ hidden_field(['secret', 'hidden value', 'id': 'my_id']) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, hiddenField) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *parameters_param = NULL, *_0;
zval *parameters = NULL;
@@ -325,7 +381,7 @@ PHP_METHOD(Ice_Tag, hiddenField) {
ZEPHIR_INIT_VAR(_0);
ZVAL_STRING(_0, "hidden", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", &_1, _0, parameters);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", NULL, 156, _0, parameters);
zephir_check_temp_parameter(_0);
zephir_check_call_status();
RETURN_MM();
@@ -335,12 +391,16 @@ PHP_METHOD(Ice_Tag, hiddenField) {
/**
* Builds a HTML INPUT[type="file"] tag.
*
+ *
+ * // Sleet
+ * {{ file_field(['some']) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, fileField) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *parameters_param = NULL, *_0;
zval *parameters = NULL;
@@ -353,7 +413,7 @@ PHP_METHOD(Ice_Tag, fileField) {
ZEPHIR_INIT_VAR(_0);
ZVAL_STRING(_0, "file", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", &_1, _0, parameters);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", NULL, 156, _0, parameters);
zephir_check_temp_parameter(_0);
zephir_check_call_status();
RETURN_MM();
@@ -363,12 +423,19 @@ PHP_METHOD(Ice_Tag, fileField) {
/**
* Builds a HTML INPUT[type="submit"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->submitButton(['some', 'Submit']);
+ *
+ * // Sleet
+ * {{ submit_button(['some', 'value' => 'Submit', 'id' => 'some1', 'class' => 'btn']) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, submitButton) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *parameters_param = NULL, *_0;
zval *parameters = NULL;
@@ -381,7 +448,7 @@ PHP_METHOD(Ice_Tag, submitButton) {
ZEPHIR_INIT_VAR(_0);
ZVAL_STRING(_0, "submit", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", &_1, _0, parameters);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", NULL, 156, _0, parameters);
zephir_check_temp_parameter(_0);
zephir_check_call_status();
RETURN_MM();
@@ -391,13 +458,21 @@ PHP_METHOD(Ice_Tag, submitButton) {
/**
* Builds a HTML BUTTON tag.
*
+ *
+ * // Phtml content
+ * $this->tag->button(['some', 'content']);
+ *
+ * // Sleet + Submit
+ * {{ button(['some', '+ ' . 'Submit', 'type' => 'button', 'id' => 'some1']) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, button) {
int ZEPHIR_LAST_CALL_STATUS;
- zval *parameters_param = NULL, *defaultParams, *_1 = NULL, *_2, *_3;
+ zval *parameters_param = NULL, *defaultParams = NULL, *_1 = NULL, *_2, *_3;
zval *parameters = NULL, *_0;
ZEPHIR_MM_GROW();
@@ -407,13 +482,13 @@ PHP_METHOD(Ice_Tag, button) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 6);
+ zephir_create_array(defaultParams, 4, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("id"), 0);
add_assoc_long_ex(defaultParams, SS("name"), 0);
add_assoc_long_ex(defaultParams, SS("content"), 1);
add_assoc_stringl_ex(defaultParams, SS("type"), SL("submit"), 1);
ZEPHIR_INIT_VAR(_0);
- array_init_size(_0, 2);
+ zephir_create_array(_0, 1, 0 TSRMLS_CC);
ZEPHIR_INIT_VAR(_1);
ZVAL_STRING(_1, "content", 1);
zephir_array_fast_append(_0, _1);
@@ -423,7 +498,7 @@ PHP_METHOD(Ice_Tag, button) {
ZVAL_STRING(_2, "content", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_VAR(_3);
ZVAL_BOOL(_3, 1);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, _1, parameters, defaultParams, _0, _2, _3);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, 0, _1, parameters, defaultParams, _0, _2, _3);
zephir_check_temp_parameter(_1);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
@@ -434,12 +509,19 @@ PHP_METHOD(Ice_Tag, button) {
/**
* Builds a HTML INPUT[type="checkbox"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->checkField(['agree', 'yes']);
+ *
+ * // Sleet
+ * {{ check_field(['remember', 'on', 'checked': 'checked']) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, checkField) {
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
zval *parameters_param = NULL, *_0;
zval *parameters = NULL;
@@ -452,7 +534,42 @@ PHP_METHOD(Ice_Tag, checkField) {
ZEPHIR_INIT_VAR(_0);
ZVAL_STRING(_0, "checkbox", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", &_1, _0, parameters);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", NULL, 156, _0, parameters);
+ zephir_check_temp_parameter(_0);
+ zephir_check_call_status();
+ RETURN_MM();
+
+}
+
+/**
+ * Builds a HTML INPUT[type="radio"] tag.
+ *
+ *
+ * // Phtml
+ * $this->tag->radioField(['sex', 'male']);
+ *
+ * // Sleet
+ * {{ radio_field(['sex', 'female', 'checked': 'checked']) }}
+ *
+ *
+ * @param array parameters
+ * @return string
+ */
+PHP_METHOD(Ice_Tag, radioField) {
+
+ int ZEPHIR_LAST_CALL_STATUS;
+ zval *parameters_param = NULL, *_0;
+ zval *parameters = NULL;
+
+ ZEPHIR_MM_GROW();
+ zephir_fetch_params(1, 1, 0, ¶meters_param);
+
+ zephir_get_arrval(parameters, parameters_param);
+
+
+ ZEPHIR_INIT_VAR(_0);
+ ZVAL_STRING(_0, "radio", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "input", NULL, 156, _0, parameters);
zephir_check_temp_parameter(_0);
zephir_check_call_status();
RETURN_MM();
@@ -470,7 +587,7 @@ PHP_METHOD(Ice_Tag, input) {
int ZEPHIR_LAST_CALL_STATUS;
zval *parameters = NULL;
- zval *type_param = NULL, *parameters_param = NULL, *defaultParams, *_0, *_1, *_2, *_3, *_4, *_5;
+ zval *type_param = NULL, *parameters_param = NULL, *defaultParams = NULL, *_0, *_1, *_2, *_3, *_4, *_5;
zval *type = NULL;
ZEPHIR_MM_GROW();
@@ -481,7 +598,7 @@ PHP_METHOD(Ice_Tag, input) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 6);
+ zephir_create_array(defaultParams, 4, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("id"), 0);
add_assoc_long_ex(defaultParams, SS("name"), 0);
add_assoc_long_ex(defaultParams, SS("value"), 1);
@@ -498,7 +615,7 @@ PHP_METHOD(Ice_Tag, input) {
ZVAL_BOOL(_4, 0);
ZEPHIR_INIT_VAR(_5);
ZVAL_BOOL(_5, 1);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, _1, parameters, defaultParams, _0, _2, _3, _4, _5);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, 0, _1, parameters, defaultParams, _0, _2, _3, _4, _5);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
RETURN_MM();
@@ -508,13 +625,27 @@ PHP_METHOD(Ice_Tag, input) {
/**
* Builds a HTML FORM tag.
*
+ *
+ * // Phtml
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, form) {
int ZEPHIR_LAST_CALL_STATUS;
- zval *parameters_param = NULL, *defaultParams, *action = NULL, *local = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_6 = NULL;
+ zval *parameters_param = NULL, *defaultParams = NULL, *action = NULL, *local = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_6 = NULL;
zval *parameters = NULL, *_7;
ZEPHIR_MM_GROW();
@@ -524,7 +655,7 @@ PHP_METHOD(Ice_Tag, form) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 3);
+ zephir_create_array(defaultParams, 2, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("action"), 0);
add_assoc_stringl_ex(defaultParams, SS("method"), SL("post"), 1);
ZEPHIR_OBS_VAR(local);
@@ -536,37 +667,37 @@ PHP_METHOD(Ice_Tag, form) {
ZEPHIR_OBS_VAR(action);
if (!(zephir_array_isset_string_fetch(&action, parameters, SS("action"), 0 TSRMLS_CC))) {
ZEPHIR_OBS_NVAR(action);
- zephir_array_fetch_string(&_0, defaultParams, SL("action"), PH_READONLY, "ice/tag.zep", 196 TSRMLS_CC);
+ zephir_array_fetch_string(&_0, defaultParams, SL("action"), PH_READONLY, "ice/tag.zep", 296 TSRMLS_CC);
zephir_array_isset_fetch(&action, parameters, _0, 0 TSRMLS_CC);
}
if (!ZEPHIR_IS_FALSE_IDENTICAL(action)) {
- _1 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_3);
ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, _1, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_2, _1, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_2)) {
- _4 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_5, _4, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_5, _4, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_6, _5, "get", NULL, action);
+ ZEPHIR_CALL_METHOD(&_6, _5, "get", NULL, 0, action);
zephir_check_call_status();
zephir_array_update_string(¶meters, SL("action"), &_6, PH_COPY | PH_SEPARATE);
}
}
}
ZEPHIR_INIT_VAR(_7);
- array_init_size(_7, 2);
+ zephir_create_array(_7, 1, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "local", 1);
zephir_array_fast_append(_7, _3);
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "form", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, _3, parameters, defaultParams, _7);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, 0, _3, parameters, defaultParams, _7);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
RETURN_MM();
@@ -576,13 +707,21 @@ PHP_METHOD(Ice_Tag, form) {
/**
* Builds a HTML TEXTAREA tag.
*
+ *
+ * // Phtml
+ * $this->tag->textArea(['description', 'content']);
+ *
+ * // Sleet
+ * {{ text_area(['some', 'placeholder' => 'Say something']) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, textArea) {
int ZEPHIR_LAST_CALL_STATUS;
- zval *parameters_param = NULL, *defaultParams, *_1 = NULL, *_2, *_3;
+ zval *parameters_param = NULL, *defaultParams = NULL, *_1 = NULL, *_2, *_3;
zval *parameters = NULL, *_0;
ZEPHIR_MM_GROW();
@@ -592,12 +731,12 @@ PHP_METHOD(Ice_Tag, textArea) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 4);
+ zephir_create_array(defaultParams, 3, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("id"), 0);
add_assoc_long_ex(defaultParams, SS("name"), 0);
add_assoc_long_ex(defaultParams, SS("content"), 1);
ZEPHIR_INIT_VAR(_0);
- array_init_size(_0, 3);
+ zephir_create_array(_0, 2, 0 TSRMLS_CC);
ZEPHIR_INIT_VAR(_1);
ZVAL_STRING(_1, "content", 1);
zephir_array_fast_append(_0, _1);
@@ -610,7 +749,7 @@ PHP_METHOD(Ice_Tag, textArea) {
ZVAL_STRING(_2, "content", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_VAR(_3);
ZVAL_BOOL(_3, 1);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, _1, parameters, defaultParams, _0, _2, _3);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, 0, _1, parameters, defaultParams, _0, _2, _3);
zephir_check_temp_parameter(_1);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
@@ -633,7 +772,7 @@ PHP_METHOD(Ice_Tag, image) {
zephir_get_arrval(parameters, parameters_param);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "img", NULL, parameters);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "img", NULL, 0, parameters);
zephir_check_call_status();
RETURN_MM();
@@ -642,13 +781,21 @@ PHP_METHOD(Ice_Tag, image) {
/**
* Builds HTML IMG tags.
*
+ *
+ * // Phtml
+ * $this->tag->img(['img/logo.png', 'Logo']);
+ *
+ * // Sleet
+ * {{ image(['http://example.com/img/logo.png', 'Logo', 'local' => false]) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, img) {
int ZEPHIR_LAST_CALL_STATUS;
- zval *parameters_param = NULL, *defaultParams, *src = NULL, *local = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_6 = NULL, *_8, *_9, *_10, *_11;
+ zval *parameters_param = NULL, *defaultParams = NULL, *src = NULL, *local = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_6 = NULL, *_8, *_9, *_10, *_11;
zval *parameters = NULL, *_7;
ZEPHIR_MM_GROW();
@@ -658,7 +805,7 @@ PHP_METHOD(Ice_Tag, img) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 3);
+ zephir_create_array(defaultParams, 2, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("src"), 0);
add_assoc_long_ex(defaultParams, SS("alt"), 1);
ZEPHIR_OBS_VAR(local);
@@ -670,29 +817,29 @@ PHP_METHOD(Ice_Tag, img) {
ZEPHIR_OBS_VAR(src);
if (!(zephir_array_isset_string_fetch(&src, parameters, SS("src"), 0 TSRMLS_CC))) {
ZEPHIR_OBS_NVAR(src);
- zephir_array_fetch_string(&_0, defaultParams, SL("src"), PH_READONLY, "ice/tag.zep", 258 TSRMLS_CC);
+ zephir_array_fetch_string(&_0, defaultParams, SL("src"), PH_READONLY, "ice/tag.zep", 374 TSRMLS_CC);
zephir_array_isset_fetch(&src, parameters, _0, 0 TSRMLS_CC);
}
- _1 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_3);
ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, _1, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_2, _1, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_2)) {
- _4 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_5, _4, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_5, _4, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_6, _5, "getstatic", NULL, src);
+ ZEPHIR_CALL_METHOD(&_6, _5, "getstatic", NULL, 0, src);
zephir_check_call_status();
zephir_array_update_string(¶meters, SL("src"), &_6, PH_COPY | PH_SEPARATE);
}
}
ZEPHIR_INIT_VAR(_7);
- array_init_size(_7, 2);
+ zephir_create_array(_7, 1, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "local", 1);
zephir_array_fast_append(_7, _3);
@@ -706,7 +853,7 @@ PHP_METHOD(Ice_Tag, img) {
ZVAL_BOOL(_10, 0);
ZEPHIR_INIT_VAR(_11);
ZVAL_BOOL(_11, 1);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, _3, parameters, defaultParams, _7, _8, _9, _10, _11);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, 0, _3, parameters, defaultParams, _7, _8, _9, _10, _11);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
RETURN_MM();
@@ -728,7 +875,7 @@ PHP_METHOD(Ice_Tag, linkTo) {
zephir_get_arrval(parameters, parameters_param);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "a", NULL, parameters);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "a", NULL, 0, parameters);
zephir_check_call_status();
RETURN_MM();
@@ -737,13 +884,21 @@ PHP_METHOD(Ice_Tag, linkTo) {
/**
* Builds a HTML A tag using framework conventions.
*
+ *
+ * // Phtml Add
+ * $this->tag->a(['post/add', 'Add', 'Add a post']);
+ *
+ * // Sleet Google
+ * {{ link_to(['http://google.com', 'Google', 'local' => false]) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, a) {
int ZEPHIR_LAST_CALL_STATUS;
- zval *parameters_param = NULL, *defaultParams, *href = NULL, *local = NULL, *query, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_6 = NULL, *_8, *_9;
+ zval *parameters_param = NULL, *defaultParams = NULL, *href = NULL, *local = NULL, *query = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_6 = NULL, *_8, *_9;
zval *parameters = NULL, *_7;
ZEPHIR_MM_GROW();
@@ -753,14 +908,14 @@ PHP_METHOD(Ice_Tag, a) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 4);
+ zephir_create_array(defaultParams, 3, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("href"), 0);
add_assoc_long_ex(defaultParams, SS("text"), 1);
add_assoc_long_ex(defaultParams, SS("title"), 2);
ZEPHIR_OBS_VAR(href);
if (!(zephir_array_isset_string_fetch(&href, parameters, SS("href"), 0 TSRMLS_CC))) {
ZEPHIR_OBS_NVAR(href);
- zephir_array_fetch_string(&_0, defaultParams, SL("href"), PH_READONLY, "ice/tag.zep", 293 TSRMLS_CC);
+ zephir_array_fetch_string(&_0, defaultParams, SL("href"), PH_READONLY, "ice/tag.zep", 418 TSRMLS_CC);
zephir_array_isset_fetch(&href, parameters, _0, 0 TSRMLS_CC);
}
ZEPHIR_OBS_VAR(local);
@@ -770,25 +925,25 @@ PHP_METHOD(Ice_Tag, a) {
}
ZEPHIR_OBS_VAR(query);
zephir_array_isset_string_fetch(&query, parameters, SS("query"), 0 TSRMLS_CC);
- _1 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_3);
ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, _1, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_2, _1, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_2)) {
- _4 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_5, _4, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_5, _4, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_6, _5, "get", NULL, href, query, local);
+ ZEPHIR_CALL_METHOD(&_6, _5, "get", NULL, 0, href, query, local);
zephir_check_call_status();
zephir_array_update_string(¶meters, SL("href"), &_6, PH_COPY | PH_SEPARATE);
}
ZEPHIR_INIT_VAR(_7);
- array_init_size(_7, 4);
+ zephir_create_array(_7, 3, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "text", 1);
zephir_array_fast_append(_7, _3);
@@ -804,7 +959,7 @@ PHP_METHOD(Ice_Tag, a) {
ZVAL_STRING(_8, "text", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_VAR(_9);
ZVAL_BOOL(_9, 1);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, _3, parameters, defaultParams, _7, _8, _9);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, 0, _3, parameters, defaultParams, _7, _8, _9);
zephir_check_temp_parameter(_3);
zephir_check_temp_parameter(_8);
zephir_check_call_status();
@@ -815,13 +970,21 @@ PHP_METHOD(Ice_Tag, a) {
/**
* Builds a LINK[rel="stylesheet"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->link(['css/app.css']);
+ *
+ * // Sleet
+ * {{ link(['http://example.com/favicon.ico', 'type' => 'image/x-icon', 'rel' => 'icon', 'local' => false]) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, link) {
int ZEPHIR_LAST_CALL_STATUS;
- zval *parameters_param = NULL, *defaultParams, *href = NULL, *local = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_6 = NULL, *_8, *_9, *_10, *_11;
+ zval *parameters_param = NULL, *defaultParams = NULL, *href = NULL, *local = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_6 = NULL, *_8, *_9, *_10, *_11;
zval *parameters = NULL, *_7;
ZEPHIR_MM_GROW();
@@ -831,7 +994,7 @@ PHP_METHOD(Ice_Tag, link) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 4);
+ zephir_create_array(defaultParams, 3, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("href"), 0);
add_assoc_stringl_ex(defaultParams, SS("type"), SL("text/css"), 1);
add_assoc_stringl_ex(defaultParams, SS("rel"), SL("stylesheet"), 1);
@@ -844,29 +1007,29 @@ PHP_METHOD(Ice_Tag, link) {
ZEPHIR_OBS_VAR(href);
if (!(zephir_array_isset_string_fetch(&href, parameters, SS("href"), 0 TSRMLS_CC))) {
ZEPHIR_OBS_NVAR(href);
- zephir_array_fetch_string(&_0, defaultParams, SL("href"), PH_READONLY, "ice/tag.zep", 331 TSRMLS_CC);
+ zephir_array_fetch_string(&_0, defaultParams, SL("href"), PH_READONLY, "ice/tag.zep", 464 TSRMLS_CC);
zephir_array_isset_fetch(&href, parameters, _0, 0 TSRMLS_CC);
}
- _1 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_3);
ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, _1, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_2, _1, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_2)) {
- _4 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_5, _4, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_5, _4, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_6, _5, "getstatic", NULL, href);
+ ZEPHIR_CALL_METHOD(&_6, _5, "getstatic", NULL, 0, href);
zephir_check_call_status();
zephir_array_update_string(¶meters, SL("href"), &_6, PH_COPY | PH_SEPARATE);
}
}
ZEPHIR_INIT_VAR(_7);
- array_init_size(_7, 2);
+ zephir_create_array(_7, 1, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "local", 1);
zephir_array_fast_append(_7, _3);
@@ -880,7 +1043,7 @@ PHP_METHOD(Ice_Tag, link) {
ZVAL_BOOL(_10, 1);
ZEPHIR_INIT_VAR(_11);
ZVAL_BOOL(_11, 1);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, _3, parameters, defaultParams, _7, _8, _9, _10, _11);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, 0, _3, parameters, defaultParams, _7, _8, _9, _10, _11);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
RETURN_MM();
@@ -890,6 +1053,14 @@ PHP_METHOD(Ice_Tag, link) {
/**
* Builds a SCRIPT[type="javascript"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->script(['js/plugins.js']);
+ *
+ * // Sleet
+ * {{ script(['content' => 'alert("OK");']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -897,7 +1068,7 @@ PHP_METHOD(Ice_Tag, script) {
int ZEPHIR_LAST_CALL_STATUS;
zend_bool _1;
- zval *parameters_param = NULL, *defaultParams, *src = NULL, *local = NULL, *_0, *_2, *_3 = NULL, *_4 = NULL, *_5, *_6 = NULL, *_7 = NULL, *_9, *_10;
+ zval *parameters_param = NULL, *defaultParams = NULL, *src = NULL, *local = NULL, *_0, *_2, *_3 = NULL, *_4 = NULL, *_5, *_6 = NULL, *_7 = NULL, *_9, *_10;
zval *parameters = NULL, *_8;
ZEPHIR_MM_GROW();
@@ -907,7 +1078,7 @@ PHP_METHOD(Ice_Tag, script) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 3);
+ zephir_create_array(defaultParams, 2, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("src"), 0);
add_assoc_stringl_ex(defaultParams, SS("type"), SL("text/javascript"), 1);
ZEPHIR_OBS_VAR(local);
@@ -919,33 +1090,33 @@ PHP_METHOD(Ice_Tag, script) {
ZEPHIR_OBS_VAR(src);
if (!(zephir_array_isset_string_fetch(&src, parameters, SS("src"), 0 TSRMLS_CC))) {
ZEPHIR_OBS_NVAR(src);
- zephir_array_fetch_string(&_0, defaultParams, SL("src"), PH_READONLY, "ice/tag.zep", 363 TSRMLS_CC);
+ zephir_array_fetch_string(&_0, defaultParams, SL("src"), PH_READONLY, "ice/tag.zep", 504 TSRMLS_CC);
zephir_array_isset_fetch(&src, parameters, _0, 0 TSRMLS_CC);
}
_1 = zephir_is_true(src);
if (_1) {
- _2 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _2 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_4);
ZVAL_STRING(_4, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_3, _2, "has", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_3, _2, "has", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
_1 = zephir_is_true(_3);
}
if (_1) {
- _5 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _5 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_6, _5, "get", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_6, _5, "get", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_7, _6, "getstatic", NULL, src);
+ ZEPHIR_CALL_METHOD(&_7, _6, "getstatic", NULL, 0, src);
zephir_check_call_status();
zephir_array_update_string(¶meters, SL("src"), &_7, PH_COPY | PH_SEPARATE);
}
}
ZEPHIR_INIT_VAR(_8);
- array_init_size(_8, 3);
+ zephir_create_array(_8, 2, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "local", 1);
zephir_array_fast_append(_8, _4);
@@ -958,7 +1129,7 @@ PHP_METHOD(Ice_Tag, script) {
ZVAL_STRING(_9, "content", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_VAR(_10);
ZVAL_BOOL(_10, 1);
- ZEPHIR_CALL_METHOD(&_3, this_ptr, "taghtml", NULL, _4, parameters, defaultParams, _8, _9, _10);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "taghtml", NULL, 0, _4, parameters, defaultParams, _8, _9, _10);
zephir_check_temp_parameter(_4);
zephir_check_temp_parameter(_9);
zephir_check_call_status();
@@ -972,13 +1143,18 @@ PHP_METHOD(Ice_Tag, script) {
/**
* Builds a STYLE tag.
*
+ *
+ * // Sleet
+ * {{ style(['body { color: #444 }']) }}
+ *
+ *
* @param array parameters
* @return string
*/
PHP_METHOD(Ice_Tag, style) {
int ZEPHIR_LAST_CALL_STATUS;
- zval *parameters_param = NULL, *defaultParams, *_1 = NULL, *_2, *_3, *_4;
+ zval *parameters_param = NULL, *defaultParams = NULL, *_1 = NULL, *_2, *_3, *_4;
zval *parameters = NULL, *_0;
ZEPHIR_MM_GROW();
@@ -988,11 +1164,11 @@ PHP_METHOD(Ice_Tag, style) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 3);
+ zephir_create_array(defaultParams, 2, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("content"), 0);
add_assoc_stringl_ex(defaultParams, SS("type"), SL("text/css"), 1);
ZEPHIR_INIT_VAR(_0);
- array_init_size(_0, 2);
+ zephir_create_array(_0, 1, 0 TSRMLS_CC);
ZEPHIR_INIT_VAR(_1);
ZVAL_STRING(_1, "content", 1);
zephir_array_fast_append(_0, _1);
@@ -1004,7 +1180,7 @@ PHP_METHOD(Ice_Tag, style) {
ZVAL_BOOL(_3, 1);
ZEPHIR_INIT_VAR(_4);
ZVAL_BOOL(_4, 1);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, _1, parameters, defaultParams, _0, _2, _3, _4);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, 0, _1, parameters, defaultParams, _0, _2, _3, _4);
zephir_check_temp_parameter(_1);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
@@ -1012,9 +1188,63 @@ PHP_METHOD(Ice_Tag, style) {
}
+/**
+ * Builds a META tag.
+ *
+ *
+ * // Phtml
+ * $this->tag->meta(['ice, framework', 'keywords']);
+ *
+ * // Sleet
+ * {{ meta(['Your description', 'property': 'og:description']) }}
+ *
+ *
+ * @param array parameters
+ * @return string
+ */
+PHP_METHOD(Ice_Tag, meta) {
+
+ int ZEPHIR_LAST_CALL_STATUS;
+ zval *parameters_param = NULL, *defaultParams = NULL, *_0, *_1, *_2, *_3, *_4, *_5;
+ zval *parameters = NULL;
+
+ ZEPHIR_MM_GROW();
+ zephir_fetch_params(1, 1, 0, ¶meters_param);
+
+ zephir_get_arrval(parameters, parameters_param);
+
+
+ ZEPHIR_INIT_VAR(defaultParams);
+ zephir_create_array(defaultParams, 2, 0 TSRMLS_CC);
+ add_assoc_long_ex(defaultParams, SS("content"), 0);
+ add_assoc_long_ex(defaultParams, SS("name"), 1);
+ ZEPHIR_INIT_VAR(_0);
+ array_init(_0);
+ ZEPHIR_INIT_VAR(_1);
+ ZVAL_STRING(_1, "meta", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_INIT_VAR(_2);
+ ZVAL_NULL(_2);
+ ZEPHIR_INIT_VAR(_3);
+ ZVAL_BOOL(_3, 0);
+ ZEPHIR_INIT_VAR(_4);
+ ZVAL_BOOL(_4, 1);
+ ZEPHIR_INIT_VAR(_5);
+ ZVAL_BOOL(_5, 1);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", NULL, 0, _1, parameters, defaultParams, _0, _2, _3, _4, _5);
+ zephir_check_temp_parameter(_1);
+ zephir_check_call_status();
+ RETURN_MM();
+
+}
+
/**
* Builds a SELECT tag.
*
+ *
+ * $countries = [1 => 'England', 2 => 'Poland'];
+ * $this->tag->select('country', $countries);
+ *
+ *
* @param array parameters
* @return string
*/
@@ -1025,7 +1255,7 @@ PHP_METHOD(Ice_Tag, select) {
HashPosition _4, _7;
zval *_3 = NULL, *_10 = NULL, *_23 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
- zval *parameters_param = NULL, *defaultParams, *name = NULL, *options = NULL, *option = NULL, *selected = NULL, *tmp, *value = NULL, *text = NULL, *group = NULL, *_value = NULL, *_text = NULL, *_options = NULL, *_0, *_1 = NULL, *_2 = NULL, **_6, **_9, *_11 = NULL, *_12 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL, *_18 = NULL, *_19 = NULL, *_20 = NULL, *_21 = NULL, *_22 = NULL;
+ zval *parameters_param = NULL, *defaultParams = NULL, *name = NULL, *options = NULL, *option = NULL, *selected = NULL, *tmp = NULL, *value = NULL, *text = NULL, *group = NULL, *subvalue = NULL, *subtext = NULL, *suboptions = NULL, *_0, *_1 = NULL, *_2 = NULL, **_6, **_9, *_11 = NULL, *_12 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL, *_18 = NULL, *_19 = NULL, *_20 = NULL, *_21 = NULL, *_22 = NULL;
zval *parameters = NULL, *_13 = NULL, *_24;
ZEPHIR_MM_GROW();
@@ -1035,26 +1265,26 @@ PHP_METHOD(Ice_Tag, select) {
ZEPHIR_INIT_VAR(defaultParams);
- array_init_size(defaultParams, 4);
+ zephir_create_array(defaultParams, 3, 0 TSRMLS_CC);
add_assoc_long_ex(defaultParams, SS("id"), 0);
add_assoc_long_ex(defaultParams, SS("name"), 0);
add_assoc_long_ex(defaultParams, SS("options"), 1);
ZEPHIR_OBS_VAR(name);
if (!(zephir_array_isset_string_fetch(&name, parameters, SS("name"), 0 TSRMLS_CC))) {
ZEPHIR_OBS_NVAR(name);
- zephir_array_fetch_string(&_0, defaultParams, SL("name"), PH_READONLY, "ice/tag.zep", 409 TSRMLS_CC);
+ zephir_array_fetch_string(&_0, defaultParams, SL("name"), PH_READONLY, "ice/tag.zep", 586 TSRMLS_CC);
zephir_array_isset_fetch(&name, parameters, _0, 0 TSRMLS_CC);
}
ZEPHIR_OBS_VAR(options);
if (!(zephir_array_isset_string_fetch(&options, parameters, SS("options"), 0 TSRMLS_CC))) {
ZEPHIR_OBS_NVAR(options);
- zephir_array_fetch_string(&_0, defaultParams, SL("options"), PH_READONLY, "ice/tag.zep", 413 TSRMLS_CC);
+ zephir_array_fetch_string(&_0, defaultParams, SL("options"), PH_READONLY, "ice/tag.zep", 590 TSRMLS_CC);
zephir_array_isset_fetch(&options, parameters, _0, 0 TSRMLS_CC);
}
- ZEPHIR_CALL_METHOD(&_1, this_ptr, "hasvalue", NULL, name);
+ ZEPHIR_CALL_METHOD(&_1, this_ptr, "hasvalue", NULL, 0, name);
zephir_check_call_status();
if (zephir_is_true(_1)) {
- ZEPHIR_CALL_METHOD(&selected, this_ptr, "getvalue", NULL, name);
+ ZEPHIR_CALL_METHOD(&selected, this_ptr, "getvalue", NULL, 0, name);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(selected);
@@ -1071,7 +1301,7 @@ PHP_METHOD(Ice_Tag, select) {
array_init(selected);
} else {
ZEPHIR_INIT_VAR(tmp);
- array_init_size(tmp, 2);
+ zephir_create_array(tmp, 1, 0 TSRMLS_CC);
zephir_get_strval(_3, selected);
zephir_array_fast_append(tmp, _3);
ZEPHIR_CPY_WRT(selected, tmp);
@@ -1081,7 +1311,7 @@ PHP_METHOD(Ice_Tag, select) {
ZEPHIR_INIT_NVAR(options);
ZVAL_STRING(options, "", 1);
} else {
- zephir_is_iterable(options, &_5, &_4, 1, 0, "ice/tag.zep", 485);
+ zephir_is_iterable(options, &_5, &_4, 1, 0, "ice/tag.zep", 662);
for (
; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS
; zephir_hash_move_forward_ex(_5, &_4)
@@ -1090,32 +1320,32 @@ PHP_METHOD(Ice_Tag, select) {
ZEPHIR_GET_HVALUE(text, _6);
if (Z_TYPE_P(text) == IS_ARRAY) {
ZEPHIR_INIT_NVAR(group);
- array_init_size(group, 2);
+ zephir_create_array(group, 1, 0 TSRMLS_CC);
zephir_array_update_string(&group, SL("label"), &value, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_NVAR(_options);
- array_init(_options);
- zephir_is_iterable(text, &_8, &_7, 0, 0, "ice/tag.zep", 464);
+ ZEPHIR_INIT_NVAR(suboptions);
+ array_init(suboptions);
+ zephir_is_iterable(text, &_8, &_7, 0, 0, "ice/tag.zep", 641);
for (
; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS
; zephir_hash_move_forward_ex(_8, &_7)
) {
- ZEPHIR_GET_HMKEY(_value, _8, _7);
- ZEPHIR_GET_HVALUE(_text, _9);
- zephir_get_strval(_10, _value);
- ZEPHIR_CPY_WRT(_value, _10);
+ ZEPHIR_GET_HMKEY(subvalue, _8, _7);
+ ZEPHIR_GET_HVALUE(subtext, _9);
+ zephir_get_strval(_10, subvalue);
+ ZEPHIR_CPY_WRT(subvalue, _10);
ZEPHIR_INIT_NVAR(option);
- array_init_size(option, 2);
- zephir_array_update_string(&option, SL("value"), &_value, PH_COPY | PH_SEPARATE);
- if (zephir_fast_in_array(_value, selected TSRMLS_CC)) {
+ zephir_create_array(option, 1, 0 TSRMLS_CC);
+ zephir_array_update_string(&option, SL("value"), &subvalue, PH_COPY | PH_SEPARATE);
+ if (zephir_fast_in_array(subvalue, selected TSRMLS_CC)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "selected", 1);
zephir_array_update_string(&option, SL("selected"), &_2, PH_COPY | PH_SEPARATE);
}
- zephir_array_update_string(&option, SL("content"), &_text, PH_COPY | PH_SEPARATE);
+ zephir_array_update_string(&option, SL("content"), &subtext, PH_COPY | PH_SEPARATE);
ZEPHIR_INIT_NVAR(_12);
array_init(_12);
ZEPHIR_INIT_NVAR(_13);
- array_init_size(_13, 2);
+ zephir_create_array(_13, 1, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_14);
ZVAL_STRING(_14, "content", 1);
zephir_array_fast_append(_13, _14);
@@ -1125,18 +1355,18 @@ PHP_METHOD(Ice_Tag, select) {
ZVAL_STRING(_15, "content", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_NVAR(_16);
ZVAL_BOOL(_16, 1);
- ZEPHIR_CALL_METHOD(&_11, this_ptr, "taghtml", &_17, _14, option, _12, _13, _15, _16);
+ ZEPHIR_CALL_METHOD(&_11, this_ptr, "taghtml", &_17, 0, _14, option, _12, _13, _15, _16);
zephir_check_temp_parameter(_14);
zephir_check_temp_parameter(_15);
zephir_check_call_status();
- zephir_array_append(&_options, _11, PH_SEPARATE, "ice/tag.zep", 460);
+ zephir_array_append(&suboptions, _11, PH_SEPARATE, "ice/tag.zep", 637);
}
ZEPHIR_INIT_NVAR(_12);
ZEPHIR_GET_CONSTANT(_12, "PHP_EOL");
ZEPHIR_INIT_NVAR(_14);
ZEPHIR_INIT_NVAR(_15);
ZEPHIR_GET_CONSTANT(_15, "PHP_EOL");
- zephir_fast_join(_14, _15, _options TSRMLS_CC);
+ zephir_fast_join(_14, _15, suboptions TSRMLS_CC);
ZEPHIR_INIT_NVAR(_16);
ZEPHIR_GET_CONSTANT(_16, "PHP_EOL");
ZEPHIR_INIT_LNVAR(_18);
@@ -1145,7 +1375,7 @@ PHP_METHOD(Ice_Tag, select) {
ZEPHIR_INIT_NVAR(_19);
array_init(_19);
ZEPHIR_INIT_NVAR(_13);
- array_init_size(_13, 2);
+ zephir_create_array(_13, 1, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_20);
ZVAL_STRING(_20, "content", 1);
zephir_array_fast_append(_13, _20);
@@ -1155,7 +1385,7 @@ PHP_METHOD(Ice_Tag, select) {
ZVAL_STRING(_21, "content", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_NVAR(_22);
ZVAL_BOOL(_22, 1);
- ZEPHIR_CALL_METHOD(&_11, this_ptr, "taghtml", &_17, _20, group, _19, _13, _21, _22);
+ ZEPHIR_CALL_METHOD(&_11, this_ptr, "taghtml", &_17, 0, _20, group, _19, _13, _21, _22);
zephir_check_temp_parameter(_20);
zephir_check_temp_parameter(_21);
zephir_check_call_status();
@@ -1164,7 +1394,7 @@ PHP_METHOD(Ice_Tag, select) {
zephir_get_strval(_23, value);
ZEPHIR_CPY_WRT(value, _23);
ZEPHIR_INIT_NVAR(option);
- array_init_size(option, 2);
+ zephir_create_array(option, 1, 0 TSRMLS_CC);
zephir_array_update_string(&option, SL("value"), &value, PH_COPY | PH_SEPARATE);
if (zephir_fast_in_array(value, selected TSRMLS_CC)) {
ZEPHIR_INIT_NVAR(_19);
@@ -1175,7 +1405,7 @@ PHP_METHOD(Ice_Tag, select) {
ZEPHIR_INIT_NVAR(_12);
array_init(_12);
ZEPHIR_INIT_NVAR(_13);
- array_init_size(_13, 2);
+ zephir_create_array(_13, 1, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_14);
ZVAL_STRING(_14, "content", 1);
zephir_array_fast_append(_13, _14);
@@ -1185,7 +1415,7 @@ PHP_METHOD(Ice_Tag, select) {
ZVAL_STRING(_15, "content", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_NVAR(_16);
ZVAL_BOOL(_16, 1);
- ZEPHIR_CALL_METHOD(&_11, this_ptr, "taghtml", &_17, _14, option, _12, _13, _15, _16);
+ ZEPHIR_CALL_METHOD(&_11, this_ptr, "taghtml", &_17, 0, _14, option, _12, _13, _15, _16);
zephir_check_temp_parameter(_14);
zephir_check_temp_parameter(_15);
zephir_check_call_status();
@@ -1199,7 +1429,7 @@ PHP_METHOD(Ice_Tag, select) {
zephir_array_update_string(¶meters, SL("content"), &_14, PH_COPY | PH_SEPARATE);
}
ZEPHIR_INIT_VAR(_24);
- array_init_size(_24, 4);
+ zephir_create_array(_24, 3, 0 TSRMLS_CC);
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "content", 1);
zephir_array_fast_append(_24, _2);
@@ -1217,7 +1447,7 @@ PHP_METHOD(Ice_Tag, select) {
ZVAL_BOOL(_19, 1);
ZEPHIR_INIT_NVAR(_20);
ZVAL_BOOL(_20, 1);
- ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", &_17, _2, parameters, defaultParams, _24, _16, _19, _20);
+ ZEPHIR_RETURN_CALL_METHOD(this_ptr, "taghtml", &_17, 0, _2, parameters, defaultParams, _24, _16, _19, _20);
zephir_check_temp_parameter(_2);
zephir_check_temp_parameter(_16);
zephir_check_call_status();
@@ -1243,9 +1473,9 @@ PHP_METHOD(Ice_Tag, tagHtml) {
int ZEPHIR_LAST_CALL_STATUS;
HashTable *_1, *_4;
HashPosition _0, _3;
- zend_bool close, eol, single, _7, _8;
+ zend_bool close, eol, single, _8, _9;
zval *parameters = NULL, *defaultParams = NULL, *skip = NULL;
- zval *name_param = NULL, *parameters_param = NULL, *defaultParams_param = NULL, *skip_param = NULL, *content_param = NULL, *close_param = NULL, *eol_param = NULL, *single_param = NULL, *params = NULL, *param = NULL, *key = NULL, *value = NULL, *attributes = NULL, *code = NULL, **_2, **_5, *_6 = NULL, *_9 = NULL, *_10, *_11, *_12 = NULL, *_13;
+ zval *name_param = NULL, *parameters_param = NULL, *defaultParams_param = NULL, *skip_param = NULL, *content_param = NULL, *close_param = NULL, *eol_param = NULL, *single_param = NULL, *params = NULL, *param = NULL, *key = NULL, *value = NULL, *attributes = NULL, *code = NULL, **_2, **_5, *_6 = NULL, *_7 = NULL, *_10 = NULL, *_11, *_12, *_13 = NULL, *_14;
zval *name = NULL, *content = NULL;
ZEPHIR_MM_GROW();
@@ -1257,7 +1487,6 @@ PHP_METHOD(Ice_Tag, tagHtml) {
array_init(parameters);
} else {
parameters = parameters_param;
-
}
if (!defaultParams_param) {
ZEPHIR_INIT_VAR(defaultParams);
@@ -1297,7 +1526,7 @@ PHP_METHOD(Ice_Tag, tagHtml) {
ZEPHIR_INIT_VAR(attributes);
array_init(attributes);
ZEPHIR_CPY_WRT(params, parameters);
- zephir_is_iterable(defaultParams, &_1, &_0, 0, 0, "ice/tag.zep", 521);
+ zephir_is_iterable(defaultParams, &_1, &_0, 0, 0, "ice/tag.zep", 698);
for (
; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS
; zephir_hash_move_forward_ex(_1, &_0)
@@ -1313,7 +1542,7 @@ PHP_METHOD(Ice_Tag, tagHtml) {
zephir_array_update_zval(&attributes, param, &key, PH_COPY | PH_SEPARATE);
}
}
- zephir_is_iterable(defaultParams, &_4, &_3, 0, 0, "ice/tag.zep", 525);
+ zephir_is_iterable(defaultParams, &_4, &_3, 0, 0, "ice/tag.zep", 702);
for (
; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS
; zephir_hash_move_forward_ex(_4, &_3)
@@ -1324,28 +1553,34 @@ PHP_METHOD(Ice_Tag, tagHtml) {
ZEPHIR_INIT_VAR(_6);
zephir_fast_array_merge(_6, &(attributes), &(params) TSRMLS_CC);
ZEPHIR_CPY_WRT(attributes, _6);
- ZEPHIR_CALL_METHOD(&code, this_ptr, "preparetag", NULL, name, attributes, skip, (single ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false)));
+ ZEPHIR_INIT_NVAR(_6);
+ if (single) {
+ ZVAL_BOOL(_6, 1);
+ } else {
+ ZVAL_BOOL(_6, 0);
+ }
+ ZEPHIR_CALL_METHOD(&code, this_ptr, "preparetag", NULL, 0, name, attributes, skip, _6);
zephir_check_call_status();
if (eol) {
- ZEPHIR_INIT_NVAR(_6);
- ZEPHIR_GET_CONSTANT(_6, "PHP_EOL");
- zephir_concat_self(&code, _6 TSRMLS_CC);
+ ZEPHIR_INIT_VAR(_7);
+ ZEPHIR_GET_CONSTANT(_7, "PHP_EOL");
+ zephir_concat_self(&code, _7 TSRMLS_CC);
}
- if (content && Z_STRLEN_P(content)) {
- _7 = ZEPHIR_IS_STRING(name, "textarea");
- if (_7) {
- _7 = zephir_array_isset_string(attributes, SS("name"));
- }
- _8 = _7;
+ if (!(!content) && Z_STRLEN_P(content)) {
+ _8 = ZEPHIR_IS_STRING(name, "textarea");
if (_8) {
- zephir_array_fetch_string(&_10, attributes, SL("name"), PH_NOISY | PH_READONLY, "ice/tag.zep", 534 TSRMLS_CC);
- ZEPHIR_CALL_METHOD(&_9, this_ptr, "hasvalue", NULL, _10);
+ _8 = zephir_array_isset_string(attributes, SS("name"));
+ }
+ _9 = _8;
+ if (_9) {
+ zephir_array_fetch_string(&_11, attributes, SL("name"), PH_NOISY | PH_READONLY, "ice/tag.zep", 711 TSRMLS_CC);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "hasvalue", NULL, 0, _11);
zephir_check_call_status();
- _8 = zephir_is_true(_9);
+ _9 = zephir_is_true(_10);
}
- if (_8) {
- zephir_array_fetch_string(&_11, attributes, SL("name"), PH_NOISY | PH_READONLY, "ice/tag.zep", 535 TSRMLS_CC);
- ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, _11);
+ if (_9) {
+ zephir_array_fetch_string(&_12, attributes, SL("name"), PH_NOISY | PH_READONLY, "ice/tag.zep", 712 TSRMLS_CC);
+ ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, 0, _12);
zephir_check_call_status();
} else {
ZEPHIR_OBS_NVAR(value);
@@ -1354,19 +1589,25 @@ PHP_METHOD(Ice_Tag, tagHtml) {
zephir_concat_self(&code, value TSRMLS_CC);
}
if (close) {
- ZEPHIR_INIT_VAR(_12);
+ ZEPHIR_INIT_VAR(_13);
+ if (eol) {
+ ZEPHIR_INIT_NVAR(_13);
+ ZEPHIR_GET_CONSTANT(_13, "PHP_EOL");
+ } else {
+ ZEPHIR_INIT_NVAR(_13);
+ ZVAL_STRING(_13, "", 1);
+ }
+ ZEPHIR_INIT_NVAR(_7);
if (eol) {
- ZEPHIR_INIT_NVAR(_12);
- ZEPHIR_GET_CONSTANT(_12, "PHP_EOL");
+ ZVAL_BOOL(_7, 1);
} else {
- ZEPHIR_INIT_NVAR(_12);
- ZVAL_STRING(_12, "", 1);
+ ZVAL_BOOL(_7, 0);
}
- ZEPHIR_CALL_METHOD(&_9, this_ptr, "endtag", NULL, name, (eol ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false)));
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "endtag", NULL, 0, name, _7);
zephir_check_call_status();
- ZEPHIR_INIT_VAR(_13);
- ZEPHIR_CONCAT_VV(_13, _12, _9);
- zephir_concat_self(&code, _13 TSRMLS_CC);
+ ZEPHIR_INIT_VAR(_14);
+ ZEPHIR_CONCAT_VV(_14, _13, _10);
+ zephir_concat_self(&code, _14 TSRMLS_CC);
}
RETURN_CCTOR(code);
@@ -1375,6 +1616,11 @@ PHP_METHOD(Ice_Tag, tagHtml) {
/**
* Builds a HTML close tag.
*
+ *
+ * // Sleet
+ * {{ end_tag('form') }}
+ *
+ *
* @param string name
* @param boolean eol
* @return string
@@ -1420,14 +1666,13 @@ PHP_METHOD(Ice_Tag, endTag) {
*/
PHP_METHOD(Ice_Tag, prepareTag) {
- HashTable *_11;
- HashPosition _10;
+ HashTable *_9;
+ HashPosition _8;
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_3 = NULL;
- zend_bool single, _8, _9, _13, _15;
+ zend_bool single, _6, _7, _11, _13;
zval *attributes = NULL, *skip = NULL;
- zval *name_param = NULL, *attributes_param = NULL, *skip_param = NULL, *single_param = NULL, *order, *keys = NULL, *attrs, *code = NULL, *tmp = NULL, *value = NULL, *key = NULL, *_0 = NULL, *_1 = NULL, *_5 = NULL, *_6 = NULL, *_7, **_12, *_14, *_16, *_17 = NULL, *_18, *_19 = NULL, *_20 = NULL;
- zval *name = NULL, *_4;
+ zval *name_param = NULL, *attributes_param = NULL, *skip_param = NULL, *single_param = NULL, *order = NULL, *keys = NULL, *attrs = NULL, *code = NULL, *tmp = NULL, *value = NULL, *key = NULL, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_5, **_10, *_12, *_14, *_15 = NULL, *_16, *_17 = NULL, *_18 = NULL;
+ zval *name = NULL, *_2;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 2, &name_param, &attributes_param, &skip_param, &single_param);
@@ -1436,7 +1681,6 @@ PHP_METHOD(Ice_Tag, prepareTag) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(name_param) == IS_STRING)) {
zephir_get_strval(name, name_param);
} else {
@@ -1444,7 +1688,6 @@ PHP_METHOD(Ice_Tag, prepareTag) {
ZVAL_EMPTY_STRING(name);
}
attributes = attributes_param;
-
if (!skip_param) {
ZEPHIR_INIT_VAR(skip);
array_init(skip);
@@ -1459,7 +1702,7 @@ PHP_METHOD(Ice_Tag, prepareTag) {
ZEPHIR_INIT_VAR(order);
- array_init_size(order, 14);
+ zephir_create_array(order, 11, 0 TSRMLS_CC);
ZEPHIR_INIT_VAR(_0);
ZVAL_STRING(_0, "rel", 1);
zephir_array_fast_append(order, _0);
@@ -1493,35 +1736,35 @@ PHP_METHOD(Ice_Tag, prepareTag) {
ZEPHIR_INIT_NVAR(_0);
ZVAL_STRING(_0, "style", 1);
zephir_array_fast_append(order, _0);
- ZEPHIR_CALL_FUNCTION(&_1, "array_flip", &_2, order);
+ ZEPHIR_CALL_FUNCTION(&_1, "array_flip", NULL, 11, order);
zephir_check_call_status();
- ZEPHIR_CALL_FUNCTION(&keys, "array_intersect_key", &_3, _1, attributes);
+ ZEPHIR_CALL_FUNCTION(&keys, "array_intersect_key", NULL, 12, _1, attributes);
zephir_check_call_status();
ZEPHIR_INIT_VAR(attrs);
zephir_fast_array_merge(attrs, &(keys), &(attributes) TSRMLS_CC);
- ZEPHIR_INIT_VAR(_4);
- ZEPHIR_CONCAT_SV(_4, "<", name);
- ZEPHIR_CPY_WRT(code, _4);
+ ZEPHIR_INIT_VAR(_2);
+ ZEPHIR_CONCAT_SV(_2, "<", name);
+ ZEPHIR_CPY_WRT(code, _2);
ZEPHIR_OBS_VAR(tmp);
if (zephir_array_isset_string_fetch(&tmp, attrs, SS("name"), 0 TSRMLS_CC)) {
- ZEPHIR_CALL_METHOD(&_5, this_ptr, "hasvalue", NULL, tmp);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "hasvalue", NULL, 0, tmp);
zephir_check_call_status();
- if (zephir_is_true(_5)) {
- ZEPHIR_CALL_METHOD(&_6, this_ptr, "getvalue", NULL, tmp);
+ if (zephir_is_true(_3)) {
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "getvalue", NULL, 0, tmp);
zephir_check_call_status();
- zephir_array_update_string(&attrs, SL("value"), &_6, PH_COPY | PH_SEPARATE);
+ zephir_array_update_string(&attrs, SL("value"), &_4, PH_COPY | PH_SEPARATE);
ZEPHIR_OBS_NVAR(tmp);
if (zephir_array_isset_string_fetch(&tmp, attrs, SS("type"), 0 TSRMLS_CC)) {
- zephir_array_fetch_string(&_7, attrs, SL("value"), PH_NOISY | PH_READONLY, "ice/tag.zep", 586 TSRMLS_CC);
- _8 = zephir_is_true(_7);
- if (_8) {
- _9 = ZEPHIR_IS_STRING(tmp, "checkbox");
- if (!(_9)) {
- _9 = ZEPHIR_IS_STRING(tmp, "radio");
+ zephir_array_fetch_string(&_5, attrs, SL("value"), PH_NOISY | PH_READONLY, "ice/tag.zep", 768 TSRMLS_CC);
+ _6 = zephir_is_true(_5);
+ if (_6) {
+ _7 = ZEPHIR_IS_STRING(tmp, "checkbox");
+ if (!(_7)) {
+ _7 = ZEPHIR_IS_STRING(tmp, "radio");
}
- _8 = _9;
+ _6 = _7;
}
- if (_8) {
+ if (_6) {
ZEPHIR_INIT_NVAR(_0);
ZVAL_STRING(_0, "checked", 1);
zephir_array_update_string(&attrs, SL("checked"), &_0, PH_COPY | PH_SEPARATE);
@@ -1529,67 +1772,67 @@ PHP_METHOD(Ice_Tag, prepareTag) {
}
}
}
- zephir_is_iterable(attrs, &_11, &_10, 0, 0, "ice/tag.zep", 602);
+ zephir_is_iterable(attrs, &_9, &_8, 0, 0, "ice/tag.zep", 784);
for (
- ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS
- ; zephir_hash_move_forward_ex(_11, &_10)
+ ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS
+ ; zephir_hash_move_forward_ex(_9, &_8)
) {
- ZEPHIR_GET_HMKEY(key, _11, _10);
- ZEPHIR_GET_HVALUE(value, _12);
- _8 = Z_TYPE_P(key) == IS_STRING;
- if (_8) {
- _8 = Z_TYPE_P(value) != IS_NULL;
+ ZEPHIR_GET_HMKEY(key, _9, _8);
+ ZEPHIR_GET_HVALUE(value, _10);
+ _6 = Z_TYPE_P(key) == IS_STRING;
+ if (_6) {
+ _6 = Z_TYPE_P(value) != IS_NULL;
}
- _9 = _8;
- if (_9) {
- _9 = !ZEPHIR_IS_FALSE_IDENTICAL(value);
+ _7 = _6;
+ if (_7) {
+ _7 = !ZEPHIR_IS_FALSE_IDENTICAL(value);
}
- _13 = _9;
- if (_13) {
- _13 = !(zephir_fast_in_array(key, skip TSRMLS_CC));
+ _11 = _7;
+ if (_11) {
+ _11 = !(zephir_fast_in_array(key, skip TSRMLS_CC));
}
- if (_13) {
- _14 = zephir_fetch_nproperty_this(this_ptr, SL("_escape"), PH_NOISY_CC);
- _15 = zephir_is_true(_14);
- if (_15) {
- _16 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_17);
- ZVAL_STRING(_17, "filter", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_5, _16, "has", NULL, _17);
- zephir_check_temp_parameter(_17);
+ if (_11) {
+ _12 = zephir_fetch_nproperty_this(this_ptr, SL("escape"), PH_NOISY_CC);
+ _13 = zephir_is_true(_12);
+ if (_13) {
+ _14 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
+ ZEPHIR_INIT_NVAR(_15);
+ ZVAL_STRING(_15, "filter", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_3, _14, "has", NULL, 0, _15);
+ zephir_check_temp_parameter(_15);
zephir_check_call_status();
- _15 = zephir_is_true(_5);
+ _13 = zephir_is_true(_3);
}
- if (_15) {
- _18 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
- ZEPHIR_INIT_NVAR(_17);
- ZVAL_STRING(_17, "filter", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_6, _18, "get", NULL, _17);
- zephir_check_temp_parameter(_17);
+ if (_13) {
+ _16 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
+ ZEPHIR_INIT_NVAR(_15);
+ ZVAL_STRING(_15, "filter", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_4, _16, "get", NULL, 0, _15);
+ zephir_check_temp_parameter(_15);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_17);
- ZVAL_STRING(_17, "escape", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_19, _6, "sanitize", NULL, value, _17);
- zephir_check_temp_parameter(_17);
+ ZEPHIR_INIT_NVAR(_15);
+ ZVAL_STRING(_15, "escape", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_17, _4, "sanitize", NULL, 0, value, _15);
+ zephir_check_temp_parameter(_15);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(value, _19);
+ ZEPHIR_CPY_WRT(value, _17);
}
- ZEPHIR_INIT_LNVAR(_20);
- ZEPHIR_CONCAT_SVSVS(_20, " ", key, "=\"", value, "\"");
- zephir_concat_self(&code, _20 TSRMLS_CC);
+ ZEPHIR_INIT_LNVAR(_18);
+ ZEPHIR_CONCAT_SVSVS(_18, " ", key, "=\"", value, "\"");
+ zephir_concat_self(&code, _18 TSRMLS_CC);
}
}
if (single) {
- ZEPHIR_INIT_LNVAR(_20);
- _14 = zephir_fetch_nproperty_this(this_ptr, SL("_docType"), PH_NOISY_CC);
- if (ZEPHIR_GT_LONG(_14, 5)) {
- ZEPHIR_INIT_NVAR(_20);
- ZVAL_STRING(_20, " />", 1);
+ ZEPHIR_INIT_LNVAR(_18);
+ _12 = zephir_fetch_nproperty_this(this_ptr, SL("docType"), PH_NOISY_CC);
+ if (ZEPHIR_GT_LONG(_12, 5)) {
+ ZEPHIR_INIT_NVAR(_18);
+ ZVAL_STRING(_18, " />", 1);
} else {
- ZEPHIR_INIT_NVAR(_20);
- ZVAL_STRING(_20, ">", 1);
+ ZEPHIR_INIT_NVAR(_18);
+ ZVAL_STRING(_18, ">", 1);
}
- zephir_concat_self(&code, _20 TSRMLS_CC);
+ zephir_concat_self(&code, _18 TSRMLS_CC);
} else {
zephir_concat_self_str(&code, SL(">") TSRMLS_CC);
}
@@ -1609,16 +1852,16 @@ PHP_METHOD(Ice_Tag, hasValue) {
zval *name = NULL;
ZEPHIR_MM_GROW();
+ zephir_get_global(&_POST, SS("_POST") TSRMLS_CC);
zephir_fetch_params(1, 1, 0, &name_param);
zephir_get_strval(name, name_param);
- zephir_get_global(&_POST, SS("_POST") TSRMLS_CC);
if (zephir_array_isset(_POST, name)) {
RETURN_MM_BOOL(1);
} else {
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_values"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("values"), PH_NOISY_CC);
if (zephir_array_isset(_0, name)) {
RETURN_MM_BOOL(1);
}
@@ -1647,7 +1890,6 @@ PHP_METHOD(Ice_Tag, setValue) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'id' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(id_param) == IS_STRING)) {
zephir_get_strval(id, id_param);
} else {
@@ -1662,11 +1904,11 @@ PHP_METHOD(Ice_Tag, setValue) {
_0 = Z_TYPE_P(value) == IS_OBJECT;
}
if (_0) {
- ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Only scalar values can be assigned to UI components", "ice/tag.zep", 643);
+ ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Only scalar values can be assigned to UI components", "ice/tag.zep", 825);
return;
}
}
- zephir_update_property_array(this_ptr, SL("_values"), id, value TSRMLS_CC);
+ zephir_update_property_array(this_ptr, SL("values"), id, value TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
@@ -1681,7 +1923,7 @@ PHP_METHOD(Ice_Tag, setValue) {
PHP_METHOD(Ice_Tag, setValues) {
zend_bool merge;
- zval *values_param = NULL, *merge_param = NULL, *current, *_0;
+ zval *values_param = NULL, *merge_param = NULL, *current = NULL, *_0;
zval *values = NULL;
ZEPHIR_MM_GROW();
@@ -1696,21 +1938,21 @@ PHP_METHOD(Ice_Tag, setValues) {
if (1 != 1) {
- ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "An array is required as default values", "ice/tag.zep", 661);
+ ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "An array is required as default values", "ice/tag.zep", 843);
return;
}
if (merge) {
ZEPHIR_OBS_VAR(current);
- zephir_read_property_this(¤t, this_ptr, SL("_values"), PH_NOISY_CC);
+ zephir_read_property_this(¤t, this_ptr, SL("values"), PH_NOISY_CC);
if (Z_TYPE_P(current) == IS_ARRAY) {
ZEPHIR_INIT_VAR(_0);
zephir_fast_array_merge(_0, &(current), &(values) TSRMLS_CC);
- zephir_update_property_this(this_ptr, SL("_values"), _0 TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("values"), _0 TSRMLS_CC);
} else {
- zephir_update_property_this(this_ptr, SL("_values"), values TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("values"), values TSRMLS_CC);
}
} else {
- zephir_update_property_this(this_ptr, SL("_values"), values TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("values"), values TSRMLS_CC);
}
ZEPHIR_MM_RESTORE();
@@ -1729,16 +1971,16 @@ PHP_METHOD(Ice_Tag, getValue) {
zval *name = NULL;
ZEPHIR_MM_GROW();
+ zephir_get_global(&_POST, SS("_POST") TSRMLS_CC);
zephir_fetch_params(1, 1, 0, &name_param);
zephir_get_strval(name, name_param);
ZEPHIR_OBS_VAR(value);
- zephir_get_global(&_POST, SS("_POST") TSRMLS_CC);
if (!(zephir_array_isset_fetch(&value, _POST, name, 0 TSRMLS_CC))) {
ZEPHIR_OBS_NVAR(value);
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_values"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("values"), PH_NOISY_CC);
if (!(zephir_array_isset_fetch(&value, _0, name, 0 TSRMLS_CC))) {
RETURN_MM_NULL();
}
@@ -1750,6 +1992,12 @@ PHP_METHOD(Ice_Tag, getValue) {
/**
* Converts texts into URL-friendly titles.
*
+ *
+ * $title = "Mess'd up --text-- just (to) stress /test/ ?our! `little` \\clean\\ url fun.ction!?-->";
+ * // 'messd-up-text-just-to-stress-test-our-little-clean-url-function'
+ * $friendly = $this->tag->friendlyTitle($title);
+ *
+ *
* @param string text
* @param string separator
* @param boolean lowercase
@@ -1761,7 +2009,7 @@ PHP_METHOD(Ice_Tag, friendlyTitle) {
HashTable *_8;
HashPosition _7;
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_4 = NULL, *_13 = NULL;
+ zephir_fcall_cache_entry *_2 = NULL, *_4 = NULL, *_13 = NULL;
zend_bool lowercase, _6;
zval *text_param = NULL, *separator_param = NULL, *lowercase_param = NULL, *replace = NULL, *friendly = NULL, *locale = NULL, *search = NULL, _0 = zval_used_for_init, *_1 = NULL, _3 = zval_used_for_init, *_5 = NULL, **_9, *_10 = NULL, *_11 = NULL, *_12;
zval *text = NULL, *separator = NULL;
@@ -1788,20 +2036,20 @@ PHP_METHOD(Ice_Tag, friendlyTitle) {
ZEPHIR_SINIT_VAR(_0);
ZVAL_STRING(&_0, "iconv", 0);
- ZEPHIR_CALL_FUNCTION(&_1, "extension_loaded", &_2, &_0);
+ ZEPHIR_CALL_FUNCTION(&_1, "extension_loaded", &_2, 157, &_0);
zephir_check_call_status();
if (zephir_is_true(_1)) {
ZEPHIR_SINIT_NVAR(_0);
ZVAL_LONG(&_0, 6);
ZEPHIR_SINIT_VAR(_3);
ZVAL_STRING(&_3, "en_US.UTF-8", 0);
- ZEPHIR_CALL_FUNCTION(&locale, "setlocale", &_4, &_0, &_3);
+ ZEPHIR_CALL_FUNCTION(&locale, "setlocale", &_4, 158, &_0, &_3);
zephir_check_call_status();
ZEPHIR_SINIT_NVAR(_0);
ZVAL_STRING(&_0, "UTF-8", 0);
ZEPHIR_SINIT_NVAR(_3);
ZVAL_STRING(&_3, "ASCII//TRANSLIT", 0);
- ZEPHIR_CALL_FUNCTION(&_5, "iconv", NULL, &_0, &_3, text);
+ ZEPHIR_CALL_FUNCTION(&_5, "iconv", NULL, 159, &_0, &_3, text);
zephir_check_call_status();
zephir_get_strval(text, _5);
}
@@ -1811,11 +2059,11 @@ PHP_METHOD(Ice_Tag, friendlyTitle) {
_6 = Z_TYPE_P(replace) != IS_STRING;
}
if (_6) {
- ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Parameter replace must be an array or a string", "ice/tag.zep", 720);
+ ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Parameter replace must be an array or a string", "ice/tag.zep", 908);
return;
}
if (Z_TYPE_P(replace) == IS_ARRAY) {
- zephir_is_iterable(replace, &_8, &_7, 0, 0, "ice/tag.zep", 727);
+ zephir_is_iterable(replace, &_8, &_7, 0, 0, "ice/tag.zep", 915);
for (
; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS
; zephir_hash_move_forward_ex(_8, &_7)
@@ -1824,14 +2072,14 @@ PHP_METHOD(Ice_Tag, friendlyTitle) {
ZEPHIR_INIT_NVAR(_10);
ZEPHIR_SINIT_NVAR(_0);
ZVAL_STRING(&_0, " ", 0);
- zephir_fast_str_replace(_10, search, &_0, text TSRMLS_CC);
+ zephir_fast_str_replace(&_10, search, &_0, text TSRMLS_CC);
zephir_get_strval(text, _10);
}
} else {
ZEPHIR_INIT_NVAR(_10);
ZEPHIR_SINIT_NVAR(_3);
ZVAL_STRING(&_3, " ", 0);
- zephir_fast_str_replace(_10, replace, &_3, text TSRMLS_CC);
+ zephir_fast_str_replace(&_10, replace, &_3, text TSRMLS_CC);
zephir_get_strval(text, _10);
}
}
@@ -1839,7 +2087,7 @@ PHP_METHOD(Ice_Tag, friendlyTitle) {
ZVAL_STRING(_11, "/[^a-zA-Z0-9\\/_|+ -]/", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_VAR(_12);
ZVAL_STRING(_12, "", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_FUNCTION(&friendly, "preg_replace", &_13, _11, _12, text);
+ ZEPHIR_CALL_FUNCTION(&friendly, "preg_replace", &_13, 101, _11, _12, text);
zephir_check_temp_parameter(_11);
zephir_check_temp_parameter(_12);
zephir_check_call_status();
@@ -1850,7 +2098,7 @@ PHP_METHOD(Ice_Tag, friendlyTitle) {
}
ZEPHIR_INIT_NVAR(_11);
ZVAL_STRING(_11, "/[\\/_|+ -]+/", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_FUNCTION(&_5, "preg_replace", &_13, _11, separator, friendly);
+ ZEPHIR_CALL_FUNCTION(&_5, "preg_replace", &_13, 101, _11, separator, friendly);
zephir_check_temp_parameter(_11);
zephir_check_call_status();
ZEPHIR_CPY_WRT(friendly, _5);
@@ -1859,12 +2107,12 @@ PHP_METHOD(Ice_Tag, friendlyTitle) {
ZEPHIR_CPY_WRT(friendly, _11);
ZEPHIR_SINIT_NVAR(_3);
ZVAL_STRING(&_3, "iconv", 0);
- ZEPHIR_CALL_FUNCTION(&_5, "extension_loaded", &_2, &_3);
+ ZEPHIR_CALL_FUNCTION(&_5, "extension_loaded", &_2, 157, &_3);
zephir_check_call_status();
if (zephir_is_true(_5)) {
ZEPHIR_SINIT_NVAR(_3);
ZVAL_LONG(&_3, 6);
- ZEPHIR_CALL_FUNCTION(NULL, "setlocale", &_4, &_3, locale);
+ ZEPHIR_CALL_FUNCTION(NULL, "setlocale", &_4, 158, &_3, locale);
zephir_check_call_status();
}
RETURN_CCTOR(friendly);
@@ -1882,7 +2130,7 @@ PHP_METHOD(Ice_Tag, getDocType) {
ZEPHIR_MM_GROW();
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_docType"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("docType"), PH_NOISY_CC);
do {
if (ZEPHIR_IS_LONG(_0, 1)) {
ZEPHIR_INIT_VAR(_1);
@@ -1972,3 +2220,24 @@ PHP_METHOD(Ice_Tag, getDocType) {
}
+static zend_object_value zephir_init_properties_Ice_Tag(zend_class_entry *class_type TSRMLS_DC) {
+
+ zval *_0, *_1;
+
+ ZEPHIR_MM_GROW();
+
+ {
+ zval *this_ptr = NULL;
+ ZEPHIR_CREATE_OBJECT(this_ptr, class_type);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("meta"), PH_NOISY_CC);
+ if (Z_TYPE_P(_0) == IS_NULL) {
+ ZEPHIR_INIT_VAR(_1);
+ array_init(_1);
+ zephir_update_property_this(this_ptr, SL("meta"), _1 TSRMLS_CC);
+ }
+ ZEPHIR_MM_RESTORE();
+ return Z_OBJVAL_P(this_ptr);
+ }
+
+}
+
diff --git a/ext/ice/tag.zep.h b/ext/ice/tag.zep.h
index 60ce4c61..a1c621aa 100644
--- a/ext/ice/tag.zep.h
+++ b/ext/ice/tag.zep.h
@@ -10,10 +10,12 @@ PHP_METHOD(Ice_Tag, setTitle);
PHP_METHOD(Ice_Tag, getTitle);
PHP_METHOD(Ice_Tag, setTitleSeparator);
PHP_METHOD(Ice_Tag, getTitleSeparator);
+PHP_METHOD(Ice_Tag, getMeta);
PHP_METHOD(Ice_Tag, setEscape);
PHP_METHOD(Ice_Tag, __construct);
PHP_METHOD(Ice_Tag, appendTitle);
PHP_METHOD(Ice_Tag, prependTitle);
+PHP_METHOD(Ice_Tag, addMeta);
PHP_METHOD(Ice_Tag, textField);
PHP_METHOD(Ice_Tag, passwordField);
PHP_METHOD(Ice_Tag, hiddenField);
@@ -21,6 +23,7 @@ PHP_METHOD(Ice_Tag, fileField);
PHP_METHOD(Ice_Tag, submitButton);
PHP_METHOD(Ice_Tag, button);
PHP_METHOD(Ice_Tag, checkField);
+PHP_METHOD(Ice_Tag, radioField);
PHP_METHOD(Ice_Tag, input);
PHP_METHOD(Ice_Tag, form);
PHP_METHOD(Ice_Tag, textArea);
@@ -31,6 +34,7 @@ PHP_METHOD(Ice_Tag, a);
PHP_METHOD(Ice_Tag, link);
PHP_METHOD(Ice_Tag, script);
PHP_METHOD(Ice_Tag, style);
+PHP_METHOD(Ice_Tag, meta);
PHP_METHOD(Ice_Tag, select);
PHP_METHOD(Ice_Tag, tagHtml);
PHP_METHOD(Ice_Tag, endTag);
@@ -41,6 +45,7 @@ PHP_METHOD(Ice_Tag, setValues);
PHP_METHOD(Ice_Tag, getValue);
PHP_METHOD(Ice_Tag, friendlyTitle);
PHP_METHOD(Ice_Tag, getDocType);
+static zend_object_value zephir_init_properties_Ice_Tag(zend_class_entry *class_type TSRMLS_DC);
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_setdoctype, 0, 0, 1)
ZEND_ARG_INFO(0, docType)
@@ -68,6 +73,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_prependtitle, 0, 0, 1)
ZEND_ARG_INFO(0, separator)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_addmeta, 0, 0, 1)
+ ZEND_ARG_ARRAY_INFO(0, parameters, 0)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_textfield, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, parameters, 0)
ZEND_END_ARG_INFO()
@@ -96,6 +105,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_checkfield, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, parameters, 0)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_radiofield, 0, 0, 1)
+ ZEND_ARG_ARRAY_INFO(0, parameters, 0)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_input, 0, 0, 2)
ZEND_ARG_INFO(0, type)
ZEND_ARG_ARRAY_INFO(0, parameters, 0)
@@ -137,6 +150,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_style, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, parameters, 0)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_meta, 0, 0, 1)
+ ZEND_ARG_ARRAY_INFO(0, parameters, 0)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_tag_select, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, parameters, 0)
ZEND_END_ARG_INFO()
@@ -197,10 +214,12 @@ ZEPHIR_INIT_FUNCS(ice_tag_method_entry) {
PHP_ME(Ice_Tag, getTitle, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, setTitleSeparator, arginfo_ice_tag_settitleseparator, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, getTitleSeparator, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Ice_Tag, getMeta, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, setEscape, arginfo_ice_tag_setescape, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(Ice_Tag, appendTitle, arginfo_ice_tag_appendtitle, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, prependTitle, arginfo_ice_tag_prependtitle, ZEND_ACC_PUBLIC)
+ PHP_ME(Ice_Tag, addMeta, arginfo_ice_tag_addmeta, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, textField, arginfo_ice_tag_textfield, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, passwordField, arginfo_ice_tag_passwordfield, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, hiddenField, arginfo_ice_tag_hiddenfield, ZEND_ACC_PUBLIC)
@@ -208,6 +227,7 @@ ZEPHIR_INIT_FUNCS(ice_tag_method_entry) {
PHP_ME(Ice_Tag, submitButton, arginfo_ice_tag_submitbutton, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, button, arginfo_ice_tag_button, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, checkField, arginfo_ice_tag_checkfield, ZEND_ACC_PUBLIC)
+ PHP_ME(Ice_Tag, radioField, arginfo_ice_tag_radiofield, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, input, arginfo_ice_tag_input, ZEND_ACC_PRIVATE)
PHP_ME(Ice_Tag, form, arginfo_ice_tag_form, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, textArea, arginfo_ice_tag_textarea, ZEND_ACC_PUBLIC)
@@ -218,6 +238,7 @@ ZEPHIR_INIT_FUNCS(ice_tag_method_entry) {
PHP_ME(Ice_Tag, link, arginfo_ice_tag_link, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, script, arginfo_ice_tag_script, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, style, arginfo_ice_tag_style, ZEND_ACC_PUBLIC)
+ PHP_ME(Ice_Tag, meta, arginfo_ice_tag_meta, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, select, arginfo_ice_tag_select, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, tagHtml, arginfo_ice_tag_taghtml, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, endTag, arginfo_ice_tag_endtag, ZEND_ACC_PUBLIC)
@@ -228,5 +249,5 @@ ZEPHIR_INIT_FUNCS(ice_tag_method_entry) {
PHP_ME(Ice_Tag, getValue, arginfo_ice_tag_getvalue, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, friendlyTitle, arginfo_ice_tag_friendlytitle, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Tag, getDocType, NULL, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/text.zep.c b/ext/ice/text.zep.c
index 063ce5be..fb09d7f7 100644
--- a/ext/ice/text.zep.c
+++ b/ext/ice/text.zep.c
@@ -17,6 +17,7 @@
#include "kernel/fcall.h"
#include "kernel/string.h"
#include "kernel/operators.h"
+#include "kernel/math.h"
/**
@@ -55,10 +56,10 @@ ZEPHIR_INIT_CLASS(Ice_Text) {
*/
PHP_METHOD(Ice_Text, random) {
- zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL, *_8 = NULL;
+ zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL;
long length;
- zval *type_param = NULL, *length_param = NULL, *pool = NULL, *str, _0 = zval_used_for_init, _1 = zval_used_for_init, *_2 = NULL, *_4 = NULL, *_5 = NULL, *_7;
- int type, end, ZEPHIR_LAST_CALL_STATUS;
+ zval *type_param = NULL, *length_param = NULL, *pool = NULL, *str = NULL, _0 = zval_used_for_init, _1 = zval_used_for_init, *_2 = NULL, *_4 = NULL, *_5 = NULL, *_7;
+ int type, end = 0, ZEPHIR_LAST_CALL_STATUS;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 0, 2, &type_param, &length_param);
@@ -73,42 +74,42 @@ PHP_METHOD(Ice_Text, random) {
} else {
length = zephir_get_intval(length_param);
}
- ZEPHIR_INIT_VAR(str);
- ZVAL_STRING(str, "", 1);
+ ZEPHIR_INIT_VAR(str);
+ ZVAL_STRING(str, "", 1);
do {
if (type == 1) {
- ZEPHIR_INIT_VAR(pool);
ZEPHIR_SINIT_VAR(_0);
ZVAL_STRING(&_0, "a", 0);
ZEPHIR_SINIT_VAR(_1);
ZVAL_STRING(&_1, "z", 0);
- ZEPHIR_CALL_FUNCTION(&_2, "range", &_3, &_0, &_1);
+ ZEPHIR_CALL_FUNCTION(&_2, "range", &_3, 160, &_0, &_1);
zephir_check_call_status();
ZEPHIR_SINIT_NVAR(_0);
ZVAL_STRING(&_0, "A", 0);
ZEPHIR_SINIT_NVAR(_1);
ZVAL_STRING(&_1, "Z", 0);
- ZEPHIR_CALL_FUNCTION(&_4, "range", &_3, &_0, &_1);
+ ZEPHIR_CALL_FUNCTION(&_4, "range", &_3, 160, &_0, &_1);
zephir_check_call_status();
+ ZEPHIR_INIT_VAR(pool);
zephir_fast_array_merge(pool, &(_2), &(_4) TSRMLS_CC);
break;
}
if (type == 2) {
- ZEPHIR_INIT_NVAR(pool);
ZEPHIR_SINIT_NVAR(_0);
ZVAL_LONG(&_0, 0);
ZEPHIR_SINIT_NVAR(_1);
ZVAL_LONG(&_1, 9);
- ZEPHIR_CALL_FUNCTION(&_2, "range", &_3, &_0, &_1);
+ ZEPHIR_CALL_FUNCTION(&_2, "range", &_3, 160, &_0, &_1);
zephir_check_call_status();
ZEPHIR_SINIT_NVAR(_0);
ZVAL_STRING(&_0, "a", 0);
ZEPHIR_SINIT_NVAR(_1);
ZVAL_STRING(&_1, "f", 0);
- ZEPHIR_CALL_FUNCTION(&_4, "range", &_3, &_0, &_1);
+ ZEPHIR_CALL_FUNCTION(&_4, "range", &_3, 160, &_0, &_1);
zephir_check_call_status();
+ ZEPHIR_INIT_NVAR(pool);
zephir_fast_array_merge(pool, &(_2), &(_4) TSRMLS_CC);
break;
}
@@ -117,7 +118,7 @@ PHP_METHOD(Ice_Text, random) {
ZVAL_LONG(&_0, 0);
ZEPHIR_SINIT_NVAR(_1);
ZVAL_LONG(&_1, 9);
- ZEPHIR_CALL_FUNCTION(&pool, "range", &_3, &_0, &_1);
+ ZEPHIR_CALL_FUNCTION(&pool, "range", &_3, 160, &_0, &_1);
zephir_check_call_status();
break;
}
@@ -126,7 +127,7 @@ PHP_METHOD(Ice_Text, random) {
ZVAL_LONG(&_0, 1);
ZEPHIR_SINIT_NVAR(_1);
ZVAL_LONG(&_1, 9);
- ZEPHIR_CALL_FUNCTION(&pool, "range", &_3, &_0, &_1);
+ ZEPHIR_CALL_FUNCTION(&pool, "range", &_3, 160, &_0, &_1);
zephir_check_call_status();
break;
}
@@ -134,21 +135,21 @@ PHP_METHOD(Ice_Text, random) {
ZVAL_LONG(&_0, 0);
ZEPHIR_SINIT_NVAR(_1);
ZVAL_LONG(&_1, 9);
- ZEPHIR_CALL_FUNCTION(&_2, "range", &_3, &_0, &_1);
+ ZEPHIR_CALL_FUNCTION(&_2, "range", &_3, 160, &_0, &_1);
zephir_check_call_status();
ZEPHIR_SINIT_NVAR(_0);
ZVAL_STRING(&_0, "a", 0);
ZEPHIR_SINIT_NVAR(_1);
ZVAL_STRING(&_1, "z", 0);
- ZEPHIR_CALL_FUNCTION(&_4, "range", &_3, &_0, &_1);
+ ZEPHIR_CALL_FUNCTION(&_4, "range", &_3, 160, &_0, &_1);
zephir_check_call_status();
ZEPHIR_SINIT_NVAR(_0);
ZVAL_STRING(&_0, "A", 0);
ZEPHIR_SINIT_NVAR(_1);
ZVAL_STRING(&_1, "Z", 0);
- ZEPHIR_CALL_FUNCTION(&_5, "range", &_3, &_0, &_1);
+ ZEPHIR_CALL_FUNCTION(&_5, "range", &_3, 160, &_0, &_1);
zephir_check_call_status();
- ZEPHIR_CALL_FUNCTION(&pool, "array_merge", &_6, _2, _4, _5);
+ ZEPHIR_CALL_FUNCTION(&pool, "array_merge", &_6, 161, _2, _4, _5);
zephir_check_call_status();
break;
} while(0);
@@ -162,9 +163,7 @@ PHP_METHOD(Ice_Text, random) {
ZVAL_LONG(&_0, 0);
ZEPHIR_SINIT_NVAR(_1);
ZVAL_LONG(&_1, end);
- ZEPHIR_CALL_FUNCTION(&_2, "mt_rand", &_8, &_0, &_1);
- zephir_check_call_status();
- zephir_array_fetch(&_7, pool, _2, PH_NOISY | PH_READONLY, "ice/text.zep", 61 TSRMLS_CC);
+ zephir_array_fetch_long(&_7, pool, zephir_mt_rand(zephir_get_intval(&_0), zephir_get_intval(&_1) TSRMLS_CC), PH_NOISY | PH_READONLY, "ice/text.zep", 61 TSRMLS_CC);
zephir_concat_self(&str, _7 TSRMLS_CC);
}
RETURN_CCTOR(str);
diff --git a/ext/ice/text.zep.h b/ext/ice/text.zep.h
index c6f3a44d..8ff2b05a 100644
--- a/ext/ice/text.zep.h
+++ b/ext/ice/text.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_text_method_entry) {
PHP_ME(Ice_Text, random, arginfo_ice_text_random, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation.zep.c b/ext/ice/validation.zep.c
index 6963f735..9cf0c9ae 100644
--- a/ext/ice/validation.zep.c
+++ b/ext/ice/validation.zep.c
@@ -23,34 +23,64 @@
#include "kernel/hash.h"
#include "ext/spl/spl_exceptions.h"
+
+/**
+ * Allows to validate array data.
+ *
+ * @package Ice/Validation
+ * @category Security
+ * @author Ice Team
+ * @copyright (c) 2014-2015 Ice Team
+ * @license http://iceframework.org/license
+ * @uses Ice\Filter (if service is available)
+ * @uses Ice\I18n (if service is available)
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'fullName' => 'required',
+ * 'email' => 'required|email',
+ * 'repeatEmail' => 'same:email',
+ * 'about' => 'required|length:10,5000',
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
+ */
ZEPHIR_INIT_CLASS(Ice_Validation) {
ZEPHIR_REGISTER_CLASS(Ice, Validation, ice, validation, ice_validation_method_entry, 0);
- zend_declare_property_null(ice_validation_ce, SL("_di"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_validation_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_ce, SL("data"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_validation_ce, SL("_rules"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_ce, SL("rules"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_validation_ce, SL("_validators"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_ce, SL("validators"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_validation_ce, SL("_filters"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_ce, SL("filters"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_validation_ce, SL("_labels"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_ce, SL("labels"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_validation_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_ce, SL("messages"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_bool(ice_validation_ce, SL("_valid"), 1, ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_bool(ice_validation_ce, SL("valid"), 1, ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_validation_ce, SL("_aliases"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_ce, SL("aliases"), ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_bool(ice_validation_ce, SL("_translate"), 1, ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_bool(ice_validation_ce, SL("translate"), 1, ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_bool(ice_validation_ce, SL("_humanLabels"), 0, ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_bool(ice_validation_ce, SL("humanLabels"), 0, ZEND_ACC_PROTECTED TSRMLS_CC);
- zend_declare_property_null(ice_validation_ce, SL("_defaultMessages"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_ce, SL("defaultMessages"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ ice_validation_ce->create_object = zephir_init_properties_Ice_Validation;
return SUCCESS;
}
@@ -58,7 +88,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation) {
PHP_METHOD(Ice_Validation, getDi) {
- RETURN_MEMBER(this_ptr, "_di");
+ RETURN_MEMBER(this_ptr, "di");
}
@@ -70,7 +100,14 @@ PHP_METHOD(Ice_Validation, setRules) {
- zephir_update_property_this(this_ptr, SL("_rules"), rules TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("rules"), rules TSRMLS_CC);
+
+}
+
+PHP_METHOD(Ice_Validation, getRules) {
+
+
+ RETURN_MEMBER(this_ptr, "rules");
}
@@ -82,7 +119,7 @@ PHP_METHOD(Ice_Validation, setFilters) {
- zephir_update_property_this(this_ptr, SL("_filters"), filters TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("filters"), filters TSRMLS_CC);
}
@@ -94,7 +131,7 @@ PHP_METHOD(Ice_Validation, setLabels) {
- zephir_update_property_this(this_ptr, SL("_labels"), labels TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("labels"), labels TSRMLS_CC);
}
@@ -106,7 +143,7 @@ PHP_METHOD(Ice_Validation, setAliases) {
- zephir_update_property_this(this_ptr, SL("_aliases"), aliases TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("aliases"), aliases TSRMLS_CC);
}
@@ -118,14 +155,14 @@ PHP_METHOD(Ice_Validation, setTranslate) {
- zephir_update_property_this(this_ptr, SL("_translate"), translate TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("translate"), translate TSRMLS_CC);
}
PHP_METHOD(Ice_Validation, getTranslate) {
- RETURN_MEMBER(this_ptr, "_translate");
+ RETURN_MEMBER(this_ptr, "translate");
}
@@ -137,7 +174,7 @@ PHP_METHOD(Ice_Validation, setHumanLabels) {
- zephir_update_property_this(this_ptr, SL("_humanLabels"), humanLabels TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("humanLabels"), humanLabels TSRMLS_CC);
}
@@ -149,9 +186,9 @@ PHP_METHOD(Ice_Validation, setHumanLabels) {
PHP_METHOD(Ice_Validation, __construct) {
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_9 = NULL;
- zval *data_param = NULL, *_1, *_2, *_3, *_4, *_5, *_6, *_7, *_8 = NULL;
- zval *data = NULL, *_0;
+ zephir_fcall_cache_entry *_1 = NULL;
+ zval *data_param = NULL, *_0 = NULL;
+ zval *data = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 0, 1, &data_param);
@@ -164,57 +201,10 @@ PHP_METHOD(Ice_Validation, __construct) {
}
- ZEPHIR_INIT_VAR(_0);
- array_init_size(_0, 29);
- add_assoc_stringl_ex(_0, SS("alnum"), SL("Field :field must contain only letters and numbers"), 1);
- add_assoc_stringl_ex(_0, SS("alpha"), SL("Field :field must contain only letters"), 1);
- add_assoc_stringl_ex(_0, SS("between"), SL("Field :field must be within the range of :min to :max"), 1);
- add_assoc_stringl_ex(_0, SS("digit"), SL("Field :field must be numeric"), 1);
- add_assoc_stringl_ex(_0, SS("default"), SL("Field :field is not valid"), 1);
- add_assoc_stringl_ex(_0, SS("email"), SL("Field :field must be an email address"), 1);
- add_assoc_stringl_ex(_0, SS("fileEmpty"), SL("Field :field must not be empty"), 1);
- add_assoc_stringl_ex(_0, SS("fileIniSize"), SL("File :field exceeds the maximum file size"), 1);
- add_assoc_stringl_ex(_0, SS("fileMaxResolution"), SL("File :field must not exceed :max resolution"), 1);
- add_assoc_stringl_ex(_0, SS("fileMinResolution"), SL("File :field must be at least :min resolution"), 1);
- add_assoc_stringl_ex(_0, SS("fileSize"), SL("File :field exceeds the size of :max"), 1);
- add_assoc_stringl_ex(_0, SS("fileType"), SL("File :field must be of type: :types"), 1);
- add_assoc_stringl_ex(_0, SS("in"), SL("Field :field must be a part of list: :values"), 1);
- add_assoc_stringl_ex(_0, SS("lengthMax"), SL("Field :field must not exceed :max characters long"), 1);
- add_assoc_stringl_ex(_0, SS("lengthMin"), SL("Field :field must be at least :min characters long"), 1);
- add_assoc_stringl_ex(_0, SS("notIn"), SL("Field :field must not be a part of list: :values"), 1);
- add_assoc_stringl_ex(_0, SS("regex"), SL("Field :field does not match the required format"), 1);
- add_assoc_stringl_ex(_0, SS("required"), SL("Field :field is required"), 1);
- add_assoc_stringl_ex(_0, SS("same"), SL("Field :field and :other must match"), 1);
- add_assoc_stringl_ex(_0, SS("unique"), SL("Field :field must be unique"), 1);
- add_assoc_stringl_ex(_0, SS("url"), SL("Field :field must be a url"), 1);
- add_assoc_stringl_ex(_0, SS("with"), SL("Field :field must occur together with :fields"), 1);
- add_assoc_stringl_ex(_0, SS("without"), SL("Field :field must not occur together with :fields"), 1);
- zephir_update_property_this(this_ptr, SL("_defaultMessages"), _0 TSRMLS_CC);
- ZEPHIR_INIT_VAR(_1);
- array_init(_1);
- zephir_update_property_this(this_ptr, SL("_aliases"), _1 TSRMLS_CC);
- ZEPHIR_INIT_VAR(_2);
- array_init(_2);
- zephir_update_property_this(this_ptr, SL("_messages"), _2 TSRMLS_CC);
- ZEPHIR_INIT_VAR(_3);
- array_init(_3);
- zephir_update_property_this(this_ptr, SL("_labels"), _3 TSRMLS_CC);
- ZEPHIR_INIT_VAR(_4);
- array_init(_4);
- zephir_update_property_this(this_ptr, SL("_filters"), _4 TSRMLS_CC);
- ZEPHIR_INIT_VAR(_5);
- array_init(_5);
- zephir_update_property_this(this_ptr, SL("_validators"), _5 TSRMLS_CC);
- ZEPHIR_INIT_VAR(_6);
- array_init(_6);
- zephir_update_property_this(this_ptr, SL("_rules"), _6 TSRMLS_CC);
- ZEPHIR_INIT_VAR(_7);
- array_init(_7);
- zephir_update_property_this(this_ptr, SL("_data"), _7 TSRMLS_CC);
- ZEPHIR_CALL_CE_STATIC(&_8, ice_di_ce, "fetch", &_9);
+ ZEPHIR_CALL_CE_STATIC(&_0, ice_di_ce, "fetch", &_1, 8);
zephir_check_call_status();
- zephir_update_property_this(this_ptr, SL("_di"), _8 TSRMLS_CC);
- zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("di"), _0 TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("data"), data TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
@@ -229,9 +219,8 @@ PHP_METHOD(Ice_Validation, __construct) {
*/
PHP_METHOD(Ice_Validation, resolve) {
- zval *_6;
+ zval *_5;
int ZEPHIR_LAST_CALL_STATUS;
- zephir_nts_static zephir_fcall_cache_entry *_5 = NULL;
zval *alias_param = NULL, *field_param = NULL, *options = NULL, *rule = NULL, *_0, *_1 = NULL, *_2, _3, *_4 = NULL;
zval *alias = NULL, *field = NULL;
@@ -246,7 +235,7 @@ PHP_METHOD(Ice_Validation, resolve) {
ZEPHIR_OBS_VAR(rule);
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_aliases"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("aliases"), PH_NOISY_CC);
if (!(zephir_array_isset_fetch(&rule, _0, alias, 0 TSRMLS_CC))) {
ZEPHIR_INIT_VAR(_1);
zephir_camelize(_1, alias);
@@ -257,22 +246,22 @@ PHP_METHOD(Ice_Validation, resolve) {
object_init_ex(_2, ice_exception_ce);
ZEPHIR_SINIT_VAR(_3);
ZVAL_STRING(&_3, "Validator %s not found", 0);
- ZEPHIR_CALL_FUNCTION(&_4, "sprintf", &_5, &_3, alias);
+ ZEPHIR_CALL_FUNCTION(&_4, "sprintf", NULL, 1, &_3, alias);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, _4);
+ ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 2, _4);
zephir_check_call_status();
- zephir_throw_exception_debug(_2, "ice/validation.zep", 84 TSRMLS_CC);
+ zephir_throw_exception_debug(_2, "ice/validation.zep", 101 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
return;
}
}
ZEPHIR_INIT_NVAR(_1);
- ZEPHIR_INIT_VAR(_6);
- array_init_size(_6, 2);
- zephir_array_fast_append(_6, options);
- ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(_1, rule, _6 TSRMLS_CC);
+ ZEPHIR_INIT_VAR(_5);
+ zephir_create_array(_5, 1, 0 TSRMLS_CC);
+ zephir_array_fast_append(_5, options);
+ ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(_1, rule, _5 TSRMLS_CC);
zephir_check_call_status();
- zephir_update_property_array_multi(this_ptr, SL("_rules"), &_1 TSRMLS_CC, SL("za"), 1, field);
+ zephir_update_property_array_multi(this_ptr, SL("rules"), &_1 TSRMLS_CC, SL("za"), 2, field);
ZEPHIR_MM_RESTORE();
}
@@ -280,6 +269,19 @@ PHP_METHOD(Ice_Validation, resolve) {
/**
* Add one rule.
*
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rule('email', 'required|email');
+ * $validation->rule('content', [
+ * 'length' => [
+ * 'max' => 1000,
+ * 'messageMin' => 'Too long!',
+ * 'label' => 'Desctiption'
+ * ]
+ * ]);
+ *
+ *
* @param string field
* @param mixed validators
* @param mixed options
@@ -287,13 +289,12 @@ PHP_METHOD(Ice_Validation, resolve) {
*/
PHP_METHOD(Ice_Validation, rule) {
- zephir_nts_static zephir_fcall_cache_entry *_13 = NULL;
zend_bool _7;
- zephir_fcall_cache_entry *_4 = NULL, *_14 = NULL;
+ zephir_fcall_cache_entry *_4 = NULL, *_10 = NULL, *_14 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
- HashTable *_2, *_11;
- HashPosition _1, _10;
- zval *field_param = NULL, *validators, *options = NULL, *validator = NULL, *rules, *rule = NULL, *alias = NULL, *values = NULL, *_0, **_3, _5, *_6, _8, *_9, **_12;
+ HashTable *_2, *_12;
+ HashPosition _1, _11;
+ zval *field_param = NULL, *validators, *options = NULL, *validator = NULL, *rules = NULL, *rule = NULL, *alias = NULL, *values = NULL, *_0, **_3, _5, *_6, _8, *_9, **_13;
zval *field = NULL;
ZEPHIR_MM_GROW();
@@ -311,11 +312,11 @@ PHP_METHOD(Ice_Validation, rule) {
zephir_gettype(_0, validators TSRMLS_CC);
do {
if (ZEPHIR_IS_STRING(_0, "object")) {
- zephir_update_property_array_multi(this_ptr, SL("_rules"), &validators TSRMLS_CC, SL("za"), 1, field);
+ zephir_update_property_array_multi(this_ptr, SL("rules"), &validators TSRMLS_CC, SL("za"), 2, field);
break;
}
if (ZEPHIR_IS_STRING(_0, "array")) {
- zephir_is_iterable(validators, &_2, &_1, 0, 0, "ice/validation.zep", 114);
+ zephir_is_iterable(validators, &_2, &_1, 0, 0, "ice/validation.zep", 144);
for (
; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
; zephir_hash_move_forward_ex(_2, &_1)
@@ -325,7 +326,7 @@ PHP_METHOD(Ice_Validation, rule) {
if (Z_TYPE_P(validator) == IS_LONG) {
ZEPHIR_CPY_WRT(validator, options);
}
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "rule", &_4, field, validator, options);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "rule", &_4, 162, field, validator, options);
zephir_check_call_status();
}
break;
@@ -344,22 +345,22 @@ PHP_METHOD(Ice_Validation, rule) {
_7 = ZEPHIR_IS_FALSE_IDENTICAL(_9);
}
if (_7) {
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolve", NULL, validators, field, options);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolve", &_10, 0, validators, field, options);
zephir_check_call_status();
} else {
ZEPHIR_INIT_VAR(rules);
zephir_fast_explode_str(rules, SL("|"), validators, LONG_MAX TSRMLS_CC);
- zephir_is_iterable(rules, &_11, &_10, 0, 0, "ice/validation.zep", 133);
+ zephir_is_iterable(rules, &_12, &_11, 0, 0, "ice/validation.zep", 163);
for (
- ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS
- ; zephir_hash_move_forward_ex(_11, &_10)
+ ; zephir_hash_get_current_data_ex(_12, (void**) &_13, &_11) == SUCCESS
+ ; zephir_hash_move_forward_ex(_12, &_11)
) {
- ZEPHIR_GET_HVALUE(rule, _12);
+ ZEPHIR_GET_HVALUE(rule, _13);
ZEPHIR_INIT_NVAR(options);
zephir_fast_explode_str(options, SL(":"), rule, LONG_MAX TSRMLS_CC);
- Z_SET_ISREF_P(options);
- ZEPHIR_CALL_FUNCTION(&alias, "array_shift", &_13, options);
- Z_UNSET_ISREF_P(options);
+ ZEPHIR_MAKE_REF(options);
+ ZEPHIR_CALL_FUNCTION(&alias, "array_shift", &_14, 4, options);
+ ZEPHIR_UNREF(options);
zephir_check_call_status();
if (!ZEPHIR_IS_STRING(alias, "regex")) {
ZEPHIR_OBS_NVAR(values);
@@ -368,7 +369,7 @@ PHP_METHOD(Ice_Validation, rule) {
zephir_fast_explode_str(options, SL(","), values, LONG_MAX TSRMLS_CC);
}
}
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolve", &_14, alias, field, options);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolve", &_10, 0, alias, field, options);
zephir_check_call_status();
}
}
@@ -383,6 +384,21 @@ PHP_METHOD(Ice_Validation, rule) {
/**
* Add multiple rules at once.
*
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => 'required|length:4,24|notIn:admin,user,root|unique:users',
+ * 'password' => 'required|length:5,32',
+ * 'repeatPassword' => 'same:password',
+ * 'email' => 'email',
+ * 'status' => 'required|digit|in:0,1,2',
+ * 'website' => 'url',
+ * 'title' => 'length:,100',
+ * 'age' => 'required|between:18,21',
+ * ]);
+ *
+ *
* @param array validators
* @return void
*/
@@ -401,15 +417,14 @@ PHP_METHOD(Ice_Validation, rules) {
validators = validators_param;
-
- zephir_is_iterable(validators, &_1, &_0, 0, 0, "ice/validation.zep", 151);
+ zephir_is_iterable(validators, &_1, &_0, 0, 0, "ice/validation.zep", 196);
for (
; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS
; zephir_hash_move_forward_ex(_1, &_0)
) {
ZEPHIR_GET_HMKEY(field, _1, _0);
ZEPHIR_GET_HVALUE(rules, _2);
- ZEPHIR_CALL_METHOD(NULL, this_ptr, "rule", &_3, field, rules);
+ ZEPHIR_CALL_METHOD(NULL, this_ptr, "rule", &_3, 0, field, rules);
zephir_check_call_status();
}
ZEPHIR_MM_RESTORE();
@@ -442,34 +457,42 @@ PHP_METHOD(Ice_Validation, validate) {
if (zephir_fast_count_int(data TSRMLS_CC)) {
- zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("data"), data TSRMLS_CC);
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_rules"), PH_NOISY_CC);
- zephir_is_iterable(_0, &_2, &_1, 0, 0, "ice/validation.zep", 177);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC);
+ zephir_is_iterable(_0, &_2, &_1, 0, 0, "ice/validation.zep", 222);
for (
; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
; zephir_hash_move_forward_ex(_2, &_1)
) {
ZEPHIR_GET_HMKEY(field, _2, _1);
ZEPHIR_GET_HVALUE(rules, _3);
- zephir_is_iterable(rules, &_5, &_4, 0, 0, "ice/validation.zep", 174);
+ zephir_is_iterable(rules, &_5, &_4, 0, 0, "ice/validation.zep", 219);
for (
; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS
; zephir_hash_move_forward_ex(_5, &_4)
) {
ZEPHIR_GET_HVALUE(rule, _6);
- ZEPHIR_CALL_METHOD(&_7, rule, "validate", NULL, this_ptr, field);
+ ZEPHIR_CALL_METHOD(&_7, rule, "validate", NULL, 0, this_ptr, field);
zephir_check_call_status();
if (ZEPHIR_IS_FALSE_IDENTICAL(_7)) {
- zephir_update_property_this(this_ptr, SL("_valid"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
+ if (0) {
+ zephir_update_property_this(this_ptr, SL("valid"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
+ } else {
+ zephir_update_property_this(this_ptr, SL("valid"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
+ }
}
}
}
- _8 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC);
+ _8 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC);
if (zephir_fast_count_int(_8 TSRMLS_CC)) {
- zephir_update_property_this(this_ptr, SL("_valid"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
+ if (0) {
+ zephir_update_property_this(this_ptr, SL("valid"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
+ } else {
+ zephir_update_property_this(this_ptr, SL("valid"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
+ }
}
- RETURN_MM_MEMBER(this_ptr, "_valid");
+ RETURN_MM_MEMBER(this_ptr, "valid");
}
@@ -481,7 +504,7 @@ PHP_METHOD(Ice_Validation, validate) {
PHP_METHOD(Ice_Validation, valid) {
- RETURN_MEMBER(this_ptr, "_valid");
+ RETURN_MEMBER(this_ptr, "valid");
}
@@ -503,7 +526,6 @@ PHP_METHOD(Ice_Validation, hasValue) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -512,7 +534,7 @@ PHP_METHOD(Ice_Validation, hasValue) {
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC);
RETURN_MM_BOOL(zephir_array_isset(_0, field));
}
@@ -528,7 +550,7 @@ PHP_METHOD(Ice_Validation, getValue) {
int ZEPHIR_LAST_CALL_STATUS;
zend_bool filtered, _1, _5;
- zval *field_param = NULL, *filtered_param = NULL, *value = NULL, *filters, *_0, *_2, *_3 = NULL, *_4 = NULL, *_6, *_7, *_8 = NULL, *_9 = NULL;
+ zval *field_param = NULL, *filtered_param = NULL, *value = NULL, *filters = NULL, *_0, *_2, *_3 = NULL, *_4 = NULL, *_6, *_7, *_8 = NULL, *_9 = NULL;
zval *field = NULL;
ZEPHIR_MM_GROW();
@@ -538,7 +560,6 @@ PHP_METHOD(Ice_Validation, getValue) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -553,14 +574,14 @@ PHP_METHOD(Ice_Validation, getValue) {
ZEPHIR_OBS_VAR(value);
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC);
zephir_array_isset_fetch(&value, _0, field, 0 TSRMLS_CC);
_1 = filtered;
if (_1) {
- _2 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _2 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_4);
ZVAL_STRING(_4, "filter", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_3, _2, "has", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_3, _2, "has", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
_1 = zephir_is_true(_3);
@@ -568,17 +589,17 @@ PHP_METHOD(Ice_Validation, getValue) {
_5 = _1;
if (_5) {
ZEPHIR_OBS_VAR(filters);
- _6 = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC);
+ _6 = zephir_fetch_nproperty_this(this_ptr, SL("filters"), PH_NOISY_CC);
_5 = zephir_array_isset_fetch(&filters, _6, field, 0 TSRMLS_CC);
}
if (_5) {
- _7 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _7 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "filter", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, _7, "get", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_8, _7, "get", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_9, _8, "sanitize", NULL, value, filters);
+ ZEPHIR_CALL_METHOD(&_9, _8, "sanitize", NULL, 0, value, filters);
zephir_check_call_status();
ZEPHIR_CPY_WRT(value, _9);
}
@@ -586,6 +607,113 @@ PHP_METHOD(Ice_Validation, getValue) {
}
+/**
+ * Get the values by fields.
+ * Values are automatically filtered out if filters have been setted.
+ *
+ *
+ * // Get value for one field
+ * $validation->getValues('password');
+ *
+ * // Get values for multiple fields
+ * $validation->getValues(['fullName', 'about']);
+ *
+ * // Get all values
+ * $validation->getValues();
+ *
+ *
+ * @param mixed fields The data keys
+ * @param boolean filtered Get the filtered value or original
+ * @return mixed
+ */
+PHP_METHOD(Ice_Validation, getValues) {
+
+ zephir_fcall_cache_entry *_7 = NULL;
+ int ZEPHIR_LAST_CALL_STATUS;
+ HashTable *_3, *_9;
+ HashPosition _2, _8;
+ zend_bool filtered;
+ zval *fields = NULL, *filtered_param = NULL, *data = NULL, *field = NULL, *_0, *_1 = NULL, **_4, *_5 = NULL, *_6 = NULL, **_10;
+
+ ZEPHIR_MM_GROW();
+ zephir_fetch_params(1, 0, 2, &fields, &filtered_param);
+
+ if (!fields) {
+ fields = ZEPHIR_GLOBAL(global_null);
+ }
+ if (!filtered_param) {
+ filtered = 1;
+ } else {
+ filtered = zephir_get_boolval(filtered_param);
+ }
+
+
+ ZEPHIR_INIT_VAR(data);
+ array_init(data);
+ if (Z_TYPE_P(fields) == IS_NULL) {
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC);
+ ZEPHIR_INIT_VAR(_1);
+ zephir_is_iterable(_0, &_3, &_2, 0, 0, "ice/validation.zep", 300);
+ for (
+ ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS
+ ; zephir_hash_move_forward_ex(_3, &_2)
+ ) {
+ ZEPHIR_GET_HMKEY(field, _3, _2);
+ ZEPHIR_GET_HVALUE(_1, _4);
+ ZEPHIR_INIT_NVAR(_6);
+ if (filtered) {
+ ZVAL_BOOL(_6, 1);
+ } else {
+ ZVAL_BOOL(_6, 0);
+ }
+ ZEPHIR_CALL_METHOD(&_5, this_ptr, "getvalue", &_7, 0, field, _6);
+ zephir_check_call_status();
+ zephir_array_update_zval(&data, field, &_5, PH_COPY | PH_SEPARATE);
+ }
+ } else {
+ ZEPHIR_INIT_NVAR(_1);
+ zephir_gettype(_1, fields TSRMLS_CC);
+ do {
+ if (ZEPHIR_IS_STRING(_1, "array")) {
+ zephir_is_iterable(fields, &_9, &_8, 0, 0, "ice/validation.zep", 308);
+ for (
+ ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS
+ ; zephir_hash_move_forward_ex(_9, &_8)
+ ) {
+ ZEPHIR_GET_HVALUE(field, _10);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC);
+ if (zephir_array_isset(_0, field)) {
+ ZEPHIR_INIT_NVAR(_6);
+ if (filtered) {
+ ZVAL_BOOL(_6, 1);
+ } else {
+ ZVAL_BOOL(_6, 0);
+ }
+ ZEPHIR_CALL_METHOD(&_5, this_ptr, "getvalue", &_7, 0, field, _6);
+ zephir_check_call_status();
+ zephir_array_update_zval(&data, field, &_5, PH_COPY | PH_SEPARATE);
+ }
+ }
+ break;
+ }
+ if (ZEPHIR_IS_STRING(_1, "string")) {
+ ZEPHIR_INIT_NVAR(_6);
+ if (filtered) {
+ ZVAL_BOOL(_6, 1);
+ } else {
+ ZVAL_BOOL(_6, 0);
+ }
+ ZEPHIR_CALL_METHOD(&data, this_ptr, "getvalue", &_7, 0, fields, _6);
+ zephir_check_call_status();
+ break;
+ }
+ } while(0);
+
+ }
+ RETURN_CCTOR(data);
+
+}
+
/**
* Get the label of a field.
* Humanize a label if humanLabels attribute and filter service is available
@@ -607,7 +735,6 @@ PHP_METHOD(Ice_Validation, getLabel) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -617,29 +744,29 @@ PHP_METHOD(Ice_Validation, getLabel) {
ZEPHIR_OBS_VAR(label);
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_labels"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("labels"), PH_NOISY_CC);
if (!(zephir_array_isset_fetch(&label, _0, field, 0 TSRMLS_CC))) {
- _1 = zephir_fetch_nproperty_this(this_ptr, SL("_humanLabels"), PH_NOISY_CC);
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("humanLabels"), PH_NOISY_CC);
_2 = zephir_is_true(_1);
if (_2) {
- _3 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _3 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_VAR(_5);
ZVAL_STRING(_5, "filter", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_4, _3, "has", NULL, _5);
+ ZEPHIR_CALL_METHOD(&_4, _3, "has", NULL, 0, _5);
zephir_check_temp_parameter(_5);
zephir_check_call_status();
_2 = zephir_is_true(_4);
}
if (_2) {
- _6 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC);
+ _6 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
ZEPHIR_INIT_NVAR(_5);
ZVAL_STRING(_5, "filter", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, _6, "get", NULL, _5);
+ ZEPHIR_CALL_METHOD(&_7, _6, "get", NULL, 0, _5);
zephir_check_temp_parameter(_5);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_5);
ZVAL_STRING(_5, "human", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, _7, "sanitize", NULL, field, _5);
+ ZEPHIR_CALL_METHOD(&label, _7, "sanitize", NULL, 0, field, _5);
zephir_check_temp_parameter(_5);
zephir_check_call_status();
} else {
@@ -673,9 +800,9 @@ PHP_METHOD(Ice_Validation, setDefaultMessages) {
ZEPHIR_INIT_VAR(_0);
- _1 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultMessages"), PH_NOISY_CC);
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("defaultMessages"), PH_NOISY_CC);
zephir_fast_array_merge(_0, &(_1), &(messages) TSRMLS_CC);
- zephir_update_property_this(this_ptr, SL("_defaultMessages"), _0 TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("defaultMessages"), _0 TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
@@ -698,7 +825,6 @@ PHP_METHOD(Ice_Validation, getDefaultMessage) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(type_param) == IS_STRING)) {
zephir_get_strval(type, type_param);
} else {
@@ -708,11 +834,11 @@ PHP_METHOD(Ice_Validation, getDefaultMessage) {
ZEPHIR_OBS_VAR(message);
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultMessages"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("defaultMessages"), PH_NOISY_CC);
if (!(zephir_array_isset_fetch(&message, _0, type, 0 TSRMLS_CC))) {
- _1 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultMessages"), PH_NOISY_CC);
+ _1 = zephir_fetch_nproperty_this(this_ptr, SL("defaultMessages"), PH_NOISY_CC);
ZEPHIR_OBS_NVAR(message);
- zephir_array_fetch_string(&message, _1, SL("default"), PH_NOISY, "ice/validation.zep", 271 TSRMLS_CC);
+ zephir_array_fetch_string(&message, _1, SL("default"), PH_NOISY, "ice/validation.zep", 363 TSRMLS_CC);
}
RETURN_CCTOR(message);
@@ -737,7 +863,6 @@ PHP_METHOD(Ice_Validation, addMessage) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -747,7 +872,7 @@ PHP_METHOD(Ice_Validation, addMessage) {
zephir_get_strval(message, message_param);
- zephir_update_property_array_multi(this_ptr, SL("_messages"), &message TSRMLS_CC, SL("za"), 1, field);
+ zephir_update_property_array_multi(this_ptr, SL("messages"), &message TSRMLS_CC, SL("za"), 2, field);
ZEPHIR_MM_RESTORE();
}
@@ -765,10 +890,97 @@ PHP_METHOD(Ice_Validation, getMessages) {
ZEPHIR_MM_GROW();
object_init_ex(return_value, ice_arr_ce);
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC);
- ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _0);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC);
+ ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 6, _0);
zephir_check_call_status();
RETURN_MM();
}
+static zend_object_value zephir_init_properties_Ice_Validation(zend_class_entry *class_type TSRMLS_DC) {
+
+ zval *_1;
+ zval *_0, *_2, *_3 = NULL, *_4, *_5, *_6, *_7, *_8, *_9;
+
+ ZEPHIR_MM_GROW();
+
+ {
+ zval *this_ptr = NULL;
+ ZEPHIR_CREATE_OBJECT(this_ptr, class_type);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("defaultMessages"), PH_NOISY_CC);
+ if (Z_TYPE_P(_0) == IS_NULL) {
+ ZEPHIR_INIT_VAR(_1);
+ zephir_create_array(_1, 23, 0 TSRMLS_CC);
+ add_assoc_stringl_ex(_1, SS("alnum"), SL("Field :field must contain only letters and numbers"), 1);
+ add_assoc_stringl_ex(_1, SS("alpha"), SL("Field :field must contain only letters"), 1);
+ add_assoc_stringl_ex(_1, SS("between"), SL("Field :field must be within the range of :min to :max"), 1);
+ add_assoc_stringl_ex(_1, SS("digit"), SL("Field :field must be numeric"), 1);
+ add_assoc_stringl_ex(_1, SS("default"), SL("Field :field is not valid"), 1);
+ add_assoc_stringl_ex(_1, SS("email"), SL("Field :field must be an email address"), 1);
+ add_assoc_stringl_ex(_1, SS("fileEmpty"), SL("Field :field must not be empty"), 1);
+ add_assoc_stringl_ex(_1, SS("fileIniSize"), SL("File :field exceeds the maximum file size"), 1);
+ add_assoc_stringl_ex(_1, SS("fileMaxResolution"), SL("File :field must not exceed :max resolution"), 1);
+ add_assoc_stringl_ex(_1, SS("fileMinResolution"), SL("File :field must be at least :min resolution"), 1);
+ add_assoc_stringl_ex(_1, SS("fileSize"), SL("File :field exceeds the size of :max"), 1);
+ add_assoc_stringl_ex(_1, SS("fileType"), SL("File :field must be of type: :types"), 1);
+ add_assoc_stringl_ex(_1, SS("in"), SL("Field :field must be a part of list: :values"), 1);
+ add_assoc_stringl_ex(_1, SS("lengthMax"), SL("Field :field must not exceed :max characters long"), 1);
+ add_assoc_stringl_ex(_1, SS("lengthMin"), SL("Field :field must be at least :min characters long"), 1);
+ add_assoc_stringl_ex(_1, SS("notIn"), SL("Field :field must not be a part of list: :values"), 1);
+ add_assoc_stringl_ex(_1, SS("regex"), SL("Field :field does not match the required format"), 1);
+ add_assoc_stringl_ex(_1, SS("required"), SL("Field :field is required"), 1);
+ add_assoc_stringl_ex(_1, SS("same"), SL("Field :field and :other must match"), 1);
+ add_assoc_stringl_ex(_1, SS("unique"), SL("Field :field must be unique"), 1);
+ add_assoc_stringl_ex(_1, SS("url"), SL("Field :field must be a url"), 1);
+ add_assoc_stringl_ex(_1, SS("with"), SL("Field :field must occur together with :fields"), 1);
+ add_assoc_stringl_ex(_1, SS("without"), SL("Field :field must not occur together with :fields"), 1);
+ zephir_update_property_this(this_ptr, SL("defaultMessages"), _1 TSRMLS_CC);
+ }
+ _2 = zephir_fetch_nproperty_this(this_ptr, SL("aliases"), PH_NOISY_CC);
+ if (Z_TYPE_P(_2) == IS_NULL) {
+ ZEPHIR_INIT_VAR(_3);
+ array_init(_3);
+ zephir_update_property_this(this_ptr, SL("aliases"), _3 TSRMLS_CC);
+ }
+ _4 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC);
+ if (Z_TYPE_P(_4) == IS_NULL) {
+ ZEPHIR_INIT_NVAR(_3);
+ array_init(_3);
+ zephir_update_property_this(this_ptr, SL("messages"), _3 TSRMLS_CC);
+ }
+ _5 = zephir_fetch_nproperty_this(this_ptr, SL("labels"), PH_NOISY_CC);
+ if (Z_TYPE_P(_5) == IS_NULL) {
+ ZEPHIR_INIT_NVAR(_3);
+ array_init(_3);
+ zephir_update_property_this(this_ptr, SL("labels"), _3 TSRMLS_CC);
+ }
+ _6 = zephir_fetch_nproperty_this(this_ptr, SL("filters"), PH_NOISY_CC);
+ if (Z_TYPE_P(_6) == IS_NULL) {
+ ZEPHIR_INIT_NVAR(_3);
+ array_init(_3);
+ zephir_update_property_this(this_ptr, SL("filters"), _3 TSRMLS_CC);
+ }
+ _7 = zephir_fetch_nproperty_this(this_ptr, SL("validators"), PH_NOISY_CC);
+ if (Z_TYPE_P(_7) == IS_NULL) {
+ ZEPHIR_INIT_NVAR(_3);
+ array_init(_3);
+ zephir_update_property_this(this_ptr, SL("validators"), _3 TSRMLS_CC);
+ }
+ _8 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC);
+ if (Z_TYPE_P(_8) == IS_NULL) {
+ ZEPHIR_INIT_NVAR(_3);
+ array_init(_3);
+ zephir_update_property_this(this_ptr, SL("rules"), _3 TSRMLS_CC);
+ }
+ _9 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC);
+ if (Z_TYPE_P(_9) == IS_NULL) {
+ ZEPHIR_INIT_NVAR(_3);
+ array_init(_3);
+ zephir_update_property_this(this_ptr, SL("data"), _3 TSRMLS_CC);
+ }
+ ZEPHIR_MM_RESTORE();
+ return Z_OBJVAL_P(this_ptr);
+ }
+
+}
+
diff --git a/ext/ice/validation.zep.h b/ext/ice/validation.zep.h
index 40b1e20a..a7864a19 100644
--- a/ext/ice/validation.zep.h
+++ b/ext/ice/validation.zep.h
@@ -5,6 +5,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation);
PHP_METHOD(Ice_Validation, getDi);
PHP_METHOD(Ice_Validation, setRules);
+PHP_METHOD(Ice_Validation, getRules);
PHP_METHOD(Ice_Validation, setFilters);
PHP_METHOD(Ice_Validation, setLabels);
PHP_METHOD(Ice_Validation, setAliases);
@@ -19,11 +20,13 @@ PHP_METHOD(Ice_Validation, validate);
PHP_METHOD(Ice_Validation, valid);
PHP_METHOD(Ice_Validation, hasValue);
PHP_METHOD(Ice_Validation, getValue);
+PHP_METHOD(Ice_Validation, getValues);
PHP_METHOD(Ice_Validation, getLabel);
PHP_METHOD(Ice_Validation, setDefaultMessages);
PHP_METHOD(Ice_Validation, getDefaultMessage);
PHP_METHOD(Ice_Validation, addMessage);
PHP_METHOD(Ice_Validation, getMessages);
+static zend_object_value zephir_init_properties_Ice_Validation(zend_class_entry *class_type TSRMLS_DC);
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_validation_setrules, 0, 0, 1)
ZEND_ARG_INFO(0, rules)
@@ -82,6 +85,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_validation_getvalue, 0, 0, 1)
ZEND_ARG_INFO(0, filtered)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_validation_getvalues, 0, 0, 0)
+ ZEND_ARG_INFO(0, fields)
+ ZEND_ARG_INFO(0, filtered)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_validation_getlabel, 0, 0, 1)
ZEND_ARG_INFO(0, field)
ZEND_END_ARG_INFO()
@@ -102,6 +110,7 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_method_entry) {
PHP_ME(Ice_Validation, getDi, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, setRules, arginfo_ice_validation_setrules, ZEND_ACC_PUBLIC)
+ PHP_ME(Ice_Validation, getRules, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, setFilters, arginfo_ice_validation_setfilters, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, setLabels, arginfo_ice_validation_setlabels, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, setAliases, arginfo_ice_validation_setaliases, ZEND_ACC_PUBLIC)
@@ -116,10 +125,11 @@ ZEPHIR_INIT_FUNCS(ice_validation_method_entry) {
PHP_ME(Ice_Validation, valid, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, hasValue, arginfo_ice_validation_hasvalue, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, getValue, arginfo_ice_validation_getvalue, ZEND_ACC_PUBLIC)
+ PHP_ME(Ice_Validation, getValues, arginfo_ice_validation_getvalues, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, getLabel, arginfo_ice_validation_getlabel, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, setDefaultMessages, arginfo_ice_validation_setdefaultmessages, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, getDefaultMessage, arginfo_ice_validation_getdefaultmessage, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, addMessage, arginfo_ice_validation_addmessage, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation, getMessages, NULL, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator.zep.c b/ext/ice/validation/validator.zep.c
index fab24384..0cf70db3 100644
--- a/ext/ice/validation/validator.zep.c
+++ b/ext/ice/validation/validator.zep.c
@@ -12,18 +12,29 @@
#include
#include "kernel/main.h"
-#include "kernel/memory.h"
#include "kernel/object.h"
+#include "kernel/memory.h"
#include "kernel/operators.h"
#include "kernel/array.h"
#include "kernel/hash.h"
+
+/**
+ * Validator is a base class for validators.
+ *
+ * @package Ice/Validation
+ * @category Security
+ * @author Ice Team
+ * @copyright (c) 2014-2015 Ice Team
+ * @license http://iceframework.org/license
+ */
ZEPHIR_INIT_CLASS(Ice_Validation_Validator) {
ZEPHIR_REGISTER_CLASS(Ice\\Validation, Validator, ice, validation_validator, ice_validation_validator_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
- zend_declare_property_null(ice_validation_validator_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ zend_declare_property_null(ice_validation_validator_ce, SL("options"), ZEND_ACC_PROTECTED TSRMLS_CC);
+ ice_validation_validator_ce->create_object = zephir_init_properties_Ice_Validation_Validator;
zend_declare_class_constant_long(ice_validation_validator_ce, SL("ALL"), 0 TSRMLS_CC);
zend_declare_class_constant_long(ice_validation_validator_ce, SL("NUMERIC"), 1 TSRMLS_CC);
@@ -41,7 +52,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator) {
*/
PHP_METHOD(Ice_Validation_Validator, __construct) {
- zval *options_param = NULL, *_0;
+ zval *options_param = NULL;
zval *options = NULL;
ZEPHIR_MM_GROW();
@@ -55,10 +66,7 @@ PHP_METHOD(Ice_Validation_Validator, __construct) {
}
- ZEPHIR_INIT_VAR(_0);
- array_init(_0);
- zephir_update_property_this(this_ptr, SL("_options"), _0 TSRMLS_CC);
- zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC);
+ zephir_update_property_this(this_ptr, SL("options"), options TSRMLS_CC);
ZEPHIR_MM_RESTORE();
}
@@ -87,7 +95,7 @@ PHP_METHOD(Ice_Validation_Validator, has) {
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC);
RETURN_BOOL(zephir_array_isset(_0, key));
}
@@ -101,7 +109,7 @@ PHP_METHOD(Ice_Validation_Validator, has) {
*/
PHP_METHOD(Ice_Validation_Validator, get) {
- zval *key, *defaultValue = NULL, *value, *_0;
+ zval *key, *defaultValue = NULL, *value = NULL, *_0;
zephir_fetch_params(0, 1, 1, &key, &defaultValue);
@@ -110,7 +118,7 @@ PHP_METHOD(Ice_Validation_Validator, get) {
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC);
if (zephir_array_isset_fetch(&value, _0, key, 1 TSRMLS_CC)) {
RETURN_CTORW(value);
}
@@ -134,7 +142,7 @@ PHP_METHOD(Ice_Validation_Validator, set) {
- zephir_update_property_array(this_ptr, SL("_options"), key, value TSRMLS_CC);
+ zephir_update_property_array(this_ptr, SL("options"), key, value TSRMLS_CC);
}
@@ -166,7 +174,7 @@ PHP_METHOD(Ice_Validation_Validator, getOptions) {
}
- _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC);
zephir_is_iterable(_0, &_2, &_1, 0, 0, "ice/validation/validator.zep", 111);
for (
; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
@@ -196,3 +204,24 @@ PHP_METHOD(Ice_Validation_Validator, getOptions) {
}
+static zend_object_value zephir_init_properties_Ice_Validation_Validator(zend_class_entry *class_type TSRMLS_DC) {
+
+ zval *_0, *_1;
+
+ ZEPHIR_MM_GROW();
+
+ {
+ zval *this_ptr = NULL;
+ ZEPHIR_CREATE_OBJECT(this_ptr, class_type);
+ _0 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC);
+ if (Z_TYPE_P(_0) == IS_NULL) {
+ ZEPHIR_INIT_VAR(_1);
+ array_init(_1);
+ zephir_update_property_this(this_ptr, SL("options"), _1 TSRMLS_CC);
+ }
+ ZEPHIR_MM_RESTORE();
+ return Z_OBJVAL_P(this_ptr);
+ }
+
+}
+
diff --git a/ext/ice/validation/validator.zep.h b/ext/ice/validation/validator.zep.h
index 0d0f2912..02458802 100644
--- a/ext/ice/validation/validator.zep.h
+++ b/ext/ice/validation/validator.zep.h
@@ -9,6 +9,7 @@ PHP_METHOD(Ice_Validation_Validator, has);
PHP_METHOD(Ice_Validation_Validator, get);
PHP_METHOD(Ice_Validation_Validator, set);
PHP_METHOD(Ice_Validation_Validator, getOptions);
+static zend_object_value zephir_init_properties_Ice_Validation_Validator(zend_class_entry *class_type TSRMLS_DC);
ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_validation_validator___construct, 0, 0, 0)
ZEND_ARG_ARRAY_INFO(0, options, 1)
@@ -45,5 +46,5 @@ ZEPHIR_INIT_FUNCS(ice_validation_validator_method_entry) {
PHP_ME(Ice_Validation_Validator, get, arginfo_ice_validation_validator_get, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation_Validator, set, arginfo_ice_validation_validator_set, ZEND_ACC_PUBLIC)
PHP_ME(Ice_Validation_Validator, getOptions, arginfo_ice_validation_validator_getoptions, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/alnum.zep.c b/ext/ice/validation/validator/alnum.zep.c
index 35e8fd0b..8b0b490b 100644
--- a/ext/ice/validation/validator/alnum.zep.c
+++ b/ext/ice/validation/validator/alnum.zep.c
@@ -28,6 +28,25 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => 'alnum',
+ * 'prefix' => [
+ * 'alnum' => [
+ * 'message' => 'Field :field must be alphanumeric'
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Alnum) {
@@ -46,11 +65,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Alnum) {
*/
PHP_METHOD(Ice_Validation_Validator_Alnum, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_11 = NULL;
zend_bool _0, _6;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -59,7 +77,6 @@ PHP_METHOD(Ice_Validation_Validator_Alnum, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -68,7 +85,7 @@ PHP_METHOD(Ice_Validation_Validator_Alnum, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -77,76 +94,76 @@ PHP_METHOD(Ice_Validation_Validator_Alnum, validate) {
if (_0) {
RETURN_MM_BOOL(1);
}
- ZEPHIR_CALL_FUNCTION(&_1, "ctype_alnum", NULL, value);
+ ZEPHIR_CALL_FUNCTION(&_1, "ctype_alnum", NULL, 163, value);
zephir_check_call_status();
if (!(zephir_is_true(_1))) {
ZEPHIR_INIT_VAR(_3);
ZVAL_STRING(_3, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_2)) {
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_4)) {
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "alnum", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _3);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_5, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_5, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_6 = ZEPHIR_IS_TRUE_IDENTICAL(_5);
if (_6) {
- ZEPHIR_CALL_METHOD(&_7, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_7, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, _7, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_8, _7, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
_6 = zephir_is_true(_8);
}
if (_6) {
- ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _9, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&i18n, _9, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _10);
- ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _10);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_9, "strtr", &_11, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_9, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _9);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _9);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/alnum.zep.h b/ext/ice/validation/validator/alnum.zep.h
index 1007d323..c5df2e65 100644
--- a/ext/ice/validation/validator/alnum.zep.h
+++ b/ext/ice/validation/validator/alnum.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_alnum_method_entry) {
PHP_ME(Ice_Validation_Validator_Alnum, validate, arginfo_ice_validation_validator_alnum_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/alpha.zep.c b/ext/ice/validation/validator/alpha.zep.c
index de3fa849..ed8dc072 100644
--- a/ext/ice/validation/validator/alpha.zep.c
+++ b/ext/ice/validation/validator/alpha.zep.c
@@ -28,6 +28,25 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => 'alpha',
+ * 'prefix' => [
+ * 'alpha' => [
+ * 'message' => 'Field :field must be alpha'
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Alpha) {
@@ -46,11 +65,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Alpha) {
*/
PHP_METHOD(Ice_Validation_Validator_Alpha, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_11 = NULL;
zend_bool _0, _6;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -59,7 +77,6 @@ PHP_METHOD(Ice_Validation_Validator_Alpha, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -68,7 +85,7 @@ PHP_METHOD(Ice_Validation_Validator_Alpha, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -77,76 +94,76 @@ PHP_METHOD(Ice_Validation_Validator_Alpha, validate) {
if (_0) {
RETURN_MM_BOOL(1);
}
- ZEPHIR_CALL_FUNCTION(&_1, "ctype_alpha", NULL, value);
+ ZEPHIR_CALL_FUNCTION(&_1, "ctype_alpha", NULL, 164, value);
zephir_check_call_status();
if (!(zephir_is_true(_1))) {
ZEPHIR_INIT_VAR(_3);
ZVAL_STRING(_3, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_2)) {
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_4)) {
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "alpha", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _3);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_5, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_5, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_6 = ZEPHIR_IS_TRUE_IDENTICAL(_5);
if (_6) {
- ZEPHIR_CALL_METHOD(&_7, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_7, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, _7, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_8, _7, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
_6 = zephir_is_true(_8);
}
if (_6) {
- ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _9, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&i18n, _9, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _10);
- ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _10);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_9, "strtr", &_11, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_9, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _9);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _9);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/alpha.zep.h b/ext/ice/validation/validator/alpha.zep.h
index 22171570..bd5ff9ae 100644
--- a/ext/ice/validation/validator/alpha.zep.h
+++ b/ext/ice/validation/validator/alpha.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_alpha_method_entry) {
PHP_ME(Ice_Validation_Validator_Alpha, validate, arginfo_ice_validation_validator_alpha_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/between.zep.c b/ext/ice/validation/validator/between.zep.c
index fd643785..66d401fc 100644
--- a/ext/ice/validation/validator/between.zep.c
+++ b/ext/ice/validation/validator/between.zep.c
@@ -28,6 +28,26 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'age' => 'between:18,21',
+ * 'height' => [
+ * 'between' => [
+ * 'min' => 180,
+ * 'max' => 190,
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Between) {
@@ -39,6 +59,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Between) {
/**
* Validate the validator
+ * Options: label, min, max, message
*
* @param Validation validation
* @param string field
@@ -46,11 +67,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Between) {
*/
PHP_METHOD(Ice_Validation_Validator_Between, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_13 = NULL;
zend_bool _0, _4, _8;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *min = NULL, *max = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *min = NULL, *max = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -59,7 +79,6 @@ PHP_METHOD(Ice_Validation_Validator_Between, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -68,7 +87,7 @@ PHP_METHOD(Ice_Validation_Validator_Between, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -79,33 +98,33 @@ PHP_METHOD(Ice_Validation_Validator_Between, validate) {
}
ZEPHIR_INIT_VAR(_2);
ZVAL_LONG(_2, 0);
- ZEPHIR_CALL_METHOD(&_1, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_1, this_ptr, "has", NULL, 0, _2);
zephir_check_call_status();
if (zephir_is_true(_1)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_LONG(_2, 0);
- ZEPHIR_CALL_METHOD(&min, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&min, this_ptr, "get", NULL, 0, _2);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "min", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&min, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&min, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_2);
ZVAL_LONG(_2, 1);
- ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, 0, _2);
zephir_check_call_status();
if (zephir_is_true(_3)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_LONG(_2, 1);
- ZEPHIR_CALL_METHOD(&max, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&max, this_ptr, "get", NULL, 0, _2);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "max", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&max, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&max, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
@@ -116,73 +135,73 @@ PHP_METHOD(Ice_Validation_Validator_Between, validate) {
if (_4) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
if (zephir_is_true(_5)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
if (zephir_is_true(_6)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "between", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _2);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_7, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_7, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_8 = ZEPHIR_IS_TRUE_IDENTICAL(_7);
if (_8) {
- ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, _9, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_10, _9, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
_8 = zephir_is_true(_10);
}
if (_8) {
- ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _11, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&i18n, _11, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _12);
- ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _12);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 4);
+ zephir_create_array(replace, 3, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
zephir_array_update_string(&replace, SL(":min"), &min, PH_COPY | PH_SEPARATE);
zephir_array_update_string(&replace, SL(":max"), &max, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_11, "strtr", &_13, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_11, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _11);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _11);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/between.zep.h b/ext/ice/validation/validator/between.zep.h
index 90de2d3a..ab16f3a4 100644
--- a/ext/ice/validation/validator/between.zep.h
+++ b/ext/ice/validation/validator/between.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_between_method_entry) {
PHP_ME(Ice_Validation_Validator_Between, validate, arginfo_ice_validation_validator_between_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/digit.zep.c b/ext/ice/validation/validator/digit.zep.c
index 43c0ad4b..fcc261c3 100644
--- a/ext/ice/validation/validator/digit.zep.c
+++ b/ext/ice/validation/validator/digit.zep.c
@@ -28,6 +28,20 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'sort' => 'digit'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Digit) {
@@ -46,11 +60,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Digit) {
*/
PHP_METHOD(Ice_Validation_Validator_Digit, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_11 = NULL;
zend_bool _0, _6;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -59,7 +72,6 @@ PHP_METHOD(Ice_Validation_Validator_Digit, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -68,7 +80,7 @@ PHP_METHOD(Ice_Validation_Validator_Digit, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -77,76 +89,76 @@ PHP_METHOD(Ice_Validation_Validator_Digit, validate) {
if (_0) {
RETURN_MM_BOOL(1);
}
- ZEPHIR_CALL_FUNCTION(&_1, "ctype_digit", NULL, value);
+ ZEPHIR_CALL_FUNCTION(&_1, "ctype_digit", NULL, 5, value);
zephir_check_call_status();
if (!(zephir_is_true(_1))) {
ZEPHIR_INIT_VAR(_3);
ZVAL_STRING(_3, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_2)) {
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
if (zephir_is_true(_4)) {
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "digit", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _3);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_5, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_5, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_6 = ZEPHIR_IS_TRUE_IDENTICAL(_5);
if (_6) {
- ZEPHIR_CALL_METHOD(&_7, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_7, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, _7, "has", NULL, _3);
+ ZEPHIR_CALL_METHOD(&_8, _7, "has", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
_6 = zephir_is_true(_8);
}
if (_6) {
- ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_3);
ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _9, "get", NULL, _3);
+ ZEPHIR_CALL_METHOD(&i18n, _9, "get", NULL, 0, _3);
zephir_check_temp_parameter(_3);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _10);
- ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_10, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _10);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_9, "strtr", &_11, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_9, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _9);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _9);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/digit.zep.h b/ext/ice/validation/validator/digit.zep.h
index 96f0cc29..d410bc99 100644
--- a/ext/ice/validation/validator/digit.zep.h
+++ b/ext/ice/validation/validator/digit.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_digit_method_entry) {
PHP_ME(Ice_Validation_Validator_Digit, validate, arginfo_ice_validation_validator_digit_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/email.zep.c b/ext/ice/validation/validator/email.zep.c
index 00904dfc..5451fe36 100644
--- a/ext/ice/validation/validator/email.zep.c
+++ b/ext/ice/validation/validator/email.zep.c
@@ -28,6 +28,20 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'e_mail' => 'email'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Email) {
@@ -46,11 +60,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Email) {
*/
PHP_METHOD(Ice_Validation_Validator_Email, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_12 = NULL;
zend_bool _0, _7;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, _1, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, _1, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -59,7 +72,6 @@ PHP_METHOD(Ice_Validation_Validator_Email, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -68,7 +80,7 @@ PHP_METHOD(Ice_Validation_Validator_Email, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -79,76 +91,76 @@ PHP_METHOD(Ice_Validation_Validator_Email, validate) {
}
ZEPHIR_SINIT_VAR(_1);
ZVAL_LONG(&_1, 274);
- ZEPHIR_CALL_FUNCTION(&_2, "filter_var", NULL, value, &_1);
+ ZEPHIR_CALL_FUNCTION(&_2, "filter_var", NULL, 104, value, &_1);
zephir_check_call_status();
if (!(zephir_is_true(_2))) {
ZEPHIR_INIT_VAR(_4);
ZVAL_STRING(_4, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
if (zephir_is_true(_3)) {
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _4);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
if (zephir_is_true(_5)) {
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _4);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "email", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _4);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_6, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_6, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_7 = ZEPHIR_IS_TRUE_IDENTICAL(_6);
if (_7) {
- ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_9, _8, "has", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_9, _8, "has", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
_7 = zephir_is_true(_9);
}
if (_7) {
- ZEPHIR_CALL_METHOD(&_10, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_10, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _10, "get", NULL, _4);
+ ZEPHIR_CALL_METHOD(&i18n, _10, "get", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_11, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_11, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _11);
- ZEPHIR_CALL_METHOD(&_11, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_11, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _11);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_10, "strtr", &_12, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_10, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _10);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _10);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/email.zep.h b/ext/ice/validation/validator/email.zep.h
index 9c8424b0..2bff7095 100644
--- a/ext/ice/validation/validator/email.zep.h
+++ b/ext/ice/validation/validator/email.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_email_method_entry) {
PHP_ME(Ice_Validation_Validator_Email, validate, arginfo_ice_validation_validator_email_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/file.zep.c b/ext/ice/validation/validator/file.zep.c
index 82e3e3c1..d3ba1da4 100644
--- a/ext/ice/validation/validator/file.zep.c
+++ b/ext/ice/validation/validator/file.zep.c
@@ -16,8 +16,8 @@
#include "kernel/memory.h"
#include "kernel/operators.h"
#include "kernel/array.h"
-#include "kernel/concat.h"
#include "kernel/string.h"
+#include "kernel/concat.h"
#include "kernel/exception.h"
#include "kernel/object.h"
#include "ext/spl/spl_exceptions.h"
@@ -31,6 +31,27 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'picture' => [
+ * 'file' => [
+ * 'maxSize' => '6M',
+ * 'allowedTypes' => ['image/jpeg', 'image/png'],
+ * 'minResolution' => '400x300,
+ * 'maxResolution' => '1600x1200',
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_FILES);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_File) {
@@ -42,6 +63,8 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_File) {
/**
* Validate the validator
+ * Options: label, messageIniSize, allowEmpty, messageEmpty, messageValid, maxSize, messageSize, allowedTypes, messageType
+ * minResolution, maxResolution, messageMinResolution, messageMaxResolution
*
* @param Validation validation
* @param string field
@@ -49,20 +72,22 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_File) {
*/
PHP_METHOD(Ice_Validation_Validator_File, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_17 = NULL, *_25 = NULL, *_31 = NULL, *_33 = NULL, *_40 = NULL;
- zend_bool _3, _4, _5, _7, _8, _12, _18, _19, _21, _23, _26, _28, _42, _43;
+ zephir_fcall_cache_entry *_17 = NULL, *_32 = NULL;
+ zend_bool _3, _4, _5, _7, _8, _12, _18, _19, _21, _23, _25, _27, _40, _41;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *i18n = NULL, *replace = NULL, *types = NULL, *byteUnits, *unit = NULL, *maxSize = NULL, *matches, *bytes, *mime = NULL, *tmp = NULL, *width, *height, *minResolution, *maxResolution, *minWidth = NULL, *maxWidth, *minHeight = NULL, *maxHeight, *_0 = NULL, *_1 = NULL, *_SERVER, *_2, *_POST, *_FILES, *_6, *_9, *_10 = NULL, *_11 = NULL, *_13 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL, *_20, *_22, *_24, *_27 = NULL, *_29 = NULL, *_30, *_32, *_34 = NULL, *_35, _36 = zval_used_for_init, *_37, *_38 = NULL, *_39 = NULL, *_41 = NULL, *_44 = NULL, *_45 = NULL, *_46 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *message = NULL, *label = NULL, *i18n = NULL, *replace = NULL, *types = NULL, *byteUnits = NULL, *unit = NULL, *maxSize = NULL, *matches = NULL, *bytes = NULL, *mime = NULL, *tmp = NULL, *width = NULL, *height = NULL, *minResolution = NULL, *maxResolution = NULL, *minWidth = NULL, *maxWidth = NULL, *minHeight = NULL, *maxHeight = NULL, *_0 = NULL, *_1 = NULL, *_SERVER, *_2, *_POST, *_FILES, *_6, *_9, *_10 = NULL, *_11 = NULL, *_13 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL, *_20, *_22, *_24, *_26 = NULL, *_28 = NULL, *_29, *_30, *_31, *_33 = NULL, *_34, _35 = zval_used_for_init, *_36, *_37 = NULL, *_38 = NULL, *_39 = NULL, *_42 = NULL, *_43 = NULL, *_44 = NULL;
ZEPHIR_MM_GROW();
+ zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC);
+ zephir_get_global(&_POST, SS("_POST") TSRMLS_CC);
+ zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC);
zephir_fetch_params(1, 2, 0, &validation, &field_param);
if (unlikely(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -71,45 +96,42 @@ PHP_METHOD(Ice_Validation_Validator_File, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
ZEPHIR_INIT_VAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_0)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
- zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC);
- zephir_array_fetch_string(&_2, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 40 TSRMLS_CC);
+ zephir_array_fetch_string(&_2, _SERVER, SL("REQUEST_METHOD"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 63 TSRMLS_CC);
_3 = ZEPHIR_IS_STRING(_2, "POST");
if (_3) {
- zephir_get_global(&_POST, SS("_POST") TSRMLS_CC);
_3 = ZEPHIR_IS_EMPTY(_POST);
}
_4 = _3;
if (_4) {
- zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC);
_4 = ZEPHIR_IS_EMPTY(_FILES);
}
_5 = _4;
if (_5) {
- zephir_array_fetch_string(&_6, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 40 TSRMLS_CC);
+ zephir_array_fetch_string(&_6, _SERVER, SL("CONTENT_LENGTH"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 63 TSRMLS_CC);
_5 = ZEPHIR_GT_LONG(_6, 0);
}
_7 = _5;
if (!(_7)) {
_8 = zephir_array_isset_string(value, SS("error"));
if (_8) {
- zephir_array_fetch_string(&_9, value, SL("error"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 40 TSRMLS_CC);
+ zephir_array_fetch_string(&_9, value, SL("error"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 63 TSRMLS_CC);
_8 = ZEPHIR_IS_LONG_IDENTICAL(_9, 1);
}
_7 = _8;
@@ -117,62 +139,62 @@ PHP_METHOD(Ice_Validation_Validator_File, validate) {
if (_7) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_10)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "messageIniSize", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "fileIniSize", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_11, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_11, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_12 = ZEPHIR_IS_TRUE_IDENTICAL(_11);
if (_12) {
- ZEPHIR_CALL_METHOD(&_13, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_13, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_14, _13, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_14, _13, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
_12 = zephir_is_true(_14);
}
if (_12) {
- ZEPHIR_CALL_METHOD(&_15, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_15, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _15, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&i18n, _15, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_16, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_16, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _16);
- ZEPHIR_CALL_METHOD(&_16, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_16, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _16);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_15, "strtr", &_17, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_15, "strtr", &_17, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _15);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _15);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
_12 = zephir_is_true(_10);
@@ -181,7 +203,7 @@ PHP_METHOD(Ice_Validation_Validator_File, validate) {
if (!(_18)) {
_19 = zephir_array_isset_string(value, SS("error"));
if (_19) {
- zephir_array_fetch_string(&_20, value, SL("error"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 60 TSRMLS_CC);
+ zephir_array_fetch_string(&_20, value, SL("error"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 83 TSRMLS_CC);
_19 = ZEPHIR_IS_LONG_IDENTICAL(_20, 4);
}
_18 = _19;
@@ -197,69 +219,69 @@ PHP_METHOD(Ice_Validation_Validator_File, validate) {
}
_21 = _12;
if (!(_21)) {
- zephir_array_fetch_string(&_22, value, SL("error"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 64 TSRMLS_CC);
+ zephir_array_fetch_string(&_22, value, SL("error"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 87 TSRMLS_CC);
_21 = !ZEPHIR_IS_LONG_IDENTICAL(_22, 0);
}
_23 = _21;
if (!(_23)) {
- zephir_array_fetch_string(&_24, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 64 TSRMLS_CC);
- ZEPHIR_CALL_FUNCTION(&_10, "is_uploaded_file", &_25, _24);
+ zephir_array_fetch_string(&_24, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 87 TSRMLS_CC);
+ ZEPHIR_CALL_FUNCTION(&_10, "is_uploaded_file", NULL, 165, _24);
zephir_check_call_status();
_23 = !zephir_is_true(_10);
}
if (_23) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_11, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_11, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_11)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "messageEmpty", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "fileEmpty", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_13, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_13, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
- _26 = ZEPHIR_IS_TRUE_IDENTICAL(_13);
- if (_26) {
- ZEPHIR_CALL_METHOD(&_14, validation, "getdi", NULL);
+ _25 = ZEPHIR_IS_TRUE_IDENTICAL(_13);
+ if (_25) {
+ ZEPHIR_CALL_METHOD(&_14, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_15, _14, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_15, _14, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- _26 = zephir_is_true(_15);
+ _25 = zephir_is_true(_15);
}
- if (_26) {
- ZEPHIR_CALL_METHOD(&_16, validation, "getdi", NULL);
+ if (_25) {
+ ZEPHIR_CALL_METHOD(&_16, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _16, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&i18n, _16, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_27, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_26, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(label, _27);
- ZEPHIR_CALL_METHOD(&_27, i18n, "translate", NULL, message);
+ ZEPHIR_CPY_WRT(label, _26);
+ ZEPHIR_CALL_METHOD(&_26, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(message, _27);
+ ZEPHIR_CPY_WRT(message, _26);
}
ZEPHIR_INIT_NVAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_15, "strtr", &_17, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_15, "strtr", &_17, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _15);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _15);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
@@ -267,74 +289,74 @@ PHP_METHOD(Ice_Validation_Validator_File, validate) {
if (!(_12)) {
_12 = !(zephir_array_isset_string(value, SS("type")));
}
- _26 = _12;
- if (!(_26)) {
- _26 = !(zephir_array_isset_string(value, SS("size")));
+ _25 = _12;
+ if (!(_25)) {
+ _25 = !(zephir_array_isset_string(value, SS("size")));
}
- if (_26) {
+ if (_25) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "messageValid", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_10)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "messageValid", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "default", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_11, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_11, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
- _28 = ZEPHIR_IS_TRUE_IDENTICAL(_11);
- if (_28) {
- ZEPHIR_CALL_METHOD(&_13, validation, "getdi", NULL);
+ _27 = ZEPHIR_IS_TRUE_IDENTICAL(_11);
+ if (_27) {
+ ZEPHIR_CALL_METHOD(&_13, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_14, _13, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_14, _13, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- _28 = zephir_is_true(_14);
+ _27 = zephir_is_true(_14);
}
- if (_28) {
- ZEPHIR_CALL_METHOD(&_15, validation, "getdi", NULL);
+ if (_27) {
+ ZEPHIR_CALL_METHOD(&_15, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _15, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&i18n, _15, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_16, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_16, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _16);
- ZEPHIR_CALL_METHOD(&_16, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_16, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _16);
}
ZEPHIR_INIT_NVAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_15, "strtr", &_17, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_15, "strtr", &_17, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _15);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _15);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "maxSize", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_10)) {
ZEPHIR_INIT_VAR(byteUnits);
- array_init_size(byteUnits, 12);
+ zephir_create_array(byteUnits, 9, 0 TSRMLS_CC);
add_assoc_long_ex(byteUnits, SS("B"), 0);
add_assoc_long_ex(byteUnits, SS("K"), 10);
add_assoc_long_ex(byteUnits, SS("M"), 20);
@@ -346,7 +368,7 @@ PHP_METHOD(Ice_Validation_Validator_File, validate) {
add_assoc_long_ex(byteUnits, SS("TB"), 40);
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "maxSize", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&maxSize, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
ZEPHIR_INIT_VAR(matches);
@@ -354,372 +376,370 @@ PHP_METHOD(Ice_Validation_Validator_File, validate) {
ZEPHIR_INIT_VAR(unit);
ZVAL_STRING(unit, "B", 1);
ZEPHIR_INIT_NVAR(_1);
+ ZEPHIR_INIT_VAR(_28);
ZEPHIR_INIT_VAR(_29);
zephir_array_keys(_29, byteUnits TSRMLS_CC);
- zephir_fast_join_str(_1, SL("|"), _29 TSRMLS_CC);
+ zephir_fast_join_str(_28, SL("|"), _29 TSRMLS_CC);
ZEPHIR_INIT_VAR(_30);
- ZEPHIR_CONCAT_SVS(_30, "/^([0-9]+(?:\\.[0-9]+)?)(", _1, ")?$/Di");
- Z_SET_ISREF_P(matches);
- ZEPHIR_CALL_FUNCTION(NULL, "preg_match", &_31, _30, maxSize, matches);
- Z_UNSET_ISREF_P(matches);
- zephir_check_call_status();
+ ZEPHIR_CONCAT_SVS(_30, "/^([0-9]+(?:\\.[0-9]+)?)(", _28, ")?$/Di");
+ zephir_preg_match(_1, _30, maxSize, matches, 0, 0 , 0 TSRMLS_CC);
if (zephir_array_isset_long(matches, 2)) {
ZEPHIR_OBS_NVAR(unit);
- zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "ice/validation/validator/file.zep", 113 TSRMLS_CC);
+ zephir_array_fetch_long(&unit, matches, 2, PH_NOISY, "ice/validation/validator/file.zep", 136 TSRMLS_CC);
}
- zephir_array_fetch_long(&_32, matches, 1, PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 116 TSRMLS_CC);
- ZEPHIR_CALL_FUNCTION(&_11, "floatval", &_33, _32);
+ zephir_array_fetch_long(&_31, matches, 1, PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 139 TSRMLS_CC);
+ ZEPHIR_CALL_FUNCTION(&_11, "floatval", &_32, 166, _31);
zephir_check_call_status();
- ZEPHIR_INIT_VAR(_34);
- zephir_array_fetch(&_35, byteUnits, unit, PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 116 TSRMLS_CC);
- ZEPHIR_SINIT_VAR(_36);
- ZVAL_LONG(&_36, 2);
- zephir_pow_function(_34, &_36, _35);
+ ZEPHIR_INIT_VAR(_33);
+ zephir_array_fetch(&_34, byteUnits, unit, PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 139 TSRMLS_CC);
+ ZEPHIR_SINIT_VAR(_35);
+ ZVAL_LONG(&_35, 2);
+ zephir_pow_function(_33, &_35, _34);
ZEPHIR_INIT_VAR(bytes);
- mul_function(bytes, _11, _34 TSRMLS_CC);
- zephir_array_fetch_string(&_37, value, SL("size"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 118 TSRMLS_CC);
- ZEPHIR_CALL_FUNCTION(&_11, "floatval", &_33, _37);
+ mul_function(bytes, _11, _33 TSRMLS_CC);
+ zephir_array_fetch_string(&_36, value, SL("size"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 141 TSRMLS_CC);
+ ZEPHIR_CALL_FUNCTION(&_11, "floatval", &_32, 166, _36);
zephir_check_call_status();
- ZEPHIR_CALL_FUNCTION(&_13, "floatval", &_33, bytes);
+ ZEPHIR_CALL_FUNCTION(&_13, "floatval", &_32, 166, bytes);
zephir_check_call_status();
if (ZEPHIR_GT(_11, _13)) {
- ZEPHIR_INIT_NVAR(_34);
- ZVAL_STRING(_34, "messageSize", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_14, this_ptr, "has", NULL, _34);
- zephir_check_temp_parameter(_34);
+ ZEPHIR_INIT_NVAR(_33);
+ ZVAL_STRING(_33, "messageSize", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_14, this_ptr, "has", NULL, 0, _33);
+ zephir_check_temp_parameter(_33);
zephir_check_call_status();
if (zephir_is_true(_14)) {
- ZEPHIR_INIT_NVAR(_34);
- ZVAL_STRING(_34, "messageSize", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _34);
- zephir_check_temp_parameter(_34);
+ ZEPHIR_INIT_NVAR(_33);
+ ZVAL_STRING(_33, "messageSize", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _33);
+ zephir_check_temp_parameter(_33);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_34);
- ZVAL_STRING(_34, "fileSize", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _34);
- zephir_check_temp_parameter(_34);
+ ZEPHIR_INIT_NVAR(_33);
+ ZVAL_STRING(_33, "fileSize", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _33);
+ zephir_check_temp_parameter(_33);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_15, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_15, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_12 = ZEPHIR_IS_TRUE_IDENTICAL(_15);
if (_12) {
- ZEPHIR_CALL_METHOD(&_16, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_16, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_34);
- ZVAL_STRING(_34, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_27, _16, "has", NULL, _34);
- zephir_check_temp_parameter(_34);
+ ZEPHIR_INIT_NVAR(_33);
+ ZVAL_STRING(_33, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_26, _16, "has", NULL, 0, _33);
+ zephir_check_temp_parameter(_33);
zephir_check_call_status();
- _12 = zephir_is_true(_27);
+ _12 = zephir_is_true(_26);
}
if (_12) {
- ZEPHIR_CALL_METHOD(&_38, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_37, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_34);
- ZVAL_STRING(_34, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _38, "get", NULL, _34);
- zephir_check_temp_parameter(_34);
+ ZEPHIR_INIT_NVAR(_33);
+ ZVAL_STRING(_33, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&i18n, _37, "get", NULL, 0, _33);
+ zephir_check_temp_parameter(_33);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_39, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_38, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(label, _39);
- ZEPHIR_CALL_METHOD(&_39, i18n, "translate", NULL, message);
+ ZEPHIR_CPY_WRT(label, _38);
+ ZEPHIR_CALL_METHOD(&_38, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(message, _39);
+ ZEPHIR_CPY_WRT(message, _38);
}
ZEPHIR_INIT_NVAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
zephir_array_update_string(&replace, SL(":max"), &maxSize, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_38, "strtr", &_17, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_37, "strtr", &_17, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _38);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _37);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
}
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
if (zephir_is_true(_10)) {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&types, this_ptr, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "allowedTypes", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&types, this_ptr, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
if (Z_TYPE_P(types) != IS_ARRAY) {
- ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Option 'allowedTypes' must be an array", "ice/validation/validator/file.zep", 143);
+ ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Option 'allowedTypes' must be an array", "ice/validation/validator/file.zep", 166);
return;
}
if ((zephir_function_exists_ex(SS("finfo_open") TSRMLS_CC) == SUCCESS)) {
- ZEPHIR_SINIT_NVAR(_36);
- ZVAL_LONG(&_36, 16);
- ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, &_36);
+ ZEPHIR_SINIT_NVAR(_35);
+ ZVAL_LONG(&_35, 16);
+ ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 167, &_35);
zephir_check_call_status();
- zephir_array_fetch_string(&_32, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 148 TSRMLS_CC);
- ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, tmp, _32);
+ zephir_array_fetch_string(&_31, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 171 TSRMLS_CC);
+ ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 168, tmp, _31);
zephir_check_call_status();
- ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, tmp);
+ ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 169, tmp);
zephir_check_call_status();
} else {
ZEPHIR_OBS_NVAR(mime);
- zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "ice/validation/validator/file.zep", 152 TSRMLS_CC);
+ zephir_array_fetch_string(&mime, value, SL("type"), PH_NOISY, "ice/validation/validator/file.zep", 175 TSRMLS_CC);
}
if (!(zephir_fast_in_array(mime, types TSRMLS_CC))) {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "messageType", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_11, this_ptr, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "messageType", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_11, this_ptr, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
if (zephir_is_true(_11)) {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "messageType", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "messageType", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "fileType", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "fileType", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_13, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_13, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_12 = ZEPHIR_IS_TRUE_IDENTICAL(_13);
if (_12) {
- ZEPHIR_CALL_METHOD(&_14, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_14, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_15, _14, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_15, _14, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
_12 = zephir_is_true(_15);
}
if (_12) {
- ZEPHIR_CALL_METHOD(&_16, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_16, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _16, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&i18n, _16, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_27, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_26, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(label, _27);
- ZEPHIR_CALL_METHOD(&_27, i18n, "translate", NULL, message);
+ ZEPHIR_CPY_WRT(label, _26);
+ ZEPHIR_CALL_METHOD(&_26, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(message, _27);
+ ZEPHIR_CPY_WRT(message, _26);
}
ZEPHIR_INIT_NVAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_NVAR(_29);
- zephir_fast_join_str(_29, SL(", "), types TSRMLS_CC);
- zephir_array_update_string(&replace, SL(":types"), &_29, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_27, "strtr", &_17, message, replace);
+ ZEPHIR_INIT_NVAR(_28);
+ zephir_fast_join_str(_28, SL(", "), types TSRMLS_CC);
+ zephir_array_update_string(&replace, SL(":types"), &_28, PH_COPY | PH_SEPARATE);
+ ZEPHIR_CALL_FUNCTION(&_26, "strtr", &_17, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _27);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _26);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
}
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_10, this_ptr, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
_12 = zephir_is_true(_10);
if (!(_12)) {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_11, this_ptr, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_11, this_ptr, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
_12 = zephir_is_true(_11);
}
if (_12) {
- zephir_array_fetch_string(&_32, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 177 TSRMLS_CC);
- ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", &_40, _32);
+ zephir_array_fetch_string(&_31, value, SL("tmp_name"), PH_NOISY | PH_READONLY, "ice/validation/validator/file.zep", 200 TSRMLS_CC);
+ ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 170, _31);
zephir_check_call_status();
ZEPHIR_OBS_VAR(width);
- zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "ice/validation/validator/file.zep", 178 TSRMLS_CC);
+ zephir_array_fetch_long(&width, tmp, 0, PH_NOISY, "ice/validation/validator/file.zep", 201 TSRMLS_CC);
ZEPHIR_OBS_VAR(height);
- zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "ice/validation/validator/file.zep", 179 TSRMLS_CC);
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_13, this_ptr, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ zephir_array_fetch_long(&height, tmp, 1, PH_NOISY, "ice/validation/validator/file.zep", 202 TSRMLS_CC);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_13, this_ptr, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
if (zephir_is_true(_13)) {
- ZEPHIR_INIT_VAR(minResolution);
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_14, this_ptr, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_14, this_ptr, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
+ ZEPHIR_INIT_VAR(minResolution);
zephir_fast_explode_str(minResolution, SL("x"), _14, LONG_MAX TSRMLS_CC);
ZEPHIR_OBS_VAR(minWidth);
- zephir_array_fetch_long(&minWidth, minResolution, 0, PH_NOISY, "ice/validation/validator/file.zep", 183 TSRMLS_CC);
+ zephir_array_fetch_long(&minWidth, minResolution, 0, PH_NOISY, "ice/validation/validator/file.zep", 206 TSRMLS_CC);
ZEPHIR_OBS_VAR(minHeight);
- zephir_array_fetch_long(&minHeight, minResolution, 1, PH_NOISY, "ice/validation/validator/file.zep", 184 TSRMLS_CC);
+ zephir_array_fetch_long(&minHeight, minResolution, 1, PH_NOISY, "ice/validation/validator/file.zep", 207 TSRMLS_CC);
} else {
ZEPHIR_INIT_NVAR(minWidth);
ZVAL_LONG(minWidth, 1);
ZEPHIR_INIT_NVAR(minHeight);
ZVAL_LONG(minHeight, 1);
}
- _26 = ZEPHIR_LT(width, minWidth);
- if (!(_26)) {
- _26 = ZEPHIR_LT(height, minHeight);
+ _25 = ZEPHIR_LT(width, minWidth);
+ if (!(_25)) {
+ _25 = ZEPHIR_LT(height, minHeight);
}
- if (_26) {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_15, this_ptr, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ if (_25) {
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_15, this_ptr, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
if (zephir_is_true(_15)) {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "messageMinResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "fileMinResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "fileMinResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_16, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_16, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
- _28 = ZEPHIR_IS_TRUE_IDENTICAL(_16);
- if (_28) {
- ZEPHIR_CALL_METHOD(&_27, validation, "getdi", NULL);
+ _27 = ZEPHIR_IS_TRUE_IDENTICAL(_16);
+ if (_27) {
+ ZEPHIR_CALL_METHOD(&_26, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_38, _27, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_37, _26, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
- _28 = zephir_is_true(_38);
+ _27 = zephir_is_true(_37);
}
- if (_28) {
- ZEPHIR_CALL_METHOD(&_39, validation, "getdi", NULL);
+ if (_27) {
+ ZEPHIR_CALL_METHOD(&_38, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _39, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&i18n, _38, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_41, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_39, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(label, _41);
- ZEPHIR_CALL_METHOD(&_41, i18n, "translate", NULL, message);
+ ZEPHIR_CPY_WRT(label, _39);
+ ZEPHIR_CALL_METHOD(&_39, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(message, _41);
+ ZEPHIR_CPY_WRT(message, _39);
}
ZEPHIR_INIT_NVAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_38, this_ptr, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "minResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_37, this_ptr, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
- zephir_array_update_string(&replace, SL(":min"), &_38, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_38, "strtr", &_17, message, replace);
+ zephir_array_update_string(&replace, SL(":min"), &_37, PH_COPY | PH_SEPARATE);
+ ZEPHIR_CALL_FUNCTION(&_37, "strtr", &_17, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _38);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _37);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_15, this_ptr, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_15, this_ptr, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
if (zephir_is_true(_15)) {
- ZEPHIR_INIT_VAR(maxResolution);
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_16, this_ptr, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_16, this_ptr, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
+ ZEPHIR_INIT_VAR(maxResolution);
zephir_fast_explode_str(maxResolution, SL("x"), _16, LONG_MAX TSRMLS_CC);
ZEPHIR_OBS_VAR(maxWidth);
- zephir_array_fetch_long(&maxWidth, maxResolution, 0, PH_NOISY, "ice/validation/validator/file.zep", 213 TSRMLS_CC);
+ zephir_array_fetch_long(&maxWidth, maxResolution, 0, PH_NOISY, "ice/validation/validator/file.zep", 236 TSRMLS_CC);
ZEPHIR_OBS_VAR(maxHeight);
- zephir_array_fetch_long(&maxHeight, maxResolution, 1, PH_NOISY, "ice/validation/validator/file.zep", 214 TSRMLS_CC);
- _42 = ZEPHIR_GT(width, maxWidth);
- if (!(_42)) {
- _42 = ZEPHIR_GT(height, maxHeight);
+ zephir_array_fetch_long(&maxHeight, maxResolution, 1, PH_NOISY, "ice/validation/validator/file.zep", 237 TSRMLS_CC);
+ _40 = ZEPHIR_GT(width, maxWidth);
+ if (!(_40)) {
+ _40 = ZEPHIR_GT(height, maxHeight);
}
- if (_42) {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_27, this_ptr, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ if (_40) {
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_26, this_ptr, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
- if (zephir_is_true(_27)) {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ if (zephir_is_true(_26)) {
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "messageMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "fileMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "fileMaxResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_39, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_38, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
- _43 = ZEPHIR_IS_TRUE_IDENTICAL(_39);
- if (_43) {
- ZEPHIR_CALL_METHOD(&_41, validation, "getdi", NULL);
+ _41 = ZEPHIR_IS_TRUE_IDENTICAL(_38);
+ if (_41) {
+ ZEPHIR_CALL_METHOD(&_39, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_44, _41, "has", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_42, _39, "has", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
- _43 = zephir_is_true(_44);
+ _41 = zephir_is_true(_42);
}
- if (_43) {
- ZEPHIR_CALL_METHOD(&_45, validation, "getdi", NULL);
+ if (_41) {
+ ZEPHIR_CALL_METHOD(&_43, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _45, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&i18n, _43, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_46, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_44, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(label, _46);
- ZEPHIR_CALL_METHOD(&_46, i18n, "translate", NULL, message);
+ ZEPHIR_CPY_WRT(label, _44);
+ ZEPHIR_CALL_METHOD(&_44, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(message, _46);
+ ZEPHIR_CPY_WRT(message, _44);
}
ZEPHIR_INIT_NVAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_NVAR(_29);
- ZVAL_STRING(_29, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_45, this_ptr, "get", NULL, _29);
- zephir_check_temp_parameter(_29);
+ ZEPHIR_INIT_NVAR(_28);
+ ZVAL_STRING(_28, "maxResolution", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_43, this_ptr, "get", NULL, 0, _28);
+ zephir_check_temp_parameter(_28);
zephir_check_call_status();
- zephir_array_update_string(&replace, SL(":max"), &_45, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_45, "strtr", &_17, message, replace);
+ zephir_array_update_string(&replace, SL(":max"), &_43, PH_COPY | PH_SEPARATE);
+ ZEPHIR_CALL_FUNCTION(&_43, "strtr", &_17, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _45);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _43);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/file.zep.h b/ext/ice/validation/validator/file.zep.h
index eefdeaba..9eb6ef41 100644
--- a/ext/ice/validation/validator/file.zep.h
+++ b/ext/ice/validation/validator/file.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_file_method_entry) {
PHP_ME(Ice_Validation_Validator_File, validate, arginfo_ice_validation_validator_file_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/in.zep.c b/ext/ice/validation/validator/in.zep.c
index 4c7390c9..9979ac41 100644
--- a/ext/ice/validation/validator/in.zep.c
+++ b/ext/ice/validation/validator/in.zep.c
@@ -29,6 +29,20 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'status' => 'in:1,2,3,4'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_In) {
@@ -40,6 +54,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_In) {
/**
* Validate the validator
+ * Options: label, values, message
*
* @param Validation validation
* @param string field
@@ -47,11 +62,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_In) {
*/
PHP_METHOD(Ice_Validation_Validator_In, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_10 = NULL;
zend_bool _0, _5;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *values = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *values = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -60,7 +74,6 @@ PHP_METHOD(Ice_Validation_Validator_In, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -69,7 +82,7 @@ PHP_METHOD(Ice_Validation_Validator_In, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -80,90 +93,90 @@ PHP_METHOD(Ice_Validation_Validator_In, validate) {
}
ZEPHIR_INIT_VAR(_1);
ZVAL_LONG(_1, 1);
- ZEPHIR_CALL_METHOD(&values, this_ptr, "getoptions", NULL, _1);
+ ZEPHIR_CALL_METHOD(&values, this_ptr, "getoptions", NULL, 0, _1);
zephir_check_call_status();
if (ZEPHIR_IS_EMPTY(values)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "values", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&values, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&values, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
if (Z_TYPE_P(values) != IS_ARRAY) {
- ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Values must be an array", "ice/validation/validator/in.zep", 44);
+ ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Values must be an array", "ice/validation/validator/in.zep", 59);
return;
}
if (!(zephir_fast_in_array(value, values TSRMLS_CC))) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_2)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_3)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "in", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_4, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_4, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_5 = ZEPHIR_IS_TRUE_IDENTICAL(_4);
if (_5) {
- ZEPHIR_CALL_METHOD(&_6, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_6, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, _6, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_7, _6, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
_5 = zephir_is_true(_7);
}
if (_5) {
- ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _8, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&i18n, _8, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _9);
- ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _9);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
ZEPHIR_INIT_NVAR(_1);
zephir_fast_join_str(_1, SL(", "), values TSRMLS_CC);
zephir_array_update_string(&replace, SL(":values"), &_1, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_8, "strtr", &_10, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_8, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _8);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _8);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/in.zep.h b/ext/ice/validation/validator/in.zep.h
index d54356bd..e69262b8 100644
--- a/ext/ice/validation/validator/in.zep.h
+++ b/ext/ice/validation/validator/in.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_in_method_entry) {
PHP_ME(Ice_Validation_Validator_In, validate, arginfo_ice_validation_validator_in_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/length.zep.c b/ext/ice/validation/validator/length.zep.c
index 46a7e0b9..932c659d 100644
--- a/ext/ice/validation/validator/length.zep.c
+++ b/ext/ice/validation/validator/length.zep.c
@@ -30,6 +30,27 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'title' => 'length:10,100',
+ * 'content' => [
+ * 'length' => [
+ * 'max' => 1000,
+ * 'messageMin' => 'Too long!',
+ * 'label' => 'Desctiption'
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Length) {
@@ -41,6 +62,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Length) {
/**
* Validate the validator
+ * Options: label, min, max, messageMin, messageMax
*
* @param Validation validation
* @param string field
@@ -48,7 +70,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Length) {
*/
PHP_METHOD(Ice_Validation_Validator_Length, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_13 = NULL;
+ zephir_fcall_cache_entry *_13 = NULL;
zend_bool _0, _5, _8, _14;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
@@ -61,7 +83,6 @@ PHP_METHOD(Ice_Validation_Validator_Length, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -70,7 +91,7 @@ PHP_METHOD(Ice_Validation_Validator_Length, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -81,38 +102,38 @@ PHP_METHOD(Ice_Validation_Validator_Length, validate) {
}
ZEPHIR_INIT_VAR(_2);
ZVAL_LONG(_2, 0);
- ZEPHIR_CALL_METHOD(&_1, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_1, this_ptr, "has", NULL, 0, _2);
zephir_check_call_status();
if (zephir_is_true(_1)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_LONG(_2, 0);
- ZEPHIR_CALL_METHOD(&min, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&min, this_ptr, "get", NULL, 0, _2);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "min", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&min, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&min, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_2);
ZVAL_LONG(_2, 1);
- ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, 0, _2);
zephir_check_call_status();
if (zephir_is_true(_3)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_LONG(_2, 1);
- ZEPHIR_CALL_METHOD(&max, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&max, this_ptr, "get", NULL, 0, _2);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "max", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&max, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&max, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
if ((zephir_function_exists_ex(SS("mb_strlen") TSRMLS_CC) == SUCCESS)) {
- ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, value);
+ ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 171, value);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(length);
@@ -120,17 +141,17 @@ PHP_METHOD(Ice_Validation_Validator_Length, validate) {
}
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
if (zephir_is_true(_4)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
_5 = zephir_is_true(min);
@@ -140,57 +161,57 @@ PHP_METHOD(Ice_Validation_Validator_Length, validate) {
if (_5) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "messageMin", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
if (zephir_is_true(_6)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "messageMin", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "lengthMin", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _2);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_7, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_7, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_8 = ZEPHIR_IS_TRUE_IDENTICAL(_7);
if (_8) {
- ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, _9, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_10, _9, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
_8 = zephir_is_true(_10);
}
if (_8) {
- ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _11, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&i18n, _11, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _12);
- ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _12);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
zephir_array_update_string(&replace, SL(":min"), &min, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_11, "strtr", &_13, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_11, "strtr", &_13, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _11);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _11);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
@@ -201,57 +222,57 @@ PHP_METHOD(Ice_Validation_Validator_Length, validate) {
if (_8) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "messageMax", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
if (zephir_is_true(_6)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "messageMax", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "lengthMax", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _2);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_7, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_7, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_14 = ZEPHIR_IS_TRUE_IDENTICAL(_7);
if (_14) {
- ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_10, _9, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_10, _9, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
_14 = zephir_is_true(_10);
}
if (_14) {
- ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _11, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&i18n, _11, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _12);
- ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _12);
}
ZEPHIR_INIT_NVAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
zephir_array_update_string(&replace, SL(":max"), &max, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_11, "strtr", &_13, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_11, "strtr", &_13, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _11);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _11);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/length.zep.h b/ext/ice/validation/validator/length.zep.h
index 07fbeb41..cc776c52 100644
--- a/ext/ice/validation/validator/length.zep.h
+++ b/ext/ice/validation/validator/length.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_length_method_entry) {
PHP_ME(Ice_Validation_Validator_Length, validate, arginfo_ice_validation_validator_length_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/notin.zep.c b/ext/ice/validation/validator/notin.zep.c
index 9ceb24db..2fd73ce8 100644
--- a/ext/ice/validation/validator/notin.zep.c
+++ b/ext/ice/validation/validator/notin.zep.c
@@ -29,6 +29,27 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'status' => 'notIn:unactive,removed',
+ * 'username' => [
+ * 'notIn' => [
+ * 'values' => ['about', 'admin', 'user', 'root'],
+ * 'message' => 'Field :field is reserved',
+ * 'label' => 'Nick'
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_NotIn) {
@@ -40,6 +61,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_NotIn) {
/**
* Validate the validator
+ * Options: label, values, message
*
* @param Validation validation
* @param string field
@@ -47,11 +69,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_NotIn) {
*/
PHP_METHOD(Ice_Validation_Validator_NotIn, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_10 = NULL;
zend_bool _0, _5;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *values = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *values = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -60,7 +81,6 @@ PHP_METHOD(Ice_Validation_Validator_NotIn, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -69,7 +89,7 @@ PHP_METHOD(Ice_Validation_Validator_NotIn, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -80,90 +100,90 @@ PHP_METHOD(Ice_Validation_Validator_NotIn, validate) {
}
ZEPHIR_INIT_VAR(_1);
ZVAL_LONG(_1, 1);
- ZEPHIR_CALL_METHOD(&values, this_ptr, "getoptions", NULL, _1);
+ ZEPHIR_CALL_METHOD(&values, this_ptr, "getoptions", NULL, 0, _1);
zephir_check_call_status();
if (ZEPHIR_IS_EMPTY(values)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "values", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&values, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&values, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
if (Z_TYPE_P(values) != IS_ARRAY) {
- ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Values must be an array", "ice/validation/validator/notin.zep", 44);
+ ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Values must be an array", "ice/validation/validator/notin.zep", 66);
return;
}
if (zephir_fast_in_array(value, values TSRMLS_CC)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_2)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_3)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "notIn", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_4, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_4, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_5 = ZEPHIR_IS_TRUE_IDENTICAL(_4);
if (_5) {
- ZEPHIR_CALL_METHOD(&_6, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_6, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, _6, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_7, _6, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
_5 = zephir_is_true(_7);
}
if (_5) {
- ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _8, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&i18n, _8, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _9);
- ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _9);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
ZEPHIR_INIT_NVAR(_1);
zephir_fast_join_str(_1, SL(", "), values TSRMLS_CC);
zephir_array_update_string(&replace, SL(":values"), &_1, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_8, "strtr", &_10, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_8, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _8);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _8);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/notin.zep.h b/ext/ice/validation/validator/notin.zep.h
index 961329de..23ae5ede 100644
--- a/ext/ice/validation/validator/notin.zep.h
+++ b/ext/ice/validation/validator/notin.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_notin_method_entry) {
PHP_ME(Ice_Validation_Validator_NotIn, validate, arginfo_ice_validation_validator_notin_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/regex.zep.c b/ext/ice/validation/validator/regex.zep.c
index 7a61a0b5..da0878e0 100644
--- a/ext/ice/validation/validator/regex.zep.c
+++ b/ext/ice/validation/validator/regex.zep.c
@@ -15,6 +15,7 @@
#include "kernel/fcall.h"
#include "kernel/memory.h"
#include "kernel/operators.h"
+#include "kernel/string.h"
#include "kernel/array.h"
#include "ext/spl/spl_exceptions.h"
#include "kernel/exception.h"
@@ -28,6 +29,24 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => [
+ * 'regex' => [
+ * 'pattern' => '/[a-zA-Z][a-zA-Z0-9_-]{3,}/'
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Regex) {
@@ -39,6 +58,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Regex) {
/**
* Validate the validator
+ * Options: label, pattern, message
*
* @param Validation validation
* @param string field
@@ -46,11 +66,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Regex) {
*/
PHP_METHOD(Ice_Validation_Validator_Regex, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_4 = NULL, *_14 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
- zend_bool failed, _0, _9;
+ zend_bool failed = 0, _0, _8;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *pattern = NULL, *matches, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_5, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *pattern = NULL, *matches = NULL, *_1 = NULL, *_2 = NULL, *_3, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -59,7 +78,6 @@ PHP_METHOD(Ice_Validation_Validator_Regex, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -68,7 +86,7 @@ PHP_METHOD(Ice_Validation_Validator_Regex, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
ZEPHIR_INIT_VAR(matches);
array_init(matches);
@@ -81,98 +99,96 @@ PHP_METHOD(Ice_Validation_Validator_Regex, validate) {
}
ZEPHIR_INIT_VAR(_2);
ZVAL_LONG(_2, 0);
- ZEPHIR_CALL_METHOD(&_1, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_1, this_ptr, "has", NULL, 0, _2);
zephir_check_call_status();
if (zephir_is_true(_1)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_LONG(_2, 0);
- ZEPHIR_CALL_METHOD(&pattern, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&pattern, this_ptr, "get", NULL, 0, _2);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "pattern", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&pattern, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&pattern, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
- Z_SET_ISREF_P(matches);
- ZEPHIR_CALL_FUNCTION(&_3, "preg_match", &_4, pattern, value, matches);
- Z_UNSET_ISREF_P(matches);
- zephir_check_call_status();
- if (zephir_is_true(_3)) {
- zephir_array_fetch_long(&_5, matches, 0, PH_NOISY | PH_READONLY, "ice/validation/validator/regex.zep", 44 TSRMLS_CC);
- failed = !ZEPHIR_IS_EQUAL(_5, value);
+ ZEPHIR_INIT_NVAR(_2);
+ zephir_preg_match(_2, pattern, value, matches, 0, 0 , 0 TSRMLS_CC);
+ if (zephir_is_true(_2)) {
+ zephir_array_fetch_long(&_3, matches, 0, PH_NOISY | PH_READONLY, "ice/validation/validator/regex.zep", 63 TSRMLS_CC);
+ failed = !ZEPHIR_IS_EQUAL(_3, value);
} else {
failed = 1;
}
if (failed) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, _2);
- zephir_check_temp_parameter(_2);
+ ZEPHIR_INIT_VAR(_5);
+ ZVAL_STRING(_5, "label", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, 0, _5);
+ zephir_check_temp_parameter(_5);
zephir_check_call_status();
- if (zephir_is_true(_6)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _2);
- zephir_check_temp_parameter(_2);
+ if (zephir_is_true(_4)) {
+ ZEPHIR_INIT_NVAR(_5);
+ ZVAL_STRING(_5, "label", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _5);
+ zephir_check_temp_parameter(_5);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, this_ptr, "has", NULL, _2);
- zephir_check_temp_parameter(_2);
+ ZEPHIR_INIT_NVAR(_5);
+ ZVAL_STRING(_5, "message", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, 0, _5);
+ zephir_check_temp_parameter(_5);
zephir_check_call_status();
- if (zephir_is_true(_7)) {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _2);
- zephir_check_temp_parameter(_2);
+ if (zephir_is_true(_6)) {
+ ZEPHIR_INIT_NVAR(_5);
+ ZVAL_STRING(_5, "message", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _5);
+ zephir_check_temp_parameter(_5);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "regex", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _2);
- zephir_check_temp_parameter(_2);
+ ZEPHIR_INIT_NVAR(_5);
+ ZVAL_STRING(_5, "regex", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _5);
+ zephir_check_temp_parameter(_5);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_8, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_7, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
- _9 = ZEPHIR_IS_TRUE_IDENTICAL(_8);
- if (_9) {
- ZEPHIR_CALL_METHOD(&_10, validation, "getdi", NULL);
+ _8 = ZEPHIR_IS_TRUE_IDENTICAL(_7);
+ if (_8) {
+ ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_11, _10, "has", NULL, _2);
- zephir_check_temp_parameter(_2);
+ ZEPHIR_INIT_NVAR(_5);
+ ZVAL_STRING(_5, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_10, _9, "has", NULL, 0, _5);
+ zephir_check_temp_parameter(_5);
zephir_check_call_status();
- _9 = zephir_is_true(_11);
+ _8 = zephir_is_true(_10);
}
- if (_9) {
- ZEPHIR_CALL_METHOD(&_12, validation, "getdi", NULL);
+ if (_8) {
+ ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_2);
- ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _12, "get", NULL, _2);
- zephir_check_temp_parameter(_2);
+ ZEPHIR_INIT_NVAR(_5);
+ ZVAL_STRING(_5, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&i18n, _11, "get", NULL, 0, _5);
+ zephir_check_temp_parameter(_5);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_13, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(label, _13);
- ZEPHIR_CALL_METHOD(&_13, i18n, "translate", NULL, message);
+ ZEPHIR_CPY_WRT(label, _12);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(message, _13);
+ ZEPHIR_CPY_WRT(message, _12);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_12, "strtr", &_14, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_11, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _12);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _11);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/regex.zep.h b/ext/ice/validation/validator/regex.zep.h
index 1104dc02..59e302b2 100644
--- a/ext/ice/validation/validator/regex.zep.h
+++ b/ext/ice/validation/validator/regex.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_regex_method_entry) {
PHP_ME(Ice_Validation_Validator_Regex, validate, arginfo_ice_validation_validator_regex_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/required.zep.c b/ext/ice/validation/validator/required.zep.c
index c8c8303c..413813ea 100644
--- a/ext/ice/validation/validator/required.zep.c
+++ b/ext/ice/validation/validator/required.zep.c
@@ -28,6 +28,20 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => 'required'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Required) {
@@ -46,11 +60,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Required) {
*/
PHP_METHOD(Ice_Validation_Validator_Required, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_10 = NULL;
zend_bool _0, _5;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -59,7 +72,6 @@ PHP_METHOD(Ice_Validation_Validator_Required, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -68,7 +80,7 @@ PHP_METHOD(Ice_Validation_Validator_Required, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -77,71 +89,71 @@ PHP_METHOD(Ice_Validation_Validator_Required, validate) {
if (_0) {
ZEPHIR_INIT_VAR(_2);
ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_1, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_1, this_ptr, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
if (zephir_is_true(_1)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
if (zephir_is_true(_3)) {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "required", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _2);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_4, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_4, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_5 = ZEPHIR_IS_TRUE_IDENTICAL(_4);
if (_5) {
- ZEPHIR_CALL_METHOD(&_6, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_6, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, _6, "has", NULL, _2);
+ ZEPHIR_CALL_METHOD(&_7, _6, "has", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
_5 = zephir_is_true(_7);
}
if (_5) {
- ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_2);
ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _8, "get", NULL, _2);
+ ZEPHIR_CALL_METHOD(&i18n, _8, "get", NULL, 0, _2);
zephir_check_temp_parameter(_2);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _9);
- ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_9, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _9);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_8, "strtr", &_10, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_8, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _8);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _8);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/required.zep.h b/ext/ice/validation/validator/required.zep.h
index 8fb4424b..6df334fa 100644
--- a/ext/ice/validation/validator/required.zep.h
+++ b/ext/ice/validation/validator/required.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_required_method_entry) {
PHP_ME(Ice_Validation_Validator_Required, validate, arginfo_ice_validation_validator_required_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/same.zep.c b/ext/ice/validation/validator/same.zep.c
index c2b00b24..00c59015 100644
--- a/ext/ice/validation/validator/same.zep.c
+++ b/ext/ice/validation/validator/same.zep.c
@@ -28,6 +28,21 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'email' => 'required|email',
+ * 'repeatEmail' => 'same:email'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Same) {
@@ -46,11 +61,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Same) {
*/
PHP_METHOD(Ice_Validation_Validator_Same, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_15 = NULL;
zend_bool _2, _3, _10;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *allowEmpty = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *other = NULL, *valueOther = NULL, *labelOther = NULL, *_0 = NULL, *_1 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *allowEmpty = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *other = NULL, *valueOther = NULL, *labelOther = NULL, *_0 = NULL, *_1 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -59,7 +73,6 @@ PHP_METHOD(Ice_Validation_Validator_Same, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -68,21 +81,21 @@ PHP_METHOD(Ice_Validation_Validator_Same, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
ZEPHIR_INIT_VAR(_1);
ZVAL_LONG(_1, 1);
- ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, _1);
zephir_check_call_status();
if (zephir_is_true(_0)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_LONG(_1, 1);
- ZEPHIR_CALL_METHOD(&allowEmpty, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&allowEmpty, this_ptr, "get", NULL, 0, _1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "allowEmpty", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&allowEmpty, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&allowEmpty, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
@@ -99,24 +112,24 @@ PHP_METHOD(Ice_Validation_Validator_Same, validate) {
}
ZEPHIR_INIT_NVAR(_1);
ZVAL_LONG(_1, 0);
- ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, 0, _1);
zephir_check_call_status();
if (zephir_is_true(_4)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_LONG(_1, 0);
- ZEPHIR_CALL_METHOD(&other, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&other, this_ptr, "get", NULL, 0, _1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "other", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&other, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&other, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_5, validation, "hasvalue", NULL, other);
+ ZEPHIR_CALL_METHOD(&_5, validation, "hasvalue", NULL, 0, other);
zephir_check_call_status();
if (zephir_is_true(_5)) {
- ZEPHIR_CALL_METHOD(&valueOther, validation, "getvalue", NULL, other);
+ ZEPHIR_CALL_METHOD(&valueOther, validation, "getvalue", NULL, 0, other);
zephir_check_call_status();
} else {
ZEPHIR_CPY_WRT(valueOther, other);
@@ -124,90 +137,90 @@ PHP_METHOD(Ice_Validation_Validator_Same, validate) {
if (!ZEPHIR_IS_EQUAL(value, valueOther)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_6)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "labelOther", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_7, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_7)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "labelOther", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&labelOther, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&labelOther, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&labelOther, validation, "getlabel", NULL, other);
+ ZEPHIR_CALL_METHOD(&labelOther, validation, "getlabel", NULL, 0, other);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_8, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
if (zephir_is_true(_8)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "same", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_9, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_9, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_10 = ZEPHIR_IS_TRUE_IDENTICAL(_9);
if (_10) {
- ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_12, _11, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_12, _11, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
_10 = zephir_is_true(_12);
}
if (_10) {
- ZEPHIR_CALL_METHOD(&_13, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_13, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _13, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&i18n, _13, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_14, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_14, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _14);
- ZEPHIR_CALL_METHOD(&_14, i18n, "translate", NULL, labelOther);
+ ZEPHIR_CALL_METHOD(&_14, i18n, "translate", NULL, 0, labelOther);
zephir_check_call_status();
ZEPHIR_CPY_WRT(labelOther, _14);
- ZEPHIR_CALL_METHOD(&_14, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_14, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _14);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
zephir_array_update_string(&replace, SL(":other"), &labelOther, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_13, "strtr", &_15, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_13, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _13);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _13);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/same.zep.h b/ext/ice/validation/validator/same.zep.h
index 307373bb..866f53c3 100644
--- a/ext/ice/validation/validator/same.zep.h
+++ b/ext/ice/validation/validator/same.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_same_method_entry) {
PHP_ME(Ice_Validation_Validator_Same, validate, arginfo_ice_validation_validator_same_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/unique.zep.c b/ext/ice/validation/validator/unique.zep.c
index 398e50f1..09217626 100644
--- a/ext/ice/validation/validator/unique.zep.c
+++ b/ext/ice/validation/validator/unique.zep.c
@@ -15,6 +15,8 @@
#include "kernel/fcall.h"
#include "kernel/operators.h"
#include "kernel/memory.h"
+#include "kernel/concat.h"
+#include "kernel/string.h"
#include "kernel/array.h"
#include "ext/spl/spl_exceptions.h"
#include "kernel/exception.h"
@@ -28,6 +30,25 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'userName' => [
+ * 'unique' => [
+ * 'from' => 'users',
+ * 'custom' => 'username'
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Unique) {
@@ -39,6 +60,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Unique) {
/**
* Validate the validator
+ * Options: label, from, custom, except, message
*
* @param Validation validation
* @param string field
@@ -46,12 +68,12 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Unique) {
*/
PHP_METHOD(Ice_Validation_Validator_Unique, validate) {
- zval *_6 = NULL;
- zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_15 = NULL;
- zend_bool _0, _10;
+ zval *_11 = NULL;
+ zephir_fcall_cache_entry *_1 = NULL;
+ zend_bool _0, _14;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *di = NULL, *db = NULL, *from = NULL, *custom = NULL, *except = NULL, *result = NULL, *id, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_14 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *di = NULL, *db = NULL, *from = NULL, *custom = NULL, *except = NULL, *tmp = NULL, *caseInsensitive = NULL, *result = NULL, *id = NULL, *_2 = NULL, *_3, *_4, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10, *_12 = NULL, *_13 = NULL, *_15 = NULL, *_16 = NULL, *_17 = NULL, *_18 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -60,7 +82,6 @@ PHP_METHOD(Ice_Validation_Validator_Unique, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -69,7 +90,7 @@ PHP_METHOD(Ice_Validation_Validator_Unique, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -78,146 +99,189 @@ PHP_METHOD(Ice_Validation_Validator_Unique, validate) {
if (_0) {
RETURN_MM_BOOL(1);
}
- ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_1);
- zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&db, di, "getdb", NULL);
+ ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_1, 8);
zephir_check_call_status();
+ ZEPHIR_INIT_VAR(_2);
+ ZVAL_STRING(_2, "db", ZEPHIR_TEMP_PARAM_COPY);
ZEPHIR_INIT_VAR(_3);
- ZVAL_LONG(_3, 0);
- ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, _3);
+ ZVAL_NULL(_3);
+ ZEPHIR_INIT_VAR(_4);
+ ZVAL_BOOL(_4, 1);
+ ZEPHIR_CALL_METHOD(&db, di, "get", NULL, 0, _2, _3, _4);
+ zephir_check_temp_parameter(_2);
zephir_check_call_status();
- if (zephir_is_true(_2)) {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_LONG(_3, 0);
- ZEPHIR_CALL_METHOD(&from, this_ptr, "get", NULL, _3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, 0);
+ ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", NULL, 0, _2);
+ zephir_check_call_status();
+ if (zephir_is_true(_5)) {
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, 0);
+ ZEPHIR_CALL_METHOD(&from, this_ptr, "get", NULL, 0, _2);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "from", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&from, this_ptr, "get", NULL, _3);
- zephir_check_temp_parameter(_3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "from", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&from, this_ptr, "get", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_LONG(_3, 1);
- ZEPHIR_CALL_METHOD(&_4, this_ptr, "has", NULL, _3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, 1);
+ ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, 0, _2);
zephir_check_call_status();
- if (zephir_is_true(_4)) {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_LONG(_3, 1);
- ZEPHIR_CALL_METHOD(&custom, this_ptr, "get", NULL, _3);
+ if (zephir_is_true(_6)) {
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, 1);
+ ZEPHIR_CALL_METHOD(&custom, this_ptr, "get", NULL, 0, _2);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "custom", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&custom, this_ptr, "get", NULL, _3);
- zephir_check_temp_parameter(_3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "custom", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&custom, this_ptr, "get", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
if (ZEPHIR_IS_EMPTY(custom)) {
ZEPHIR_CPY_WRT(custom, field);
}
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_LONG(_3, 2);
- ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", NULL, _3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, 2);
+ ZEPHIR_CALL_METHOD(&_7, this_ptr, "has", NULL, 0, _2);
zephir_check_call_status();
- if (zephir_is_true(_5)) {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_LONG(_3, 2);
- ZEPHIR_CALL_METHOD(&except, this_ptr, "get", NULL, _3);
+ if (zephir_is_true(_7)) {
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, 2);
+ ZEPHIR_CALL_METHOD(&except, this_ptr, "get", NULL, 0, _2);
+ zephir_check_call_status();
+ } else {
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "except", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&except, this_ptr, "get", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
+ zephir_check_call_status();
+ }
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, 3);
+ ZEPHIR_CALL_METHOD(&_8, this_ptr, "has", NULL, 0, _2);
+ zephir_check_call_status();
+ if (zephir_is_true(_8)) {
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_LONG(_2, 3);
+ ZEPHIR_CALL_METHOD(&caseInsensitive, this_ptr, "get", NULL, 0, _2);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "except", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&except, this_ptr, "get", NULL, _3);
- zephir_check_temp_parameter(_3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "caseInsensitive", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&caseInsensitive, this_ptr, "get", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
+ zephir_check_call_status();
+ }
+ if (zephir_is_true(caseInsensitive)) {
+ ZEPHIR_CPY_WRT(tmp, value);
+ ZEPHIR_CALL_METHOD(&_9, db, "gettype", NULL, 0);
zephir_check_call_status();
+ if (ZEPHIR_IS_STRING(_9, "NOSQL")) {
+ ZEPHIR_INIT_NVAR(value);
+ object_init_ex(value, zephir_get_internal_ce(SS("mongoregex") TSRMLS_CC));
+ ZEPHIR_INIT_VAR(_10);
+ ZEPHIR_CONCAT_SVS(_10, "/^", tmp, "$/i");
+ ZEPHIR_CALL_METHOD(NULL, value, "__construct", NULL, 0, _10);
+ zephir_check_call_status();
+ } else {
+ ZEPHIR_INIT_NVAR(value);
+ zephir_fast_strtolower(value, tmp);
+ }
}
if (zephir_is_true(except)) {
ZEPHIR_INIT_VAR(id);
- array_init_size(id, 2);
- zephir_array_update_string(&id, SL("!="), &except, PH_COPY | PH_SEPARATE);
- ZEPHIR_INIT_VAR(_6);
- array_init_size(_6, 3);
- zephir_array_update_zval(&_6, custom, &value, PH_COPY);
- zephir_array_update_string(&_6, SL("id"), &id, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_METHOD(&result, db, "findone", NULL, from, _6);
+ zephir_create_array(id, 1, 0 TSRMLS_CC);
+ ZEPHIR_CALL_METHOD(&_9, db, "getidvalue", NULL, 0, except);
+ zephir_check_call_status();
+ zephir_array_update_string(&id, SL("!="), &_9, PH_COPY | PH_SEPARATE);
+ ZEPHIR_INIT_VAR(_11);
+ zephir_create_array(_11, 2, 0 TSRMLS_CC);
+ zephir_array_update_zval(&_11, custom, &value, PH_COPY);
+ ZEPHIR_CALL_METHOD(&_9, db, "getid", NULL, 0);
+ zephir_check_call_status();
+ zephir_array_update_zval(&_11, _9, &id, PH_COPY);
+ ZEPHIR_CALL_METHOD(&result, db, "findone", NULL, 0, from, _11);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_6);
- array_init_size(_6, 2);
- zephir_array_update_zval(&_6, custom, &value, PH_COPY);
- ZEPHIR_CALL_METHOD(&result, db, "findone", NULL, from, _6);
+ ZEPHIR_INIT_NVAR(_11);
+ zephir_create_array(_11, 1, 0 TSRMLS_CC);
+ zephir_array_update_zval(&_11, custom, &value, PH_COPY);
+ ZEPHIR_CALL_METHOD(&result, db, "findone", NULL, 0, from, _11);
zephir_check_call_status();
}
if (zephir_is_true(result)) {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, this_ptr, "has", NULL, _3);
- zephir_check_temp_parameter(_3);
- zephir_check_call_status();
- if (zephir_is_true(_7)) {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _3);
- zephir_check_temp_parameter(_3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_9, this_ptr, "has", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
+ zephir_check_call_status();
+ if (zephir_is_true(_9)) {
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "label", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, this_ptr, "has", NULL, _3);
- zephir_check_temp_parameter(_3);
- zephir_check_call_status();
- if (zephir_is_true(_8)) {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _3);
- zephir_check_temp_parameter(_3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "message", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_12, this_ptr, "has", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
+ zephir_check_call_status();
+ if (zephir_is_true(_12)) {
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "message", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
zephir_check_call_status();
} else {
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "unique", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _3);
- zephir_check_temp_parameter(_3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "unique", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_9, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_13, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
- _10 = ZEPHIR_IS_TRUE_IDENTICAL(_9);
- if (_10) {
- ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL);
+ _14 = ZEPHIR_IS_TRUE_IDENTICAL(_13);
+ if (_14) {
+ ZEPHIR_CALL_METHOD(&_15, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_12, _11, "has", NULL, _3);
- zephir_check_temp_parameter(_3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&_16, _15, "has", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
zephir_check_call_status();
- _10 = zephir_is_true(_12);
+ _14 = zephir_is_true(_16);
}
- if (_10) {
- ZEPHIR_CALL_METHOD(&_13, validation, "getdi", NULL);
+ if (_14) {
+ ZEPHIR_CALL_METHOD(&_17, validation, "getdi", NULL, 0);
zephir_check_call_status();
- ZEPHIR_INIT_NVAR(_3);
- ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _13, "get", NULL, _3);
- zephir_check_temp_parameter(_3);
+ ZEPHIR_INIT_NVAR(_2);
+ ZVAL_STRING(_2, "i18n", ZEPHIR_TEMP_PARAM_COPY);
+ ZEPHIR_CALL_METHOD(&i18n, _17, "get", NULL, 0, _2);
+ zephir_check_temp_parameter(_2);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_14, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_18, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(label, _14);
- ZEPHIR_CALL_METHOD(&_14, i18n, "translate", NULL, message);
+ ZEPHIR_CPY_WRT(label, _18);
+ ZEPHIR_CALL_METHOD(&_18, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(message, _14);
+ ZEPHIR_CPY_WRT(message, _18);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_13, "strtr", &_15, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_17, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _13);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _17);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/unique.zep.h b/ext/ice/validation/validator/unique.zep.h
index a165f707..5cf60f44 100644
--- a/ext/ice/validation/validator/unique.zep.h
+++ b/ext/ice/validation/validator/unique.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_unique_method_entry) {
PHP_ME(Ice_Validation_Validator_Unique, validate, arginfo_ice_validation_validator_unique_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/url.zep.c b/ext/ice/validation/validator/url.zep.c
index b7283f40..106894b7 100644
--- a/ext/ice/validation/validator/url.zep.c
+++ b/ext/ice/validation/validator/url.zep.c
@@ -28,6 +28,20 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'website' => 'url'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Url) {
@@ -46,11 +60,10 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Url) {
*/
PHP_METHOD(Ice_Validation_Validator_Url, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_12 = NULL;
zend_bool _0, _7;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, _1, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, _1, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -59,7 +72,6 @@ PHP_METHOD(Ice_Validation_Validator_Url, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -68,7 +80,7 @@ PHP_METHOD(Ice_Validation_Validator_Url, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -79,76 +91,76 @@ PHP_METHOD(Ice_Validation_Validator_Url, validate) {
}
ZEPHIR_SINIT_VAR(_1);
ZVAL_LONG(&_1, 273);
- ZEPHIR_CALL_FUNCTION(&_2, "filter_var", NULL, value, &_1);
+ ZEPHIR_CALL_FUNCTION(&_2, "filter_var", NULL, 104, value, &_1);
zephir_check_call_status();
if (!(zephir_is_true(_2))) {
ZEPHIR_INIT_VAR(_4);
ZVAL_STRING(_4, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
if (zephir_is_true(_3)) {
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _4);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
if (zephir_is_true(_5)) {
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _4);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "url", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _4);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_6, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_6, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
_7 = ZEPHIR_IS_TRUE_IDENTICAL(_6);
if (_7) {
- ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_8, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_9, _8, "has", NULL, _4);
+ ZEPHIR_CALL_METHOD(&_9, _8, "has", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
_7 = zephir_is_true(_9);
}
if (_7) {
- ZEPHIR_CALL_METHOD(&_10, validation, "getdi", NULL);
+ ZEPHIR_CALL_METHOD(&_10, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_4);
ZVAL_STRING(_4, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _10, "get", NULL, _4);
+ ZEPHIR_CALL_METHOD(&i18n, _10, "get", NULL, 0, _4);
zephir_check_temp_parameter(_4);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_11, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_11, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
ZEPHIR_CPY_WRT(label, _11);
- ZEPHIR_CALL_METHOD(&_11, i18n, "translate", NULL, message);
+ ZEPHIR_CALL_METHOD(&_11, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
ZEPHIR_CPY_WRT(message, _11);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 2);
+ zephir_create_array(replace, 1, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_10, "strtr", &_12, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_10, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _10);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _10);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/url.zep.h b/ext/ice/validation/validator/url.zep.h
index 27e23f2f..b4df33d5 100644
--- a/ext/ice/validation/validator/url.zep.h
+++ b/ext/ice/validation/validator/url.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_url_method_entry) {
PHP_ME(Ice_Validation_Validator_Url, validate, arginfo_ice_validation_validator_url_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/with.zep.c b/ext/ice/validation/validator/with.zep.c
index c272ebbd..f32a1207 100644
--- a/ext/ice/validation/validator/with.zep.c
+++ b/ext/ice/validation/validator/with.zep.c
@@ -30,6 +30,24 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'repeatPassword' => [
+ * 'with' => [
+ * 'fields' => ['password'],
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_With) {
@@ -41,6 +59,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_With) {
/**
* Validate the validator
+ * Options: label, fields, message
*
* @param Validation validation
* @param string field
@@ -48,14 +67,12 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_With) {
*/
PHP_METHOD(Ice_Validation_Validator_With, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_14 = NULL;
- zephir_fcall_cache_entry *_5 = NULL;
HashTable *_3;
HashPosition _2;
- zend_bool _0, _6;
+ zend_bool _0, _5;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *fields = NULL, *with = NULL, *tmp = NULL, *required, *_1 = NULL, **_4, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *fields = NULL, *with = NULL, *tmp = NULL, *required = NULL, *_1 = NULL, **_4, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -64,7 +81,6 @@ PHP_METHOD(Ice_Validation_Validator_With, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -73,7 +89,7 @@ PHP_METHOD(Ice_Validation_Validator_With, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -84,108 +100,108 @@ PHP_METHOD(Ice_Validation_Validator_With, validate) {
}
ZEPHIR_INIT_VAR(_1);
ZVAL_LONG(_1, 1);
- ZEPHIR_CALL_METHOD(&fields, this_ptr, "getoptions", NULL, _1);
+ ZEPHIR_CALL_METHOD(&fields, this_ptr, "getoptions", NULL, 0, _1);
zephir_check_call_status();
ZEPHIR_INIT_VAR(required);
array_init(required);
if (ZEPHIR_IS_EMPTY(fields)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "fields", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&fields, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&fields, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
if (Z_TYPE_P(fields) != IS_ARRAY) {
- ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Fields must be an array", "ice/validation/validator/with.zep", 45);
+ ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Fields must be an array", "ice/validation/validator/with.zep", 64);
return;
}
- zephir_is_iterable(fields, &_3, &_2, 0, 0, "ice/validation/validator/with.zep", 56);
+ zephir_is_iterable(fields, &_3, &_2, 0, 0, "ice/validation/validator/with.zep", 75);
for (
; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS
; zephir_hash_move_forward_ex(_3, &_2)
) {
ZEPHIR_GET_HVALUE(with, _4);
- ZEPHIR_CALL_METHOD(&tmp, validation, "getvalue", &_5, with);
+ ZEPHIR_CALL_METHOD(&tmp, validation, "getvalue", NULL, 0, with);
zephir_check_call_status();
- _6 = ZEPHIR_IS_STRING_IDENTICAL(tmp, "");
- if (!(_6)) {
- _6 = Z_TYPE_P(tmp) == IS_NULL;
+ _5 = ZEPHIR_IS_STRING_IDENTICAL(tmp, "");
+ if (!(_5)) {
+ _5 = Z_TYPE_P(tmp) == IS_NULL;
}
- if (_6) {
- zephir_array_append(&required, with, PH_SEPARATE, "ice/validation/validator/with.zep", 52);
+ if (_5) {
+ zephir_array_append(&required, with, PH_SEPARATE, "ice/validation/validator/with.zep", 71);
}
}
if (zephir_fast_count_int(required TSRMLS_CC)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- if (zephir_is_true(_7)) {
+ if (zephir_is_true(_6)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_7, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- if (zephir_is_true(_8)) {
+ if (zephir_is_true(_7)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "with", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_9, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_8, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
- _6 = ZEPHIR_IS_TRUE_IDENTICAL(_9);
- if (_6) {
- ZEPHIR_CALL_METHOD(&_10, validation, "getdi", NULL);
+ _5 = ZEPHIR_IS_TRUE_IDENTICAL(_8);
+ if (_5) {
+ ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_11, _10, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_10, _9, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- _6 = zephir_is_true(_11);
+ _5 = zephir_is_true(_10);
}
- if (_6) {
- ZEPHIR_CALL_METHOD(&_12, validation, "getdi", NULL);
+ if (_5) {
+ ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _12, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&i18n, _11, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_13, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(label, _13);
- ZEPHIR_CALL_METHOD(&_13, i18n, "translate", NULL, message);
+ ZEPHIR_CPY_WRT(label, _12);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(message, _13);
+ ZEPHIR_CPY_WRT(message, _12);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
ZEPHIR_INIT_NVAR(_1);
zephir_fast_join_str(_1, SL(", "), required TSRMLS_CC);
zephir_array_update_string(&replace, SL(":fields"), &_1, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_12, "strtr", &_14, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_11, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _12);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _11);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/with.zep.h b/ext/ice/validation/validator/with.zep.h
index 122694a3..7e8d6b64 100644
--- a/ext/ice/validation/validator/with.zep.h
+++ b/ext/ice/validation/validator/with.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_with_method_entry) {
PHP_ME(Ice_Validation_Validator_With, validate, arginfo_ice_validation_validator_with_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/validation/validator/without.zep.c b/ext/ice/validation/validator/without.zep.c
index e605a1c8..b5cc8ee9 100644
--- a/ext/ice/validation/validator/without.zep.c
+++ b/ext/ice/validation/validator/without.zep.c
@@ -30,6 +30,24 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'password' => [
+ * 'without' => [
+ * 'fields' => ['newPassword'],
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Without) {
@@ -41,6 +59,7 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Without) {
/**
* Validate the validator
+ * Options: label, fields, message
*
* @param Validation validation
* @param string field
@@ -48,14 +67,12 @@ ZEPHIR_INIT_CLASS(Ice_Validation_Validator_Without) {
*/
PHP_METHOD(Ice_Validation_Validator_Without, validate) {
- zephir_nts_static zephir_fcall_cache_entry *_14 = NULL;
- zephir_fcall_cache_entry *_5 = NULL;
HashTable *_3;
HashPosition _2;
- zend_bool _0, _6;
+ zend_bool _0, _5;
int ZEPHIR_LAST_CALL_STATUS;
zval *field = NULL;
- zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace, *fields = NULL, *without = NULL, *tmp = NULL, *except, *_1 = NULL, **_4, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL;
+ zval *validation, *field_param = NULL, *value = NULL, *label = NULL, *message = NULL, *i18n = NULL, *replace = NULL, *fields = NULL, *without = NULL, *tmp = NULL, *except = NULL, *_1 = NULL, **_4, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11 = NULL, *_12 = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &validation, &field_param);
@@ -64,7 +81,6 @@ PHP_METHOD(Ice_Validation_Validator_Without, validate) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
-
if (likely(Z_TYPE_P(field_param) == IS_STRING)) {
zephir_get_strval(field, field_param);
} else {
@@ -73,7 +89,7 @@ PHP_METHOD(Ice_Validation_Validator_Without, validate) {
}
- ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, field);
+ ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field);
zephir_check_call_status();
_0 = ZEPHIR_IS_STRING_IDENTICAL(value, "");
if (!(_0)) {
@@ -84,108 +100,108 @@ PHP_METHOD(Ice_Validation_Validator_Without, validate) {
}
ZEPHIR_INIT_VAR(_1);
ZVAL_LONG(_1, 1);
- ZEPHIR_CALL_METHOD(&fields, this_ptr, "getoptions", NULL, _1);
+ ZEPHIR_CALL_METHOD(&fields, this_ptr, "getoptions", NULL, 0, _1);
zephir_check_call_status();
ZEPHIR_INIT_VAR(except);
array_init(except);
if (ZEPHIR_IS_EMPTY(fields)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "fields", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&fields, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&fields, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
if (Z_TYPE_P(fields) != IS_ARRAY) {
- ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Fields must be an array", "ice/validation/validator/without.zep", 45);
+ ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Fields must be an array", "ice/validation/validator/without.zep", 64);
return;
}
- zephir_is_iterable(fields, &_3, &_2, 0, 0, "ice/validation/validator/without.zep", 56);
+ zephir_is_iterable(fields, &_3, &_2, 0, 0, "ice/validation/validator/without.zep", 75);
for (
; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS
; zephir_hash_move_forward_ex(_3, &_2)
) {
ZEPHIR_GET_HVALUE(without, _4);
- ZEPHIR_CALL_METHOD(&tmp, validation, "getvalue", &_5, without);
+ ZEPHIR_CALL_METHOD(&tmp, validation, "getvalue", NULL, 0, without);
zephir_check_call_status();
- _6 = !ZEPHIR_IS_STRING_IDENTICAL(tmp, "");
- if (_6) {
- _6 = Z_TYPE_P(tmp) != IS_NULL;
+ _5 = !ZEPHIR_IS_STRING_IDENTICAL(tmp, "");
+ if (_5) {
+ _5 = Z_TYPE_P(tmp) != IS_NULL;
}
- if (_6) {
- zephir_array_append(&except, without, PH_SEPARATE, "ice/validation/validator/without.zep", 52);
+ if (_5) {
+ zephir_array_append(&except, without, PH_SEPARATE, "ice/validation/validator/without.zep", 71);
}
}
if (zephir_fast_count_int(except TSRMLS_CC)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_7, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_6, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- if (zephir_is_true(_7)) {
+ if (zephir_is_true(_6)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "label", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&label, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
- ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, field);
+ ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, field);
zephir_check_call_status();
}
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_8, this_ptr, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_7, this_ptr, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- if (zephir_is_true(_8)) {
+ if (zephir_is_true(_7)) {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "message", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, this_ptr, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
} else {
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "without", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, _1);
+ ZEPHIR_CALL_METHOD(&message, validation, "getdefaultmessage", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
}
- ZEPHIR_CALL_METHOD(&_9, validation, "gettranslate", NULL);
+ ZEPHIR_CALL_METHOD(&_8, validation, "gettranslate", NULL, 0);
zephir_check_call_status();
- _6 = ZEPHIR_IS_TRUE_IDENTICAL(_9);
- if (_6) {
- ZEPHIR_CALL_METHOD(&_10, validation, "getdi", NULL);
+ _5 = ZEPHIR_IS_TRUE_IDENTICAL(_8);
+ if (_5) {
+ ZEPHIR_CALL_METHOD(&_9, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&_11, _10, "has", NULL, _1);
+ ZEPHIR_CALL_METHOD(&_10, _9, "has", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- _6 = zephir_is_true(_11);
+ _5 = zephir_is_true(_10);
}
- if (_6) {
- ZEPHIR_CALL_METHOD(&_12, validation, "getdi", NULL);
+ if (_5) {
+ ZEPHIR_CALL_METHOD(&_11, validation, "getdi", NULL, 0);
zephir_check_call_status();
ZEPHIR_INIT_NVAR(_1);
ZVAL_STRING(_1, "i18n", ZEPHIR_TEMP_PARAM_COPY);
- ZEPHIR_CALL_METHOD(&i18n, _12, "get", NULL, _1);
+ ZEPHIR_CALL_METHOD(&i18n, _11, "get", NULL, 0, _1);
zephir_check_temp_parameter(_1);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(&_13, i18n, "translate", NULL, label);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, label);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(label, _13);
- ZEPHIR_CALL_METHOD(&_13, i18n, "translate", NULL, message);
+ ZEPHIR_CPY_WRT(label, _12);
+ ZEPHIR_CALL_METHOD(&_12, i18n, "translate", NULL, 0, message);
zephir_check_call_status();
- ZEPHIR_CPY_WRT(message, _13);
+ ZEPHIR_CPY_WRT(message, _12);
}
ZEPHIR_INIT_VAR(replace);
- array_init_size(replace, 3);
+ zephir_create_array(replace, 2, 0 TSRMLS_CC);
zephir_array_update_string(&replace, SL(":field"), &label, PH_COPY | PH_SEPARATE);
ZEPHIR_INIT_NVAR(_1);
zephir_fast_join_str(_1, SL(", "), except TSRMLS_CC);
zephir_array_update_string(&replace, SL(":fields"), &_1, PH_COPY | PH_SEPARATE);
- ZEPHIR_CALL_FUNCTION(&_12, "strtr", &_14, message, replace);
+ ZEPHIR_CALL_FUNCTION(&_11, "strtr", NULL, 85, message, replace);
zephir_check_call_status();
- ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, field, _12);
+ ZEPHIR_CALL_METHOD(NULL, validation, "addmessage", NULL, 0, field, _11);
zephir_check_call_status();
RETURN_MM_BOOL(0);
}
diff --git a/ext/ice/validation/validator/without.zep.h b/ext/ice/validation/validator/without.zep.h
index 8533f21f..b8c4d104 100644
--- a/ext/ice/validation/validator/without.zep.h
+++ b/ext/ice/validation/validator/without.zep.h
@@ -12,5 +12,5 @@ ZEND_END_ARG_INFO()
ZEPHIR_INIT_FUNCS(ice_validation_validator_without_method_entry) {
PHP_ME(Ice_Validation_Validator_Without, validate, arginfo_ice_validation_validator_without_validate, ZEND_ACC_PUBLIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/ice/version.zep.c b/ext/ice/version.zep.c
index 7006f08d..1e95df64 100644
--- a/ext/ice/version.zep.c
+++ b/ext/ice/version.zep.c
@@ -12,11 +12,11 @@
#include
#include "kernel/main.h"
-#include "kernel/fcall.h"
#include "kernel/array.h"
-#include "kernel/operators.h"
#include "kernel/memory.h"
#include "kernel/concat.h"
+#include "kernel/fcall.h"
+#include "kernel/operators.h"
/**
@@ -27,6 +27,7 @@
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ * @see http://semver.org (Semantic Versioning 2.0.0)
*/
ZEPHIR_INIT_CLASS(Ice_Version) {
@@ -42,22 +43,32 @@ ZEPHIR_INIT_CLASS(Ice_Version) {
zend_declare_class_constant_long(ice_version_ce, SL("STABLE"), 4 TSRMLS_CC);
+ zend_declare_class_constant_long(ice_version_ce, SL("MAJOR"), 1 TSRMLS_CC);
+
+ zend_declare_class_constant_long(ice_version_ce, SL("MINOR"), 0 TSRMLS_CC);
+
+ zend_declare_class_constant_long(ice_version_ce, SL("PATCH"), 35 TSRMLS_CC);
+
+ zend_declare_class_constant_long(ice_version_ce, SL("STAGE"), 4 TSRMLS_CC);
+
+ zend_declare_class_constant_long(ice_version_ce, SL("BUILD"), 1 TSRMLS_CC);
+
return SUCCESS;
}
/**
- * Get array version of the framework.
+ * Get version array.
*
* @return array
*/
PHP_METHOD(Ice_Version, current) {
- array_init_size(return_value, 7);
+ zephir_create_array(return_value, 5, 0 TSRMLS_CC);
add_assoc_long_ex(return_value, SS("major"), 1);
add_assoc_long_ex(return_value, SS("minor"), 0);
- add_assoc_long_ex(return_value, SS("patch"), 6);
+ add_assoc_long_ex(return_value, SS("patch"), 35);
add_assoc_long_ex(return_value, SS("stage"), 4);
add_assoc_long_ex(return_value, SS("build"), 1);
return;
@@ -65,96 +76,110 @@ PHP_METHOD(Ice_Version, current) {
}
/**
- * Get version of the framework.
+ * Get version string.
*
* 1.0.0-dev
- * 1.0.0-alpha3
- * 1.0.0-beta2
- * 1.0.0-rc5
+ * 1.0.0-alpha.3
+ * 1.0.0-beta.2
+ * 1.0.0-rc.5
* 1.0.0
*
* @return string
*/
PHP_METHOD(Ice_Version, get) {
- int ZEPHIR_LAST_CALL_STATUS;
- zval *current = NULL, *suffix = NULL, *_0, *_1, *_2, *_3;
+ zval *_2 = NULL;
+ int _0;
+ zval *suffix = NULL, _1 = zval_used_for_init, _3, _4;
ZEPHIR_MM_GROW();
- ZEPHIR_CALL_SELF(¤t, "current", NULL);
- zephir_check_call_status();
- zephir_array_fetch_string(&_0, current, SL("stage"), PH_NOISY | PH_READONLY, "ice/version.zep", 56 TSRMLS_CC);
do {
- if (ZEPHIR_IS_LONG(_0, 0)) {
+ _0 = 4;
+ if (_0 == 0) {
ZEPHIR_INIT_VAR(suffix);
ZVAL_STRING(suffix, "-dev", 1);
break;
}
- if (ZEPHIR_IS_LONG(_0, 1)) {
- zephir_array_fetch_string(&_1, current, SL("build"), PH_NOISY | PH_READONLY, "ice/version.zep", 61 TSRMLS_CC);
- ZEPHIR_INIT_NVAR(suffix);
- ZEPHIR_CONCAT_SV(suffix, "-alpha", _1);
+ if (_0 == 1) {
+ ZEPHIR_SINIT_VAR(_1);
+ ZVAL_LONG(&_1, 1);
+ ZEPHIR_INIT_VAR(_2);
+ ZEPHIR_CONCAT_SV(_2, "-alpha.", &_1);
+ ZEPHIR_CPY_WRT(suffix, _2);
break;
}
- if (ZEPHIR_IS_LONG(_0, 2)) {
- zephir_array_fetch_string(&_1, current, SL("build"), PH_NOISY | PH_READONLY, "ice/version.zep", 64 TSRMLS_CC);
- ZEPHIR_INIT_NVAR(suffix);
- ZEPHIR_CONCAT_SV(suffix, "-beta", _1);
+ if (_0 == 2) {
+ ZEPHIR_SINIT_NVAR(_1);
+ ZVAL_LONG(&_1, 1);
+ ZEPHIR_INIT_LNVAR(_2);
+ ZEPHIR_CONCAT_SV(_2, "-beta.", &_1);
+ ZEPHIR_CPY_WRT(suffix, _2);
break;
}
- if (ZEPHIR_IS_LONG(_0, 3)) {
- zephir_array_fetch_string(&_1, current, SL("build"), PH_NOISY | PH_READONLY, "ice/version.zep", 67 TSRMLS_CC);
- ZEPHIR_INIT_NVAR(suffix);
- ZEPHIR_CONCAT_SV(suffix, "-RC", _1);
+ if (_0 == 3) {
+ ZEPHIR_SINIT_NVAR(_1);
+ ZVAL_LONG(&_1, 1);
+ ZEPHIR_INIT_LNVAR(_2);
+ ZEPHIR_CONCAT_SV(_2, "-rc.", &_1);
+ ZEPHIR_CPY_WRT(suffix, _2);
break;
}
- if (ZEPHIR_IS_LONG(_0, 4)) {
+ if (_0 == 4) {
ZEPHIR_INIT_NVAR(suffix);
ZVAL_STRING(suffix, "", 1);
break;
}
} while(0);
- zephir_array_fetch_string(&_1, current, SL("major"), PH_NOISY | PH_READONLY, "ice/version.zep", 74 TSRMLS_CC);
- zephir_array_fetch_string(&_2, current, SL("minor"), PH_NOISY | PH_READONLY, "ice/version.zep", 74 TSRMLS_CC);
- zephir_array_fetch_string(&_3, current, SL("patch"), PH_NOISY | PH_READONLY, "ice/version.zep", 74 TSRMLS_CC);
- ZEPHIR_CONCAT_VSVSVV(return_value, _1, ".", _2, ".", _3, suffix);
+ ZEPHIR_SINIT_NVAR(_1);
+ ZVAL_LONG(&_1, 1);
+ ZEPHIR_SINIT_VAR(_3);
+ ZVAL_LONG(&_3, 0);
+ ZEPHIR_SINIT_VAR(_4);
+ ZVAL_LONG(&_4, 35);
+ ZEPHIR_CONCAT_VSVSVV(return_value, &_1, ".", &_3, ".", &_4, suffix);
RETURN_MM();
}
/**
- * Get version id of the framework.
- * [major][minor(2 digits)][patch (2 digits)][stage][build], eg. id for 1.4.2-rc5 is 1040235
+ * Get version id.
*
- * @return string
+ * [major][minor(2 digits)][patch (2 digits)][stage][build]
+ * eg. id for 1.4.12-rc.5 is 1041235
+ *
+ * @return int
*/
PHP_METHOD(Ice_Version, id) {
- zephir_nts_static zephir_fcall_cache_entry *_4 = NULL;
int ZEPHIR_LAST_CALL_STATUS;
- zval *current = NULL, *_0, *_1, _2 = zval_used_for_init, *_3 = NULL, *_5, *_6 = NULL, *_7, *_8;
+ zephir_fcall_cache_entry *_4 = NULL;
+ zval *id = NULL, _0, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3 = NULL, *_5 = NULL;
ZEPHIR_MM_GROW();
- ZEPHIR_CALL_SELF(¤t, "current", NULL);
- zephir_check_call_status();
- zephir_array_fetch_string(&_0, current, SL("major"), PH_NOISY | PH_READONLY, "ice/version.zep", 89 TSRMLS_CC);
- zephir_array_fetch_string(&_1, current, SL("minor"), PH_NOISY | PH_READONLY, "ice/version.zep", 89 TSRMLS_CC);
+ ZEPHIR_SINIT_VAR(_0);
+ ZVAL_LONG(&_0, 1);
+ ZEPHIR_SINIT_VAR(_1);
+ ZVAL_STRING(&_1, "%02s", 0);
ZEPHIR_SINIT_VAR(_2);
- ZVAL_STRING(&_2, "%02s", 0);
- ZEPHIR_CALL_FUNCTION(&_3, "sprintf", &_4, &_2, _1);
+ ZVAL_LONG(&_2, 0);
+ ZEPHIR_CALL_FUNCTION(&_3, "sprintf", &_4, 1, &_1, &_2);
zephir_check_call_status();
- zephir_array_fetch_string(&_5, current, SL("patch"), PH_NOISY | PH_READONLY, "ice/version.zep", 89 TSRMLS_CC);
+ ZEPHIR_SINIT_NVAR(_1);
+ ZVAL_STRING(&_1, "%02s", 0);
ZEPHIR_SINIT_NVAR(_2);
- ZVAL_STRING(&_2, "%02s", 0);
- ZEPHIR_CALL_FUNCTION(&_6, "sprintf", &_4, &_2, _5);
+ ZVAL_LONG(&_2, 35);
+ ZEPHIR_CALL_FUNCTION(&_5, "sprintf", &_4, 1, &_1, &_2);
zephir_check_call_status();
- zephir_array_fetch_string(&_7, current, SL("stage"), PH_NOISY | PH_READONLY, "ice/version.zep", 89 TSRMLS_CC);
- zephir_array_fetch_string(&_8, current, SL("build"), PH_NOISY | PH_READONLY, "ice/version.zep", 89 TSRMLS_CC);
- ZEPHIR_CONCAT_VVVVV(return_value, _0, _3, _6, _7, _8);
- RETURN_MM();
+ ZEPHIR_SINIT_NVAR(_1);
+ ZVAL_LONG(&_1, 4);
+ ZEPHIR_SINIT_NVAR(_2);
+ ZVAL_LONG(&_2, 1);
+ ZEPHIR_INIT_VAR(id);
+ ZEPHIR_CONCAT_VVVVV(id, &_0, _3, _5, &_1, &_2);
+ RETURN_MM_LONG(zephir_get_intval(id));
}
diff --git a/ext/ice/version.zep.h b/ext/ice/version.zep.h
index b11f9c8c..98f659d3 100644
--- a/ext/ice/version.zep.h
+++ b/ext/ice/version.zep.h
@@ -11,5 +11,5 @@ ZEPHIR_INIT_FUNCS(ice_version_method_entry) {
PHP_ME(Ice_Version, current, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Ice_Version, get, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(Ice_Version, id, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- PHP_FE_END
+ PHP_FE_END
};
diff --git a/ext/kernel/array.c b/ext/kernel/array.c
index 9501abe0..db05a502 100644
--- a/ext/kernel/array.c
+++ b/ext/kernel/array.c
@@ -1136,22 +1136,24 @@ void zephir_array_unshift(zval *arr, zval *arg TSRMLS_DC)
{
if (likely(Z_TYPE_P(arr) == IS_ARRAY)) {
- HashTable oldhash;
zval** args[1] = { &arg };
- HashTable *newhash = Z_ARRVAL_P(arr);
-
#if PHP_VERSION_ID < 50600
+ HashTable oldhash;
+ HashTable *newhash = Z_ARRVAL_P(arr);
newhash = php_splice(newhash, 0, 0, args, 1, NULL);
- #else
- php_splice(newhash, 0, 0, args, 1, NULL TSRMLS_CC);
- #endif
- oldhash = *Z_ARRVAL_P(arr);
- *Z_ARRVAL_P(arr) = *newhash;
+ oldhash = *Z_ARRVAL_P(arr);
+ if (Z_ARRVAL_P(arr) == &EG(symbol_table)) {
+ zend_reset_all_cv(&EG(symbol_table) TSRMLS_CC);
+ }
+ *Z_ARRVAL_P(arr) = *newhash;
- FREE_HASHTABLE(newhash);
- zend_hash_destroy(&oldhash);
+ FREE_HASHTABLE(newhash);
+ zend_hash_destroy(&oldhash);
+ #else
+ php_splice(Z_ARRVAL_P(arr), 0, 0, args, 1, NULL TSRMLS_CC);
+ #endif
}
}
@@ -1263,29 +1265,17 @@ int zephir_array_is_associative(zval *arr) {
}
/**
- * Multiple array-offset update
+ * Implementation of Multiple array-offset update
*/
-int zephir_array_update_multi(zval **arr, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...)
+void zephir_array_update_multi_ex(zval **arr, zval **value, const char *types, int types_length, int types_count, va_list ap TSRMLS_DC)
{
- va_list ap;
long old_l[ZEPHIR_MAX_ARRAY_LEVELS], old_ll[ZEPHIR_MAX_ARRAY_LEVELS];
char *s, *old_s[ZEPHIR_MAX_ARRAY_LEVELS], old_type[ZEPHIR_MAX_ARRAY_LEVELS];
zval *fetched, *tmp, *p, *item, *old_item[ZEPHIR_MAX_ARRAY_LEVELS], *old_p[ZEPHIR_MAX_ARRAY_LEVELS];
int i, j, l, ll, re_update, must_continue, wrap_tmp;
- va_start(ap, types_count);
-
assert(types_length < ZEPHIR_MAX_ARRAY_LEVELS);
- SEPARATE_ZVAL_IF_NOT_REF(arr);
-
-/*
- memset(old_type, '\0', ZEPHIR_MAX_ARRAY_LEVELS);
- memset(old_s, '\0', ZEPHIR_MAX_ARRAY_LEVELS);
- memset(old_p, '\0', ZEPHIR_MAX_ARRAY_LEVELS);
- memset(old_item, '\0', ZEPHIR_MAX_ARRAY_LEVELS);
-*/
-
p = *arr;
for (i = 0; i < types_length; ++i) {
@@ -1459,7 +1449,54 @@ int zephir_array_update_multi(zval **arr, zval **value TSRMLS_DC, const char *ty
old_type[i] = types[i];
}
}
+}
+
+int zephir_array_update_multi(zval **arr, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...)
+{
+ va_list ap;
+
+ va_start(ap, types_count);
+ SEPARATE_ZVAL_IF_NOT_REF(arr);
+
+/*
+ memset(old_type, '\0', ZEPHIR_MAX_ARRAY_LEVELS);
+ memset(old_s, '\0', ZEPHIR_MAX_ARRAY_LEVELS);
+ memset(old_p, '\0', ZEPHIR_MAX_ARRAY_LEVELS);
+ memset(old_item, '\0', ZEPHIR_MAX_ARRAY_LEVELS);
+*/
+
+ zephir_array_update_multi_ex(arr, value, types, types_length, types_count, ap TSRMLS_CC);
va_end(ap);
return 0;
}
+
+void ZEPHIR_FASTCALL zephir_create_array(zval *return_value, uint size, int initialize TSRMLS_DC) {
+
+ uint i;
+ zval *null_value;
+ HashTable *hashTable;
+
+ if (size > 0) {
+
+ hashTable = (HashTable *) emalloc(sizeof(HashTable));
+ zephir_hash_init(hashTable, size, NULL, ZVAL_PTR_DTOR, 0);
+
+ if (initialize) {
+
+ MAKE_STD_ZVAL(null_value);
+ ZVAL_NULL(null_value);
+ Z_SET_REFCOUNT_P(null_value, size);
+
+ for (i = 0; i < size; i++) {
+ zend_hash_next_index_insert(hashTable, &null_value, sizeof(zval *), NULL);
+ }
+ }
+
+ Z_ARRVAL_P(return_value) = hashTable;
+ Z_TYPE_P(return_value) = IS_ARRAY;
+
+ } else {
+ array_init(return_value);
+ }
+}
diff --git a/ext/kernel/array.h b/ext/kernel/array.h
index f8075192..40af9c63 100644
--- a/ext/kernel/array.h
+++ b/ext/kernel/array.h
@@ -22,6 +22,11 @@
#define ZEPHIR_KERNEL_ARRAY_H
#define ZEPHIR_MAX_ARRAY_LEVELS 16
+#include
+#include
+#include "kernel/globals.h"
+#include "kernel/main.h"
+
/** Combined isset/fetch */
int zephir_array_isset_fetch(zval **fetched, const zval *arr, zval *index, int readonly TSRMLS_DC);
int zephir_array_isset_quick_string_fetch(zval **fetched, zval *arr, char *index, uint index_length, unsigned long key, int readonly TSRMLS_DC);
@@ -78,8 +83,11 @@ void zephir_array_values(zval *return_value, zval *arr);
int zephir_array_key_exists(zval *arr, zval *key TSRMLS_DC);
int zephir_array_is_associative(zval *arr);
+void zephir_array_update_multi_ex(zval **arr, zval **value, const char *types, int types_length, int types_count, va_list ap TSRMLS_DC);
int zephir_array_update_multi(zval **arr, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...);
+void ZEPHIR_FASTCALL zephir_create_array(zval *return_value, uint size, int initialize TSRMLS_DC);
+
#define zephir_array_fast_append(arr, value) \
Z_ADDREF_P(value); \
zend_hash_next_index_insert(Z_ARRVAL_P(arr), &value, sizeof(zval *), NULL);
diff --git a/ext/kernel/array.h.gch b/ext/kernel/array.h.gch
new file mode 100644
index 00000000..56515a78
Binary files /dev/null and b/ext/kernel/array.h.gch differ
diff --git a/ext/kernel/assert.h b/ext/kernel/assert.h
index d7c7fe43..9b04961a 100644
--- a/ext/kernel/assert.h
+++ b/ext/kernel/assert.h
@@ -22,6 +22,9 @@
#ifndef ZEPHIR_RELEASE
+#include
+#include
+
extern int zephir_assert_class(zval *object, char *class_name TSRMLS_DC);
#endif
diff --git a/ext/kernel/assert.h.gch b/ext/kernel/assert.h.gch
new file mode 100644
index 00000000..f6afcb9f
Binary files /dev/null and b/ext/kernel/assert.h.gch differ
diff --git a/ext/kernel/backtrace.c b/ext/kernel/backtrace.c
index d706e365..b11a5ca7 100644
--- a/ext/kernel/backtrace.c
+++ b/ext/kernel/backtrace.c
@@ -19,7 +19,7 @@
*/
#ifndef ZEPHIR_RELEASE
-#if defined(linux)
+#if defined(linux) || defined(DARWIN) || defined(__APPLE__)
#include
#include
diff --git a/ext/kernel/backtrace.h.gch b/ext/kernel/backtrace.h.gch
new file mode 100644
index 00000000..ea6f16fe
Binary files /dev/null and b/ext/kernel/backtrace.h.gch differ
diff --git a/ext/kernel/concat.c b/ext/kernel/concat.c
index ab9bf394..f778f3f9 100644
--- a/ext/kernel/concat.c
+++ b/ext/kernel/concat.c
@@ -3,15 +3,52 @@
#include "config.h"
#endif
-#include "php.h"
+#include
#include "php_ext.h"
-#include "ext/standard/php_string.h"
+#include
#include "ext.h"
#include "kernel/main.h"
#include "kernel/memory.h"
#include "kernel/concat.h"
+void zephir_concat_sss(zval **result, const char *op1, zend_uint op1_len, const char *op2, zend_uint op2_len, const char *op3, zend_uint op3_len, int self_var TSRMLS_DC){
+
+ zval result_copy;
+ int use_copy = 0;
+ uint offset = 0, length;
+
+ length = op1_len + op2_len + op3_len;
+ if (self_var) {
+
+ if (Z_TYPE_PP(result) != IS_STRING) {
+ zend_make_printable_zval(*result, &result_copy, &use_copy);
+ if (use_copy) {
+ ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy));
+ }
+ }
+
+ offset = Z_STRLEN_PP(result);
+ length += offset;
+ Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1);
+
+ } else {
+ Z_STRVAL_PP(result) = (char *) emalloc(length + 1);
+ }
+
+ memcpy(Z_STRVAL_PP(result) + offset, op1, op1_len);
+ memcpy(Z_STRVAL_PP(result) + offset + op1_len, op2, op2_len);
+ memcpy(Z_STRVAL_PP(result) + offset + op1_len + op2_len, op3, op3_len);
+ Z_STRVAL_PP(result)[length] = 0;
+ Z_TYPE_PP(result) = IS_STRING;
+ Z_STRLEN_PP(result) = length;
+
+ if (use_copy) {
+ zval_dtor(&result_copy);
+ }
+
+}
+
void zephir_concat_sv(zval **result, const char *op1, zend_uint op1_len, zval *op2, int self_var TSRMLS_DC){
zval result_copy, op2_copy;
@@ -757,6 +794,202 @@ void zephir_concat_vsvsv(zval **result, zval *op1, const char *op2, zend_uint op
}
+void zephir_concat_vsvsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, zval *op7, int self_var TSRMLS_DC){
+
+ zval result_copy, op1_copy, op3_copy, op5_copy, op7_copy;
+ int use_copy = 0, use_copy1 = 0, use_copy3 = 0, use_copy5 = 0, use_copy7 = 0;
+ uint offset = 0, length;
+
+ if (Z_TYPE_P(op1) != IS_STRING) {
+ zend_make_printable_zval(op1, &op1_copy, &use_copy1);
+ if (use_copy1) {
+ op1 = &op1_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op3) != IS_STRING) {
+ zend_make_printable_zval(op3, &op3_copy, &use_copy3);
+ if (use_copy3) {
+ op3 = &op3_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op5) != IS_STRING) {
+ zend_make_printable_zval(op5, &op5_copy, &use_copy5);
+ if (use_copy5) {
+ op5 = &op5_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op7) != IS_STRING) {
+ zend_make_printable_zval(op7, &op7_copy, &use_copy7);
+ if (use_copy7) {
+ op7 = &op7_copy;
+ }
+ }
+
+ length = Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7);
+ if (self_var) {
+
+ if (Z_TYPE_PP(result) != IS_STRING) {
+ zend_make_printable_zval(*result, &result_copy, &use_copy);
+ if (use_copy) {
+ ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy));
+ }
+ }
+
+ offset = Z_STRLEN_PP(result);
+ length += offset;
+ Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1);
+
+ } else {
+ Z_STRVAL_PP(result) = (char *) emalloc(length + 1);
+ }
+
+ memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len);
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3), op4, op4_len);
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len, Z_STRVAL_P(op5), Z_STRLEN_P(op5));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5), op6, op6_len);
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len, Z_STRVAL_P(op7), Z_STRLEN_P(op7));
+ Z_STRVAL_PP(result)[length] = 0;
+ Z_TYPE_PP(result) = IS_STRING;
+ Z_STRLEN_PP(result) = length;
+
+ if (use_copy1) {
+ zval_dtor(op1);
+ }
+
+ if (use_copy3) {
+ zval_dtor(op3);
+ }
+
+ if (use_copy5) {
+ zval_dtor(op5);
+ }
+
+ if (use_copy7) {
+ zval_dtor(op7);
+ }
+
+ if (use_copy) {
+ zval_dtor(&result_copy);
+ }
+
+}
+
+void zephir_concat_vsvsvsvsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, zval *op7, const char *op8, zend_uint op8_len, zval *op9, const char *op10, zend_uint op10_len, zval *op11, int self_var TSRMLS_DC){
+
+ zval result_copy, op1_copy, op3_copy, op5_copy, op7_copy, op9_copy, op11_copy;
+ int use_copy = 0, use_copy1 = 0, use_copy3 = 0, use_copy5 = 0, use_copy7 = 0, use_copy9 = 0, use_copy11 = 0;
+ uint offset = 0, length;
+
+ if (Z_TYPE_P(op1) != IS_STRING) {
+ zend_make_printable_zval(op1, &op1_copy, &use_copy1);
+ if (use_copy1) {
+ op1 = &op1_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op3) != IS_STRING) {
+ zend_make_printable_zval(op3, &op3_copy, &use_copy3);
+ if (use_copy3) {
+ op3 = &op3_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op5) != IS_STRING) {
+ zend_make_printable_zval(op5, &op5_copy, &use_copy5);
+ if (use_copy5) {
+ op5 = &op5_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op7) != IS_STRING) {
+ zend_make_printable_zval(op7, &op7_copy, &use_copy7);
+ if (use_copy7) {
+ op7 = &op7_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op9) != IS_STRING) {
+ zend_make_printable_zval(op9, &op9_copy, &use_copy9);
+ if (use_copy9) {
+ op9 = &op9_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op11) != IS_STRING) {
+ zend_make_printable_zval(op11, &op11_copy, &use_copy11);
+ if (use_copy11) {
+ op11 = &op11_copy;
+ }
+ }
+
+ length = Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7) + op8_len + Z_STRLEN_P(op9) + op10_len + Z_STRLEN_P(op11);
+ if (self_var) {
+
+ if (Z_TYPE_PP(result) != IS_STRING) {
+ zend_make_printable_zval(*result, &result_copy, &use_copy);
+ if (use_copy) {
+ ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy));
+ }
+ }
+
+ offset = Z_STRLEN_PP(result);
+ length += offset;
+ Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1);
+
+ } else {
+ Z_STRVAL_PP(result) = (char *) emalloc(length + 1);
+ }
+
+ memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len);
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3), op4, op4_len);
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len, Z_STRVAL_P(op5), Z_STRLEN_P(op5));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5), op6, op6_len);
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len, Z_STRVAL_P(op7), Z_STRLEN_P(op7));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7), op8, op8_len);
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7) + op8_len, Z_STRVAL_P(op9), Z_STRLEN_P(op9));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7) + op8_len + Z_STRLEN_P(op9), op10, op10_len);
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5) + op6_len + Z_STRLEN_P(op7) + op8_len + Z_STRLEN_P(op9) + op10_len, Z_STRVAL_P(op11), Z_STRLEN_P(op11));
+ Z_STRVAL_PP(result)[length] = 0;
+ Z_TYPE_PP(result) = IS_STRING;
+ Z_STRLEN_PP(result) = length;
+
+ if (use_copy1) {
+ zval_dtor(op1);
+ }
+
+ if (use_copy3) {
+ zval_dtor(op3);
+ }
+
+ if (use_copy5) {
+ zval_dtor(op5);
+ }
+
+ if (use_copy7) {
+ zval_dtor(op7);
+ }
+
+ if (use_copy9) {
+ zval_dtor(op9);
+ }
+
+ if (use_copy11) {
+ zval_dtor(op11);
+ }
+
+ if (use_copy) {
+ zval_dtor(&result_copy);
+ }
+
+}
+
void zephir_concat_vsvsvv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, zval *op6, int self_var TSRMLS_DC){
zval result_copy, op1_copy, op3_copy, op5_copy, op6_copy;
@@ -1242,6 +1475,89 @@ void zephir_concat_vvvs(zval **result, zval *op1, zval *op2, zval *op3, const ch
}
+void zephir_concat_vvvsv(zval **result, zval *op1, zval *op2, zval *op3, const char *op4, zend_uint op4_len, zval *op5, int self_var TSRMLS_DC){
+
+ zval result_copy, op1_copy, op2_copy, op3_copy, op5_copy;
+ int use_copy = 0, use_copy1 = 0, use_copy2 = 0, use_copy3 = 0, use_copy5 = 0;
+ uint offset = 0, length;
+
+ if (Z_TYPE_P(op1) != IS_STRING) {
+ zend_make_printable_zval(op1, &op1_copy, &use_copy1);
+ if (use_copy1) {
+ op1 = &op1_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op2) != IS_STRING) {
+ zend_make_printable_zval(op2, &op2_copy, &use_copy2);
+ if (use_copy2) {
+ op2 = &op2_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op3) != IS_STRING) {
+ zend_make_printable_zval(op3, &op3_copy, &use_copy3);
+ if (use_copy3) {
+ op3 = &op3_copy;
+ }
+ }
+
+ if (Z_TYPE_P(op5) != IS_STRING) {
+ zend_make_printable_zval(op5, &op5_copy, &use_copy5);
+ if (use_copy5) {
+ op5 = &op5_copy;
+ }
+ }
+
+ length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5);
+ if (self_var) {
+
+ if (Z_TYPE_PP(result) != IS_STRING) {
+ zend_make_printable_zval(*result, &result_copy, &use_copy);
+ if (use_copy) {
+ ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy));
+ }
+ }
+
+ offset = Z_STRLEN_PP(result);
+ length += offset;
+ Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1);
+
+ } else {
+ Z_STRVAL_PP(result) = (char *) emalloc(length + 1);
+ }
+
+ memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2), Z_STRVAL_P(op3), Z_STRLEN_P(op3));
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3), op4, op4_len);
+ memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + op4_len, Z_STRVAL_P(op5), Z_STRLEN_P(op5));
+ Z_STRVAL_PP(result)[length] = 0;
+ Z_TYPE_PP(result) = IS_STRING;
+ Z_STRLEN_PP(result) = length;
+
+ if (use_copy1) {
+ zval_dtor(op1);
+ }
+
+ if (use_copy2) {
+ zval_dtor(op2);
+ }
+
+ if (use_copy3) {
+ zval_dtor(op3);
+ }
+
+ if (use_copy5) {
+ zval_dtor(op5);
+ }
+
+ if (use_copy) {
+ zval_dtor(&result_copy);
+ }
+
+}
+
void zephir_concat_vvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, int self_var TSRMLS_DC){
zval result_copy, op1_copy, op2_copy, op3_copy, op4_copy;
diff --git a/ext/kernel/concat.h b/ext/kernel/concat.h
index c16378d4..d6d1198e 100644
--- a/ext/kernel/concat.h
+++ b/ext/kernel/concat.h
@@ -1,3 +1,17 @@
+
+#ifndef ZEPHIR_KERNEL_CONCAT_H
+#define ZEPHIR_KERNEL_CONCAT_H
+
+#include
+#include
+
+#include "kernel/main.h"
+
+#define ZEPHIR_CONCAT_SSS(result, op1, op2, op3) \
+ zephir_concat_sss(&result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, sizeof(op3)-1, 0 TSRMLS_CC);
+#define ZEPHIR_SCONCAT_SSS(result, op1, op2, op3) \
+ zephir_concat_sss(&result, op1, sizeof(op1)-1, op2, sizeof(op2)-1, op3, sizeof(op3)-1, 1 TSRMLS_CC);
+
#define ZEPHIR_CONCAT_SV(result, op1, op2) \
zephir_concat_sv(&result, op1, sizeof(op1)-1, op2, 0 TSRMLS_CC);
#define ZEPHIR_SCONCAT_SV(result, op1, op2) \
@@ -58,6 +72,16 @@
#define ZEPHIR_SCONCAT_VSVSV(result, op1, op2, op3, op4, op5) \
zephir_concat_vsvsv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, 1 TSRMLS_CC);
+#define ZEPHIR_CONCAT_VSVSVSV(result, op1, op2, op3, op4, op5, op6, op7) \
+ zephir_concat_vsvsvsv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, op7, 0 TSRMLS_CC);
+#define ZEPHIR_SCONCAT_VSVSVSV(result, op1, op2, op3, op4, op5, op6, op7) \
+ zephir_concat_vsvsvsv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, op7, 1 TSRMLS_CC);
+
+#define ZEPHIR_CONCAT_VSVSVSVSVSV(result, op1, op2, op3, op4, op5, op6, op7, op8, op9, op10, op11) \
+ zephir_concat_vsvsvsvsvsv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, op7, op8, sizeof(op8)-1, op9, op10, sizeof(op10)-1, op11, 0 TSRMLS_CC);
+#define ZEPHIR_SCONCAT_VSVSVSVSVSV(result, op1, op2, op3, op4, op5, op6, op7, op8, op9, op10, op11) \
+ zephir_concat_vsvsvsvsvsv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, sizeof(op6)-1, op7, op8, sizeof(op8)-1, op9, op10, sizeof(op10)-1, op11, 1 TSRMLS_CC);
+
#define ZEPHIR_CONCAT_VSVSVV(result, op1, op2, op3, op4, op5, op6) \
zephir_concat_vsvsvv(&result, op1, op2, sizeof(op2)-1, op3, op4, sizeof(op4)-1, op5, op6, 0 TSRMLS_CC);
#define ZEPHIR_SCONCAT_VSVSVV(result, op1, op2, op3, op4, op5, op6) \
@@ -93,6 +117,11 @@
#define ZEPHIR_SCONCAT_VVVS(result, op1, op2, op3, op4) \
zephir_concat_vvvs(&result, op1, op2, op3, op4, sizeof(op4)-1, 1 TSRMLS_CC);
+#define ZEPHIR_CONCAT_VVVSV(result, op1, op2, op3, op4, op5) \
+ zephir_concat_vvvsv(&result, op1, op2, op3, op4, sizeof(op4)-1, op5, 0 TSRMLS_CC);
+#define ZEPHIR_SCONCAT_VVVSV(result, op1, op2, op3, op4, op5) \
+ zephir_concat_vvvsv(&result, op1, op2, op3, op4, sizeof(op4)-1, op5, 1 TSRMLS_CC);
+
#define ZEPHIR_CONCAT_VVVV(result, op1, op2, op3, op4) \
zephir_concat_vvvv(&result, op1, op2, op3, op4, 0 TSRMLS_CC);
#define ZEPHIR_SCONCAT_VVVV(result, op1, op2, op3, op4) \
@@ -104,6 +133,7 @@
zephir_concat_vvvvv(&result, op1, op2, op3, op4, op5, 1 TSRMLS_CC);
+void zephir_concat_sss(zval **result, const char *op1, zend_uint op1_len, const char *op2, zend_uint op2_len, const char *op3, zend_uint op3_len, int self_var TSRMLS_DC);
void zephir_concat_sv(zval **result, const char *op1, zend_uint op1_len, zval *op2, int self_var TSRMLS_DC);
void zephir_concat_svs(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, int self_var TSRMLS_DC);
void zephir_concat_svsv(zval **result, const char *op1, zend_uint op1_len, zval *op2, const char *op3, zend_uint op3_len, zval *op4, int self_var TSRMLS_DC);
@@ -116,6 +146,8 @@ void zephir_concat_vs(zval **result, zval *op1, const char *op2, zend_uint op2_l
void zephir_concat_vsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, int self_var TSRMLS_DC);
void zephir_concat_vsvs(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, int self_var TSRMLS_DC);
void zephir_concat_vsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, int self_var TSRMLS_DC);
+void zephir_concat_vsvsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, zval *op7, int self_var TSRMLS_DC);
+void zephir_concat_vsvsvsvsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, zval *op7, const char *op8, zend_uint op8_len, zval *op9, const char *op10, zend_uint op10_len, zval *op11, int self_var TSRMLS_DC);
void zephir_concat_vsvsvv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, zval *op6, int self_var TSRMLS_DC);
void zephir_concat_vsvv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, zval *op4, int self_var TSRMLS_DC);
void zephir_concat_vsvvs(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, zval *op4, const char *op5, zend_uint op5_len, int self_var TSRMLS_DC);
@@ -123,6 +155,10 @@ void zephir_concat_vv(zval **result, zval *op1, zval *op2, int self_var TSRMLS_D
void zephir_concat_vvs(zval **result, zval *op1, zval *op2, const char *op3, zend_uint op3_len, int self_var TSRMLS_DC);
void zephir_concat_vvv(zval **result, zval *op1, zval *op2, zval *op3, int self_var TSRMLS_DC);
void zephir_concat_vvvs(zval **result, zval *op1, zval *op2, zval *op3, const char *op4, zend_uint op4_len, int self_var TSRMLS_DC);
+void zephir_concat_vvvsv(zval **result, zval *op1, zval *op2, zval *op3, const char *op4, zend_uint op4_len, zval *op5, int self_var TSRMLS_DC);
void zephir_concat_vvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, int self_var TSRMLS_DC);
void zephir_concat_vvvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, zval *op5, int self_var TSRMLS_DC);
-void zephir_concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
\ No newline at end of file
+void zephir_concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
+
+#endif /* ZEPHIR_KERNEL_CONCAT_H */
+
diff --git a/ext/kernel/concat.h.gch b/ext/kernel/concat.h.gch
new file mode 100644
index 00000000..6694bdd9
Binary files /dev/null and b/ext/kernel/concat.h.gch differ
diff --git a/ext/kernel/debug.h b/ext/kernel/debug.h
index a1ce0b41..ed40cd46 100644
--- a/ext/kernel/debug.h
+++ b/ext/kernel/debug.h
@@ -17,8 +17,13 @@
+------------------------------------------------------------------------+
*/
+#ifndef ZEPHIR_KERNEL_DEBUG_H
+#define ZEPHIR_KERNEL_DEBUG_H
+
#ifndef ZEPHIR_RELEASE
+#include
+
#define PHV(v) zephir_vdump(v)
#define PHPR(v) zephir_print_r(v)
@@ -60,3 +65,4 @@ int zephir_error_space();
int zephir_debug_space();
#endif
+#endif
\ No newline at end of file
diff --git a/ext/kernel/debug.h.gch b/ext/kernel/debug.h.gch
new file mode 100644
index 00000000..fc189155
Binary files /dev/null and b/ext/kernel/debug.h.gch differ
diff --git a/ext/kernel/exception.c b/ext/kernel/exception.c
index 3397d96e..8662a12f 100644
--- a/ext/kernel/exception.c
+++ b/ext/kernel/exception.c
@@ -45,28 +45,37 @@ void zephir_throw_exception(zval *object TSRMLS_DC){
/**
* Throws a zval object as exception
*/
-void zephir_throw_exception_debug(zval *object, const char *file, zend_uint line TSRMLS_DC){
+void zephir_throw_exception_debug(zval *object, const char *file, zend_uint line TSRMLS_DC) {
zend_class_entry *default_exception_ce;
int ZEPHIR_LAST_CALL_STATUS = 0;
- zval *curline = NULL;
+ zval *curline = NULL, *object_copy = NULL;
ZEPHIR_MM_GROW();
+ if (Z_TYPE_P(object) != IS_OBJECT) {
+ object_copy = object;
+ ALLOC_INIT_ZVAL(object);
+ object_init_ex(object, zend_exception_get_default(TSRMLS_C));
+ ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, object_copy);
+ }
+
Z_ADDREF_P(object);
if (line > 0) {
curline = 0;
- ZEPHIR_CALL_METHOD(&curline, object, "getline", NULL);
+ ZEPHIR_CALL_METHOD(&curline, object, "getline", NULL, 0);
zephir_check_call_status();
if (ZEPHIR_IS_LONG(curline, 0)) {
default_exception_ce = zend_exception_get_default(TSRMLS_C);
- zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, file TSRMLS_CC);
- zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, line TSRMLS_CC);
+ zend_update_property_string(default_exception_ce, object, "file", sizeof("file") - 1, file TSRMLS_CC);
+ zend_update_property_long(default_exception_ce, object, "line", sizeof("line") - 1, line TSRMLS_CC);
}
}
- zend_throw_exception_object(object TSRMLS_CC);
+ if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
+ zend_throw_exception_object(object TSRMLS_CC);
+ }
ZEPHIR_MM_RESTORE();
}
@@ -85,8 +94,7 @@ void zephir_throw_exception_string_debug(zend_class_entry *ce, const char *messa
ALLOC_INIT_ZVAL(msg);
ZVAL_STRINGL(msg, message, message_len, 1);
- ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, msg);
- zephir_check_call_status();
+ ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, msg);
if (line > 0) {
default_exception_ce = zend_exception_get_default(TSRMLS_C);
@@ -94,7 +102,9 @@ void zephir_throw_exception_string_debug(zend_class_entry *ce, const char *messa
zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, line TSRMLS_CC);
}
- zend_throw_exception_object(object TSRMLS_CC);
+ if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
+ zend_throw_exception_object(object TSRMLS_CC);
+ }
zval_ptr_dtor(&msg);
}
@@ -113,10 +123,11 @@ void zephir_throw_exception_string(zend_class_entry *ce, const char *message, ze
ALLOC_INIT_ZVAL(msg);
ZVAL_STRINGL(msg, message, message_len, 1);
- ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, msg);
- zephir_check_call_status();
+ ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, msg);
- zend_throw_exception_object(object TSRMLS_CC);
+ if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
+ zend_throw_exception_object(object TSRMLS_CC);
+ }
zval_ptr_dtor(&msg);
}
@@ -141,10 +152,11 @@ void zephir_throw_exception_format(zend_class_entry *ce TSRMLS_DC, const char *f
ALLOC_INIT_ZVAL(msg);
ZVAL_STRINGL(msg, buffer, len, 0);
- ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, msg);
- zephir_check_call_status();
+ ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, msg);
- zend_throw_exception_object(object TSRMLS_CC);
+ if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
+ zend_throw_exception_object(object TSRMLS_CC);
+ }
zval_ptr_dtor(&msg);
}
@@ -161,8 +173,7 @@ void zephir_throw_exception_zval_debug(zend_class_entry *ce, zval *message, cons
ALLOC_INIT_ZVAL(object);
object_init_ex(object, ce);
- ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, message);
- zephir_check_call_status();
+ ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, message);
if (line > 0) {
default_exception_ce = zend_exception_get_default(TSRMLS_C);
@@ -170,7 +181,9 @@ void zephir_throw_exception_zval_debug(zend_class_entry *ce, zval *message, cons
zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, line TSRMLS_CC);
}
- zend_throw_exception_object(object TSRMLS_CC);
+ if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
+ zend_throw_exception_object(object TSRMLS_CC);
+ }
}
/**
@@ -184,9 +197,9 @@ void zephir_throw_exception_zval(zend_class_entry *ce, zval *message TSRMLS_DC){
ALLOC_INIT_ZVAL(object);
object_init_ex(object, ce);
- ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, message);
- zephir_check_call_status();
+ ZEPHIR_CALL_METHOD(NULL, object, "__construct", NULL, 0, message);
- zend_throw_exception_object(object TSRMLS_CC);
+ if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {
+ zend_throw_exception_object(object TSRMLS_CC);
+ }
}
-
diff --git a/ext/kernel/exception.h b/ext/kernel/exception.h
index fc96456f..115481ae 100644
--- a/ext/kernel/exception.h
+++ b/ext/kernel/exception.h
@@ -21,7 +21,8 @@
#ifndef ZEPHIR_KERNEL_EXCEPTIONS_H
#define ZEPHIR_KERNEL_EXCEPTIONS_H
-#include "Zend/zend.h"
+#include
+#include "kernel/main.h"
/** Exceptions */
#define ZEPHIR_THROW_EXCEPTION_STR(class_entry, message) \
@@ -62,6 +63,5 @@ void zephir_throw_exception_string(zend_class_entry *ce, const char *message, ze
void zephir_throw_exception_zval(zend_class_entry *ce, zval *message TSRMLS_DC);
void zephir_throw_exception_zval_debug(zend_class_entry *ce, zval *message, const char *file, zend_uint line TSRMLS_DC);
void zephir_throw_exception_format(zend_class_entry *ce TSRMLS_DC, const char *format, ...);
-void zephir_throw_exception_internal(zval *exception TSRMLS_DC);
#endif /* ZEPHIR_KERNEL_EXCEPTIONS_H */
diff --git a/ext/kernel/exception.h.gch b/ext/kernel/exception.h.gch
new file mode 100644
index 00000000..1684352d
Binary files /dev/null and b/ext/kernel/exception.h.gch differ
diff --git a/ext/kernel/exit.h.gch b/ext/kernel/exit.h.gch
new file mode 100644
index 00000000..132dfbb2
Binary files /dev/null and b/ext/kernel/exit.h.gch differ
diff --git a/ext/kernel/extended/fcall.c b/ext/kernel/extended/fcall.c
new file mode 100644
index 00000000..d95c7395
--- /dev/null
+++ b/ext/kernel/extended/fcall.c
@@ -0,0 +1,1374 @@
+
+/*
+ +------------------------------------------------------------------------+
+ | Zephir Language |
+ +------------------------------------------------------------------------+
+ | Copyright (c) 2011-2015 Zephir Team (http://www.zephir-lang.com) |
+ +------------------------------------------------------------------------+
+ | This source file is subject to the New BSD License that is bundled |
+ | with this package in the file docs/LICENSE.txt. |
+ | |
+ | If you did not receive a copy of the license and are unable to |
+ | obtain it through the world-wide-web, please send an email |
+ | to license@zephir-lang.com so we can send you a copy immediately. |
+ +------------------------------------------------------------------------+
+ | Authors: Andres Gutierrez |
+ +------------------------------------------------------------------------+
+*/
+
+#include
+#include "php_ext.h"
+
+#include
+#include
+#include
+
+#include "kernel/main.h"
+#include "kernel/fcall.h"
+#include "kernel/memory.h"
+#include "kernel/hash.h"
+#include "kernel/string.h"
+#include "kernel/operators.h"
+#include "kernel/exception.h"
+#include "kernel/backtrace.h"
+
+#if PHP_VERSION_ID >= 50600
+
+#if ZEND_MODULE_API_NO >= 20141001
+void zephir_clean_and_cache_symbol_table(zend_array *symbol_table)
+{
+ if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
+ zend_array_destroy(symbol_table);
+ } else {
+ zend_symtable_clean(symbol_table);
+ *(++EG(symtable_cache_ptr)) = symbol_table;
+ }
+}
+#else
+void zephir_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC)
+{
+ if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
+ zend_hash_destroy(symbol_table);
+ FREE_HASHTABLE(symbol_table);
+ } else {
+ zend_hash_clean(symbol_table);
+ *(++EG(symtable_cache_ptr)) = symbol_table;
+ }
+}
+#endif
+
+/**
+ * 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_func_aparams_fast(zval **return_value_ptr, zephir_fcall_cache_entry **cache_entry, zend_uint param_count, zval *pparams[] 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;
+ zend_execute_data execute_data;
+ zval ***params, ***params_array = NULL;
+ zval **static_params_array[10];
+ zend_class_entry *old_scope = EG(scope);
+ zend_function_state *function_state = &EX(function_state);
+ zend_function *func;
+ zval *rv = NULL, **retval_ptr_ptr = return_value_ptr ? return_value_ptr : &rv;
+
+ if (retval_ptr_ptr && *retval_ptr_ptr) {
+ zval_ptr_dtor(retval_ptr_ptr);
+ *retval_ptr_ptr = NULL;
+ }
+
+ if (param_count) {
+
+ if (UNEXPECTED(param_count > 10)) {
+ params_array = (zval***) emalloc(param_count * sizeof(zval**));
+ params = params_array;
+ for (i = 0; i < param_count; ++i) {
+ params_array[i] = &pparams[i];
+ }
+ } else {
+ params = static_params_array;
+ for (i = 0; i < param_count; ++i) {
+ static_params_array[i] = &pparams[i];
+ }
+ }
+ } else {
+ params = NULL;
+ }
+
+ if (!EG(active)) {
+ return FAILURE; /* executor is already inactive */
+ }
+
+ if (EG(exception)) {
+ return FAILURE; /* we would result in an instable executor otherwise */
+ }
+
+ /* 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));
+ }
+
+#ifndef ZEPHIR_RELEASE
+ function_state->function = (*cache_entry)->f;
+ ++(*cache_entry)->times;
+#else
+ function_state->function = *cache_entry;
+#endif
+ func = function_state->function;
+
+ calling_scope = NULL;
+ called_scope = NULL;
+ EX(object) = NULL;
+
+ ZEND_VM_STACK_GROW_IF_NEEDED(param_count + 1);
+
+ for (i = 0; i < param_count; i++) {
+ zval *param;
+
+ if (ARG_SHOULD_BE_SENT_BY_REF(func, i + 1)) {
+ if (!PZVAL_IS_REF(*params[i]) && Z_REFCOUNT_PP(params[i]) > 1) {
+ zval *new_zval;
+
+ if (!ARG_MAY_BE_SENT_BY_REF(func, 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((void *) (zend_uintptr_t)i TSRMLS_CC);
+ zend_vm_stack_clear_multiple(0 TSRMLS_CC);
+ }
+
+ zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
+ i+1,
+ func->common.scope ? func->common.scope->name : "",
+ func->common.scope ? "::" : "",
+ func->common.function_name);
+ return FAILURE;
+ }
+
+ ALLOC_ZVAL(new_zval);
+ *new_zval = **params[i];
+ zval_copy_ctor(new_zval);
+ Z_SET_REFCOUNT_P(new_zval, 1);
+ Z_DELREF_PP(params[i]);
+ *params[i] = new_zval;
+ }
+ Z_ADDREF_PP(params[i]);
+ Z_SET_ISREF_PP(params[i]);
+ param = *params[i];
+ } else if (PZVAL_IS_REF(*params[i]) && (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 ) {
+ ALLOC_ZVAL(param);
+ *param = **(params[i]);
+ INIT_PZVAL(param);
+ zval_copy_ctor(param);
+ } else if (*params[i] != &EG(uninitialized_zval)) {
+ Z_ADDREF_PP(params[i]);
+ param = *params[i];
+ } else {
+ ALLOC_ZVAL(param);
+ *param = **(params[i]);
+ INIT_PZVAL(param);
+ }
+ zend_vm_stack_push(param TSRMLS_CC);
+ }
+
+ function_state->arguments = zend_vm_stack_top(TSRMLS_C);
+ zend_vm_stack_push((void*)(zend_uintptr_t)param_count TSRMLS_CC);
+
+ current_scope = EG(scope);
+ EG(scope) = calling_scope;
+
+ current_called_scope = EG(called_scope);
+ if (called_scope) {
+ EG(called_scope) = called_scope;
+ } else if (func->type != ZEND_INTERNAL_FUNCTION) {
+ EG(called_scope) = NULL;
+ }
+
+ EX(prev_execute_data) = EG(current_execute_data);
+ EG(current_execute_data) = &execute_data;
+
+ if (func->type == ZEND_USER_FUNCTION) {
+
+ calling_symbol_table = EG(active_symbol_table);
+ EG(scope) = func->common.scope;
+ 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) = retval_ptr_ptr;
+ EG(active_op_array) = (zend_op_array *) function_state->function;
+ original_opline_ptr = EG(opline_ptr);
+
+ zend_execute(EG(active_op_array) TSRMLS_CC);
+
+ if (EG(active_symbol_table)) {
+ zephir_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC);
+ }
+ 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 (func->type == ZEND_INTERNAL_FUNCTION) {
+
+ ALLOC_INIT_ZVAL(*retval_ptr_ptr);
+ if (func->common.scope) {
+ EG(scope) = func->common.scope;
+ }
+
+ func->internal_function.handler(param_count, *retval_ptr_ptr, retval_ptr_ptr, NULL, 1 TSRMLS_CC);
+
+ if (EG(exception) && retval_ptr_ptr) {
+ zval_ptr_dtor(retval_ptr_ptr);
+ *retval_ptr_ptr = NULL;
+ }
+
+ } else { /* ZEND_OVERLOADED_FUNCTION */
+ ALLOC_INIT_ZVAL(*retval_ptr_ptr);
+
+ /* Not sure what should be done here if it's a static method */
+ zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
+
+ if (func->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
+ efree((char*)func->common.function_name);
+ }
+ efree(function_state->function);
+
+ if (EG(exception) && retval_ptr_ptr) {
+ zval_ptr_dtor(retval_ptr_ptr);
+ *retval_ptr_ptr = NULL;
+ }
+ }
+ zend_vm_stack_clear_multiple(0 TSRMLS_CC);
+
+ EG(called_scope) = current_called_scope;
+ EG(scope) = current_scope;
+ EG(current_execute_data) = EX(prev_execute_data);
+
+ if (EG(exception)) {
+ zephir_throw_exception_internal(NULL TSRMLS_CC);
+ }
+
+ EG(scope) = old_scope;
+
+ if (UNEXPECTED(params_array != NULL)) {
+ efree(params_array);
+ }
+
+ if (rv) {
+ zval_ptr_dtor(&rv);
+ }
+
+ return SUCCESS;
+}
+
+static int zephir_is_callable_check_class(const char *name, int name_len, zend_fcall_info_cache *fcc, int *strict_class, char **error TSRMLS_DC) /* {{{ */
+{
+ int ret = 0;
+ zend_class_entry **pce;
+ char *lcname = zend_str_tolower_dup(name, name_len);
+
+ *strict_class = 0;
+ if (name_len == sizeof("self") - 1 &&
+ !memcmp(lcname, "self", sizeof("self") - 1)) {
+ if (!EG(scope)) {
+ if (error) *error = estrdup("cannot access self:: when no class scope is active");
+ } else {
+ fcc->called_scope = EG(called_scope);
+ fcc->calling_scope = EG(scope);
+ if (!fcc->object_ptr) {
+ fcc->object_ptr = EG(This);
+ }
+ ret = 1;
+ }
+ } else if (name_len == sizeof("parent") - 1 &&
+ !memcmp(lcname, "parent", sizeof("parent") - 1)) {
+ if (!EG(scope)) {
+ if (error) *error = estrdup("cannot access parent:: when no class scope is active");
+ } else if (!EG(scope)->parent) {
+ if (error) *error = estrdup("cannot access parent:: when current class scope has no parent");
+ } else {
+ fcc->called_scope = EG(called_scope);
+ fcc->calling_scope = EG(scope)->parent;
+ if (!fcc->object_ptr) {
+ fcc->object_ptr = EG(This);
+ }
+ *strict_class = 1;
+ ret = 1;
+ }
+ } else if (name_len == sizeof("static") - 1 &&
+ !memcmp(lcname, "static", sizeof("static") - 1)) {
+ if (!EG(called_scope)) {
+ if (error) *error = estrdup("cannot access static:: when no class scope is active");
+ } else {
+ fcc->called_scope = EG(called_scope);
+ fcc->calling_scope = EG(called_scope);
+ if (!fcc->object_ptr) {
+ fcc->object_ptr = EG(This);
+ }
+ *strict_class = 1;
+ ret = 1;
+ }
+ } else if (zend_lookup_class_ex(name, name_len, NULL, 1, &pce TSRMLS_CC) == SUCCESS) {
+ zend_class_entry *scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL;
+
+ fcc->calling_scope = *pce;
+ if (scope && !fcc->object_ptr && EG(This) &&
+ instanceof_function(Z_OBJCE_P(EG(This)), scope TSRMLS_CC) &&
+ instanceof_function(scope, fcc->calling_scope TSRMLS_CC)) {
+ fcc->object_ptr = EG(This);
+ fcc->called_scope = Z_OBJCE_P(fcc->object_ptr);
+ } else {
+ fcc->called_scope = fcc->object_ptr ? Z_OBJCE_P(fcc->object_ptr) : fcc->calling_scope;
+ }
+ *strict_class = 1;
+ ret = 1;
+ } else {
+ if (error) zephir_spprintf(error, 0, "class '%.*s' not found", name_len, name);
+ }
+ efree(lcname);
+ return ret;
+}
+
+static int zephir_is_callable_check_func(int check_flags, zval *callable, zend_fcall_info_cache *fcc, int strict_class, char **error TSRMLS_DC) /* {{{ */
+{
+ zend_class_entry *ce_org = fcc->calling_scope;
+ int retval = 0;
+ char *mname, *lmname;
+ const char *colon;
+ int clen, mlen;
+ zend_class_entry *last_scope;
+ HashTable *ftable;
+ int call_via_handler = 0;
+
+ if (error) {
+ *error = NULL;
+ }
+
+ fcc->calling_scope = NULL;
+ fcc->function_handler = NULL;
+
+ if (!ce_org) {
+ /* Skip leading \ */
+ if (Z_STRVAL_P(callable)[0] == '\\') {
+ mlen = Z_STRLEN_P(callable) - 1;
+ lmname = zend_str_tolower_dup(Z_STRVAL_P(callable) + 1, mlen);
+ } else {
+ mlen = Z_STRLEN_P(callable);
+ lmname = zend_str_tolower_dup(Z_STRVAL_P(callable), mlen);
+ }
+ /* Check if function with given name exists.
+ * This may be a compound name that includes namespace name */
+ if (zend_hash_find(EG(function_table), lmname, mlen+1, (void**)&fcc->function_handler) == SUCCESS) {
+ efree(lmname);
+ return 1;
+ }
+ efree(lmname);
+ }
+
+ /* Split name into class/namespace and method/function names */
+ if ((colon = zend_memrchr(Z_STRVAL_P(callable), ':', Z_STRLEN_P(callable))) != NULL &&
+ colon > Z_STRVAL_P(callable) &&
+ *(colon-1) == ':'
+ ) {
+ colon--;
+ clen = colon - Z_STRVAL_P(callable);
+ mlen = Z_STRLEN_P(callable) - clen - 2;
+
+ if (colon == Z_STRVAL_P(callable)) {
+ if (error) zephir_spprintf(error, 0, "invalid function name");
+ return 0;
+ }
+
+ /* This is a compound name.
+ * Try to fetch class and then find static method. */
+ last_scope = EG(scope);
+ if (ce_org) {
+ EG(scope) = ce_org;
+ }
+
+ if (!zephir_is_callable_check_class(Z_STRVAL_P(callable), clen, fcc, &strict_class, error TSRMLS_CC)) {
+ EG(scope) = last_scope;
+ return 0;
+ }
+ EG(scope) = last_scope;
+
+ ftable = &fcc->calling_scope->function_table;
+ if (ce_org && !instanceof_function(ce_org, fcc->calling_scope TSRMLS_CC)) {
+ if (error) zephir_spprintf(error, 0, "class '%s' is not a subclass of '%s'", ce_org->name, fcc->calling_scope->name);
+ return 0;
+ }
+ mname = Z_STRVAL_P(callable) + clen + 2;
+ } else if (ce_org) {
+ /* Try to fetch find static method of given class. */
+ mlen = Z_STRLEN_P(callable);
+ mname = Z_STRVAL_P(callable);
+ ftable = &ce_org->function_table;
+ fcc->calling_scope = ce_org;
+ } else {
+ /* We already checked for plain function before. */
+ if (error && !(check_flags & IS_CALLABLE_CHECK_SILENT)) {
+ zephir_spprintf(error, 0, "function '%s' not found or invalid function name", Z_STRVAL_P(callable));
+ }
+ return 0;
+ }
+
+ lmname = zend_str_tolower_dup(mname, mlen);
+ if (strict_class &&
+ fcc->calling_scope &&
+ mlen == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1 &&
+ !memcmp(lmname, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME) - 1)) {
+ fcc->function_handler = fcc->calling_scope->constructor;
+ if (fcc->function_handler) {
+ retval = 1;
+ }
+ } else if (zend_hash_find(ftable, lmname, mlen+1, (void**)&fcc->function_handler) == SUCCESS) {
+ retval = 1;
+ if ((fcc->function_handler->op_array.fn_flags & ZEND_ACC_CHANGED) &&
+ !strict_class && EG(scope) &&
+ instanceof_function(fcc->function_handler->common.scope, EG(scope) TSRMLS_CC)) {
+ zend_function *priv_fbc;
+
+ if (zend_hash_find(&EG(scope)->function_table, lmname, mlen+1, (void **) &priv_fbc)==SUCCESS
+ && priv_fbc->common.fn_flags & ZEND_ACC_PRIVATE
+ && priv_fbc->common.scope == EG(scope)) {
+ fcc->function_handler = priv_fbc;
+ }
+ }
+ } else {
+ if (fcc->object_ptr && fcc->calling_scope == ce_org) {
+ if (strict_class && ce_org->__call) {
+ fcc->function_handler = emalloc(sizeof(zend_internal_function));
+ fcc->function_handler->internal_function.type = ZEND_INTERNAL_FUNCTION;
+ fcc->function_handler->internal_function.module = (ce_org->type == ZEND_INTERNAL_CLASS) ? ce_org->info.internal.module : NULL;
+ fcc->function_handler->internal_function.handler = zend_std_call_user_call;
+ fcc->function_handler->internal_function.arg_info = NULL;
+ fcc->function_handler->internal_function.num_args = 0;
+ fcc->function_handler->internal_function.scope = ce_org;
+ fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
+ fcc->function_handler->internal_function.function_name = estrndup(mname, mlen);
+ call_via_handler = 1;
+ retval = 1;
+ } else if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) {
+ fcc->function_handler = Z_OBJ_HT_P(fcc->object_ptr)->get_method(&fcc->object_ptr, mname, mlen, NULL TSRMLS_CC);
+ if (fcc->function_handler) {
+ if (strict_class &&
+ (!fcc->function_handler->common.scope ||
+ !instanceof_function(ce_org, fcc->function_handler->common.scope TSRMLS_CC))) {
+ if ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ } else {
+ retval = 1;
+ call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
+ }
+ }
+ }
+ } else if (fcc->calling_scope) {
+ if (fcc->calling_scope->get_static_method) {
+ fcc->function_handler = fcc->calling_scope->get_static_method(fcc->calling_scope, mname, mlen TSRMLS_CC);
+ } else {
+ fcc->function_handler = zend_std_get_static_method(fcc->calling_scope, mname, mlen, NULL TSRMLS_CC);
+ }
+ if (fcc->function_handler) {
+ retval = 1;
+ call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
+ if (call_via_handler && !fcc->object_ptr && EG(This) &&
+ Z_OBJ_HT_P(EG(This))->get_class_entry &&
+ instanceof_function(Z_OBJCE_P(EG(This)), fcc->calling_scope TSRMLS_CC)) {
+ fcc->object_ptr = EG(This);
+ }
+ }
+ }
+ }
+
+ if (retval) {
+ if (fcc->calling_scope && !call_via_handler) {
+ if (!fcc->object_ptr && (fcc->function_handler->common.fn_flags & ZEND_ACC_ABSTRACT)) {
+ if (error) {
+ zephir_spprintf(error, 0, "cannot call abstract method %s::%s()", fcc->calling_scope->name, fcc->function_handler->common.function_name);
+ retval = 0;
+ } else {
+ zend_error(E_ERROR, "Cannot call abstract method %s::%s()", fcc->calling_scope->name, fcc->function_handler->common.function_name);
+ }
+ } else if (!fcc->object_ptr && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) {
+ int severity;
+ char *verb;
+ if (fcc->function_handler->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+ severity = E_STRICT;
+ verb = "should not";
+ } else {
+ /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+ severity = E_ERROR;
+ verb = "cannot";
+ }
+ if ((check_flags & IS_CALLABLE_CHECK_IS_STATIC) != 0) {
+ retval = 0;
+ }
+ if (EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), fcc->calling_scope TSRMLS_CC)) {
+ fcc->object_ptr = EG(This);
+ if (error) {
+ zephir_spprintf(error, 0, "non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name, fcc->function_handler->common.function_name, verb, Z_OBJCE_P(EG(This))->name);
+ if (severity == E_ERROR) {
+ retval = 0;
+ }
+ } else if (retval) {
+ zend_error(severity, "Non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name, fcc->function_handler->common.function_name, verb, Z_OBJCE_P(EG(This))->name);
+ }
+ } else {
+ if (error) {
+ zephir_spprintf(error, 0, "non-static method %s::%s() %s be called statically", fcc->calling_scope->name, fcc->function_handler->common.function_name, verb);
+ if (severity == E_ERROR) {
+ retval = 0;
+ }
+ } else if (retval) {
+ zend_error(severity, "Non-static method %s::%s() %s be called statically", fcc->calling_scope->name, fcc->function_handler->common.function_name, verb);
+ }
+ }
+ }
+ }
+ } else if (error && !(check_flags & IS_CALLABLE_CHECK_SILENT)) {
+ if (fcc->calling_scope) {
+ if (error) zephir_spprintf(error, 0, "class '%s' does not have a method '%s'", fcc->calling_scope->name, mname);
+ } else {
+ if (error) zephir_spprintf(error, 0, "function '%s' does not exist", mname);
+ }
+ }
+ efree(lmname);
+
+ if (fcc->object_ptr) {
+ fcc->called_scope = Z_OBJCE_P(fcc->object_ptr);
+ }
+ if (retval) {
+ fcc->initialized = 1;
+ }
+ return retval;
+}
+
+static zend_bool zephir_is_callable_ex(zval *callable, zval *object_ptr, uint check_flags, char **callable_name, int *callable_name_len, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */
+{
+ zend_bool ret;
+ int callable_name_len_local;
+ zend_fcall_info_cache fcc_local;
+
+ if (callable_name) {
+ *callable_name = NULL;
+ }
+ if (callable_name_len == NULL) {
+ callable_name_len = &callable_name_len_local;
+ }
+ if (fcc == NULL) {
+ fcc = &fcc_local;
+ }
+ if (error) {
+ *error = NULL;
+ }
+
+ fcc->initialized = 0;
+ fcc->calling_scope = NULL;
+ fcc->called_scope = NULL;
+ fcc->function_handler = NULL;
+ fcc->object_ptr = NULL;
+
+ if (object_ptr && Z_TYPE_P(object_ptr) != IS_OBJECT) {
+ object_ptr = NULL;
+ }
+ if (object_ptr &&
+ (!EG(objects_store).object_buckets ||
+ !EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(object_ptr)].valid)) {
+ return 0;
+ }
+
+ switch (Z_TYPE_P(callable)) {
+
+ case IS_STRING:
+ if (object_ptr) {
+ fcc->object_ptr = object_ptr;
+ fcc->calling_scope = Z_OBJCE_P(object_ptr);
+ if (callable_name) {
+ char *ptr;
+
+ *callable_name_len = fcc->calling_scope->name_length + Z_STRLEN_P(callable) + sizeof("::") - 1;
+ ptr = *callable_name = emalloc(*callable_name_len + 1);
+ memcpy(ptr, fcc->calling_scope->name, fcc->calling_scope->name_length);
+ ptr += fcc->calling_scope->name_length;
+ memcpy(ptr, "::", sizeof("::") - 1);
+ ptr += sizeof("::") - 1;
+ memcpy(ptr, Z_STRVAL_P(callable), Z_STRLEN_P(callable) + 1);
+ }
+ } else if (callable_name) {
+ *callable_name = estrndup(Z_STRVAL_P(callable), Z_STRLEN_P(callable));
+ *callable_name_len = Z_STRLEN_P(callable);
+ }
+ if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
+ fcc->called_scope = fcc->calling_scope;
+ return 1;
+ }
+
+ ret = zephir_is_callable_check_func(check_flags, callable, fcc, 0, error TSRMLS_CC);
+ if (fcc == &fcc_local &&
+ fcc->function_handler &&
+ ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
+ (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ return ret;
+
+ case IS_ARRAY:
+ {
+ zval **method = NULL;
+ zval **obj = NULL;
+ int strict_class = 0;
+
+ if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2) {
+ zend_hash_index_find(Z_ARRVAL_P(callable), 0, (void **) &obj);
+ zend_hash_index_find(Z_ARRVAL_P(callable), 1, (void **) &method);
+ }
+ if (obj && method &&
+ (Z_TYPE_PP(obj) == IS_OBJECT ||
+ Z_TYPE_PP(obj) == IS_STRING) &&
+ Z_TYPE_PP(method) == IS_STRING) {
+
+ if (Z_TYPE_PP(obj) == IS_STRING) {
+ if (callable_name) {
+ char *ptr;
+
+ *callable_name_len = Z_STRLEN_PP(obj) + Z_STRLEN_PP(method) + sizeof("::") - 1;
+ ptr = *callable_name = emalloc(*callable_name_len + 1);
+ memcpy(ptr, Z_STRVAL_PP(obj), Z_STRLEN_PP(obj));
+ ptr += Z_STRLEN_PP(obj);
+ memcpy(ptr, "::", sizeof("::") - 1);
+ ptr += sizeof("::") - 1;
+ memcpy(ptr, Z_STRVAL_PP(method), Z_STRLEN_PP(method) + 1);
+ }
+
+ if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
+ return 1;
+ }
+
+ if (!zephir_is_callable_check_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), fcc, &strict_class, error TSRMLS_CC)) {
+ return 0;
+ }
+
+ } else {
+ if (!EG(objects_store).object_buckets ||
+ !EG(objects_store).object_buckets[Z_OBJ_HANDLE_PP(obj)].valid) {
+ return 0;
+ }
+
+ fcc->calling_scope = Z_OBJCE_PP(obj); /* TBFixed: what if it's overloaded? */
+
+ fcc->object_ptr = *obj;
+
+ if (callable_name) {
+ char *ptr;
+
+ *callable_name_len = fcc->calling_scope->name_length + Z_STRLEN_PP(method) + sizeof("::") - 1;
+ ptr = *callable_name = emalloc(*callable_name_len + 1);
+ memcpy(ptr, fcc->calling_scope->name, fcc->calling_scope->name_length);
+ ptr += fcc->calling_scope->name_length;
+ memcpy(ptr, "::", sizeof("::") - 1);
+ ptr += sizeof("::") - 1;
+ memcpy(ptr, Z_STRVAL_PP(method), Z_STRLEN_PP(method) + 1);
+ }
+
+ if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
+ fcc->called_scope = fcc->calling_scope;
+ return 1;
+ }
+ }
+
+ ret = zephir_is_callable_check_func(check_flags, *method, fcc, strict_class, error TSRMLS_CC);
+ if (fcc == &fcc_local &&
+ fcc->function_handler &&
+ ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
+ (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ return ret;
+
+ } else {
+ if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2) {
+ if (!obj || (Z_TYPE_PP(obj) != IS_STRING && Z_TYPE_PP(obj) != IS_OBJECT)) {
+ if (error) zephir_spprintf(error, 0, "first array member is not a valid class name or object");
+ } else {
+ if (error) zephir_spprintf(error, 0, "second array member is not a valid method");
+ }
+ } else {
+ if (error) zephir_spprintf(error, 0, "array must have exactly two members");
+ }
+ if (callable_name) {
+ *callable_name = estrndup("Array", sizeof("Array")-1);
+ *callable_name_len = sizeof("Array") - 1;
+ }
+ }
+ }
+ return 0;
+
+ case IS_OBJECT:
+ if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object_ptr TSRMLS_CC) == SUCCESS) {
+ fcc->called_scope = fcc->calling_scope;
+ if (callable_name) {
+ zend_class_entry *ce = Z_OBJCE_P(callable); /* TBFixed: what if it's overloaded? */
+
+ *callable_name_len = ce->name_length + sizeof("::__invoke") - 1;
+ *callable_name = emalloc(*callable_name_len + 1);
+ memcpy(*callable_name, ce->name, ce->name_length);
+ memcpy((*callable_name) + ce->name_length, "::__invoke", sizeof("::__invoke"));
+ }
+ return 1;
+ }
+ /* break missing intentionally */
+
+ default:
+ if (callable_name) {
+ zval expr_copy;
+ int use_copy;
+
+ zend_make_printable_zval(callable, &expr_copy, &use_copy);
+ *callable_name = estrndup(Z_STRVAL(expr_copy), Z_STRLEN(expr_copy));
+ *callable_name_len = Z_STRLEN(expr_copy);
+ zval_dtor(&expr_copy);
+ }
+ if (error) zephir_spprintf(error, 0, "no array or string given");
+ return 0;
+ }
+}
+
+static zend_bool zephir_is_info_dynamic_callable(zephir_fcall_info *info, zend_fcall_info_cache *fcc, zend_class_entry *ce_org, int strict_class TSRMLS_DC)
+{
+ int call_via_handler = 0, retval = 0;
+ char *lcname = zend_str_tolower_dup(info->func_name, info->func_length);
+
+ if (fcc->object_ptr && fcc->calling_scope == ce_org) {
+ if (strict_class && ce_org->__call) {
+ fcc->function_handler = emalloc(sizeof(zend_internal_function));
+ fcc->function_handler->internal_function.type = ZEND_INTERNAL_FUNCTION;
+ fcc->function_handler->internal_function.module = (ce_org->type == ZEND_INTERNAL_CLASS) ? ce_org->info.internal.module : NULL;
+ fcc->function_handler->internal_function.handler = zend_std_call_user_call;
+ fcc->function_handler->internal_function.arg_info = NULL;
+ fcc->function_handler->internal_function.num_args = 0;
+ fcc->function_handler->internal_function.scope = ce_org;
+ fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
+ fcc->function_handler->internal_function.function_name = estrndup(lcname, info->func_length);
+ call_via_handler = 1;
+ retval = 1;
+ } else if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) {
+ fcc->function_handler = Z_OBJ_HT_P(fcc->object_ptr)->get_method(&fcc->object_ptr, lcname, info->func_length, NULL TSRMLS_CC);
+ if (fcc->function_handler) {
+ if (strict_class &&
+ (!fcc->function_handler->common.scope ||
+ !instanceof_function(ce_org, fcc->function_handler->common.scope TSRMLS_CC))) {
+ if ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ } else {
+ call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
+ retval = 1;
+ }
+ }
+ }
+ } else if (fcc->calling_scope) {
+ if (fcc->calling_scope->get_static_method) {
+ fcc->function_handler = fcc->calling_scope->get_static_method(fcc->calling_scope, lcname, info->func_length TSRMLS_CC);
+ } else {
+ fcc->function_handler = zend_std_get_static_method(fcc->calling_scope, lcname, info->func_length, NULL TSRMLS_CC);
+ }
+ if (fcc->function_handler) {
+ call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
+ if (call_via_handler && !fcc->object_ptr && EG(This) &&
+ Z_OBJ_HT_P(EG(This))->get_class_entry &&
+ instanceof_function(Z_OBJCE_P(EG(This)), fcc->calling_scope TSRMLS_CC)) {
+ fcc->object_ptr = EG(This);
+ }
+ retval = 1;
+ }
+ }
+
+ efree(lcname);
+ return retval;
+}
+
+static zend_bool zephir_is_info_callable_ex(zephir_fcall_info *info, zend_fcall_info_cache *fcc TSRMLS_DC)
+{
+ int retval = 0;
+ zend_class_entry *ce_org = fcc->calling_scope;
+ zend_fcall_info_cache fcc_local;
+
+ if (fcc == NULL) {
+ fcc = &fcc_local;
+ }
+
+ fcc->initialized = 0;
+ fcc->calling_scope = NULL;
+ fcc->called_scope = NULL;
+ fcc->function_handler = NULL;
+ fcc->object_ptr = NULL;
+
+ switch (info->type) {
+
+ case ZEPHIR_FCALL_TYPE_FUNC:
+
+ if (zend_hash_find(EG(function_table), info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) {
+ if (fcc == &fcc_local &&
+ fcc->function_handler &&
+ ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
+ (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ fcc->initialized = 1;
+ return 1;
+ }
+ break;
+
+ case ZEPHIR_FCALL_TYPE_ZVAL_METHOD:
+
+ if (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(info->object_ptr)].valid) {
+ return 0;
+ }
+
+ fcc->calling_scope = Z_OBJCE_P(info->object_ptr); /* TBFixed: what if it's overloaded? */
+ fcc->called_scope = fcc->calling_scope;
+ fcc->object_ptr = info->object_ptr;
+ if (!ce_org) {
+ ce_org = fcc->calling_scope;
+ }
+
+ if (zend_hash_find(&info->ce->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) {
+ if (fcc == &fcc_local &&
+ fcc->function_handler &&
+ ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
+ (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ retval = 1;
+ }
+
+ if (!retval) {
+ retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 0 TSRMLS_CC);
+ }
+ break;
+
+ case ZEPHIR_FCALL_TYPE_CLASS_SELF_METHOD:
+
+ if (!EG(scope)) {
+ return 0; // cannot access self:: when no class scope is active
+ }
+
+ fcc->called_scope = EG(called_scope);
+ fcc->calling_scope = EG(scope);
+ if (!fcc->object_ptr) {
+ fcc->object_ptr = EG(This);
+ }
+
+ if (zend_hash_find(&fcc->calling_scope->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) {
+ if (fcc == &fcc_local &&
+ fcc->function_handler &&
+ ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
+ (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ retval = 1;
+ }
+
+ if (!retval) {
+ retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 0 TSRMLS_CC);
+ }
+ break;
+
+ case ZEPHIR_FCALL_TYPE_CLASS_PARENT_METHOD:
+
+ if (!EG(scope)) {
+ return 0; // cannot access parent:: when no class scope is active
+ }
+
+ if (!EG(scope)->parent) {
+ return 0; // cannot access parent:: when current class scope has no parent
+ }
+
+ fcc->called_scope = EG(called_scope);
+ fcc->calling_scope = EG(scope)->parent;
+ if (!fcc->object_ptr) {
+ fcc->object_ptr = EG(This);
+ }
+
+ if (zend_hash_find(&fcc->calling_scope->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) {
+ if (fcc == &fcc_local &&
+ fcc->function_handler &&
+ ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
+ (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ retval = 1;
+ }
+
+ if (!retval) {
+ retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 1 TSRMLS_CC);
+ }
+ break;
+
+ case ZEPHIR_FCALL_TYPE_CLASS_STATIC_METHOD:
+
+ if (!EG(called_scope)) {
+ return 0; // cannot access static:: when no class scope is active
+ }
+
+ fcc->called_scope = EG(called_scope);
+ fcc->calling_scope = EG(called_scope);
+ if (!fcc->object_ptr) {
+ fcc->object_ptr = EG(This);
+ }
+
+ if (zend_hash_find(&fcc->calling_scope->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) {
+ if (fcc == &fcc_local &&
+ fcc->function_handler &&
+ ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
+ (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ retval = 1;
+ }
+
+ if (!retval) {
+ retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 1 TSRMLS_CC);
+ }
+ break;
+
+ case ZEPHIR_FCALL_TYPE_CE_METHOD:
+ {
+ zend_class_entry *scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL;
+
+ fcc->calling_scope = info->ce;
+ if (scope && !fcc->object_ptr && EG(This) &&
+ instanceof_function(Z_OBJCE_P(EG(This)), scope TSRMLS_CC) &&
+ instanceof_function(scope, fcc->calling_scope TSRMLS_CC)) {
+ fcc->object_ptr = EG(This);
+ fcc->called_scope = Z_OBJCE_P(fcc->object_ptr);
+ } else {
+ fcc->called_scope = fcc->object_ptr ? Z_OBJCE_P(fcc->object_ptr) : fcc->calling_scope;
+ }
+
+ if (zend_hash_find(&fcc->calling_scope->function_table, info->func_name, info->func_length + 1, (void**)&fcc->function_handler) == SUCCESS) {
+ if (fcc == &fcc_local &&
+ fcc->function_handler &&
+ ((fcc->function_handler->type == ZEND_INTERNAL_FUNCTION &&
+ (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER)) ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
+ fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
+ if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
+ efree((char*)fcc->function_handler->common.function_name);
+ }
+ efree(fcc->function_handler);
+ }
+ retval = 1;
+ }
+
+ if (!retval) {
+ retval = zephir_is_info_dynamic_callable(info, fcc, ce_org, 1 TSRMLS_CC);
+ }
+ }
+ break;
+ }
+
+ if (fcc->object_ptr) {
+ fcc->called_scope = Z_OBJCE_P(fcc->object_ptr);
+ }
+ if (retval) {
+ fcc->initialized = 1;
+ }
+
+ return retval;
+}
+
+int zephir_call_function_opt(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zephir_fcall_info *info 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;
+ zend_fcall_info_cache fci_cache_local;
+ zend_uint fn_flags;
+
+ *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 */
+ }
+
+ /* 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) {
+ char *callable_name;
+ char *error = NULL;
+
+ if (!fci_cache) {
+ fci_cache = &fci_cache_local;
+ }
+
+ if (!info) {
+ if (!zephir_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) {
+ zend_error(E_STRICT, "%s", error);
+ efree(error);
+ }
+ }
+ efree(callable_name);
+ } else {
+ if (!zephir_is_info_callable_ex(info, fci_cache TSRMLS_CC)) {
+ return FAILURE;
+ }
+ }
+ }
+
+#ifndef ZEPHIR_RELEASE
+ /*fprintf(stderr, "initialized: %d\n", fci_cache->initialized);
+ if (fci_cache->function_handler) {
+ if (fci_cache->function_handler->type == ZEND_INTERNAL_FUNCTION) {
+ fprintf(stderr, "function handler: %s\n", fci_cache->function_handler->common.function_name);
+ } else {
+ fprintf(stderr, "function handler: %s\n", "unknown");
+ }
+ } else {
+ fprintf(stderr, "function handler: NONE\n");
+ }
+ if (fci_cache->calling_scope) {
+ fprintf(stderr, "real calling_scope: %s (%p)\n", fci_cache->calling_scope->name, fci_cache->calling_scope);
+ } else {
+ fprintf(stderr, "real calling_scope: NONE\n");
+ }
+ if (fci_cache->called_scope) {
+ fprintf(stderr, "real called_scope: %s (%p)\n", fci_cache->called_scope->name, fci_cache->called_scope);
+ } else {
+ fprintf(stderr, "real called_scope: NONE\n");
+ }*/
+#endif
+
+ 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;
+ }
+
+ fn_flags = EX(function_state).function->common.fn_flags;
+ if (fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
+ if (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);
+ }
+ if (fn_flags & ZEND_ACC_DEPRECATED) {
+ zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
+ 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);
+ }
+ }
+
+ ZEND_VM_STACK_GROW_IF_NEEDED(fci->param_count + 1);
+
+ for (i = 0; i < fci->param_count; i++) {
+ zval *param;
+
+ if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)) {
+ if (!PZVAL_IS_REF(*fci->params[i]) && 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((void *) (zend_uintptr_t)i TSRMLS_CC);
+ zend_vm_stack_clear_multiple(0 TSRMLS_CC);
+ }
+
+ 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 (PZVAL_IS_REF(*fci->params[i]) &&
+ /* don't separate references for __call */
+ (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 ) {
+ ALLOC_ZVAL(param);
+ *param = **(fci->params[i]);
+ INIT_PZVAL(param);
+ zval_copy_ctor(param);
+ } 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(param TSRMLS_CC);
+ }
+
+ EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C);
+ zend_vm_stack_push((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);
+
+ //if (EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) {
+ // *fci->retval_ptr_ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC);
+ //} else {
+ zend_execute(EG(active_op_array) TSRMLS_CC);
+ //}
+
+ if (!fci->symbol_table && EG(active_symbol_table)) {
+ zephir_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC);
+ }
+ 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;
+ }
+ if (EXPECTED(zend_execute_internal == NULL)) {
+ /* saves one function call if zend_execute_internal is not used */
+ EX(function_state).function->internal_function.handler(fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC);
+ } else {
+ zend_execute_internal(&execute_data, fci, 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 { /* ZEND_OVERLOADED_FUNCTION */
+ ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr);
+
+ /* Not sure what should be done here if it's a static method */
+ 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");
+ }
+
+ if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
+ efree((char*)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;
+ }
+ }
+ zend_vm_stack_clear_multiple(0 TSRMLS_CC);
+
+ 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
diff --git a/ext/kernel/extended/fcall.h b/ext/kernel/extended/fcall.h
new file mode 100644
index 00000000..aea5c85a
--- /dev/null
+++ b/ext/kernel/extended/fcall.h
@@ -0,0 +1,43 @@
+
+/*
+ +------------------------------------------------------------------------+
+ | Zephir Language |
+ +------------------------------------------------------------------------+
+ | Copyright (c) 2011-2015 Zephir Team (http://www.zephir-lang.com) |
+ +------------------------------------------------------------------------+
+ | This source file is subject to the New BSD License that is bundled |
+ | with this package in the file docs/LICENSE.txt. |
+ | |
+ | If you did not receive a copy of the license and are unable to |
+ | obtain it through the world-wide-web, please send an email |
+ | to license@zephir-lang.com so we can send you a copy immediately. |
+ +------------------------------------------------------------------------+
+ | Authors: Andres Gutierrez |
+ +------------------------------------------------------------------------+
+*/
+
+#ifndef ZEPHIR_KERNEL_FCALL_EXT_H
+#define ZEPHIR_KERNEL_FCALL_EXT_H
+
+#define ZEPHIR_FCALL_TYPE_UNKNOWN 0
+#define ZEPHIR_FCALL_TYPE_FUNC 1
+#define ZEPHIR_FCALL_TYPE_ZVAL_METHOD 2
+#define ZEPHIR_FCALL_TYPE_CLASS_PARENT_METHOD 3
+#define ZEPHIR_FCALL_TYPE_CLASS_SELF_METHOD 4
+#define ZEPHIR_FCALL_TYPE_CLASS_STATIC_METHOD 5
+#define ZEPHIR_FCALL_TYPE_CE_METHOD 6
+
+typedef struct _zephir_fcall_info {
+ int type;
+ zend_class_entry *ce;
+ zval *object_ptr;
+ const char *class_name;
+ int class_length;
+ const char *func_name;
+ int func_length;
+} zephir_fcall_info;
+
+int zephir_call_function_opt(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zephir_fcall_info *info TSRMLS_DC);
+int zephir_call_func_aparams_fast(zval **return_value_ptr, zephir_fcall_cache_entry **cache_entry, uint param_count, zval **params TSRMLS_DC);
+
+#endif
diff --git a/ext/kernel/fcall.c b/ext/kernel/fcall.c
index bf285a72..2076fc4b 100644
--- a/ext/kernel/fcall.c
+++ b/ext/kernel/fcall.c
@@ -27,6 +27,7 @@
#include "kernel/main.h"
#include "kernel/fcall.h"
+#include "kernel/extended/fcall.h"
#include "kernel/memory.h"
#include "kernel/hash.h"
#include "kernel/operators.h"
@@ -118,7 +119,7 @@ static char *zephir_fcall_possible_method(zend_class_entry *ce, const char *wron
ZVAL_STRING(&method_name, wrong_name, 0);
params[0] = &method_name;
- zephir_call_func_aparams(&right, SL("metaphone"), NULL, 1, params TSRMLS_CC);
+ zephir_call_func_aparams(&right, SL("metaphone"), NULL, 0, 1, params TSRMLS_CC);
methods = &ce->function_table;
zend_hash_internal_pointer_reset_ex(methods, &pos);
@@ -134,7 +135,7 @@ static char *zephir_fcall_possible_method(zend_class_entry *ce, const char *wron
left = NULL;
params[0] = &method_name;
- zephir_call_func_aparams(&left, SL("metaphone"), NULL, 1, params TSRMLS_CC);
+ zephir_call_func_aparams(&left, SL("metaphone"), NULL, 0, 1, params TSRMLS_CC);
if (zephir_is_equal(left, right TSRMLS_CC)) {
possible_method = (char *) method->common.function_name;
@@ -196,12 +197,13 @@ static ulong zephir_make_fcall_key(char **result, size_t *length, const zend_cla
if (Z_TYPE_P(function_name) == IS_STRING) {
l = (size_t)(Z_STRLEN_P(function_name)) + 1;
c = Z_STRVAL_P(function_name);
- len = 2 * ppzce_size + l;
- buf = ecalloc(1, len);
+ len = 2 * ppzce_size + l + 1;
+ buf = emalloc(len);
memcpy(buf, c, l);
memcpy(buf + l, &calling_scope, ppzce_size);
memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size);
+ buf[len - 1] = '\0';
}
else if (Z_TYPE_P(function_name) == IS_ARRAY) {
zval **method;
@@ -213,24 +215,120 @@ static ulong zephir_make_fcall_key(char **result, size_t *length, const zend_cla
) {
l = (size_t)(Z_STRLEN_PP(method)) + 1;
c = Z_STRVAL_PP(method);
- len = 2 * ppzce_size + l;
- buf = ecalloc(1, len);
+ len = 2 * ppzce_size + l + 1;
+ buf = emalloc(len);
memcpy(buf, c, l);
memcpy(buf + l, &calling_scope, ppzce_size);
memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size);
+ buf[len - 1] = '\0';
}
}
- else if (Z_TYPE_P(function_name) == IS_OBJECT) {
- /*if (Z_OBJ_HANDLER_P(function_name, get_closure)) {
- l = sizeof("__invoke");
- len = 2 * ppzce_size + l;
- buf = ecalloc(1, len);
- memcpy(buf, "__invoke", l);
- memcpy(buf + l, &calling_scope, ppzce_size);
- memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size);
- }*/
+ if (EXPECTED(buf != NULL)) {
+ size_t i;
+
+ 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;
+ }
+
+ for (i = l; i < len; ++i) {
+ char c = buf[i];
+ hash = (hash << 5) + hash + c;
+ }
+ }
+
+ *result = buf;
+ *length = len;
+ return hash;
+}
+
+/**
+ * Creates a unique key to cache the current method/function call address for the current scope
+ */
+static ulong zephir_make_fcall_info_key(char **result, size_t *length, const zend_class_entry *obj_ce, zephir_call_type type, zephir_fcall_info *info TSRMLS_DC)
+{
+ const zend_class_entry *calling_scope = EG(scope);
+ char *buf = NULL, *c;
+ size_t l = 0, len = 0;
+ const size_t ppzce_size = sizeof(zend_class_entry**);
+ ulong hash = 5381;
+
+ *result = NULL;
+ *length = 0;
+
+ if (calling_scope && type == zephir_fcall_parent) {
+ calling_scope = calling_scope->parent;
+ if (UNEXPECTED(!calling_scope)) {
+ return 0;
+ }
+ }
+ else if (type == zephir_fcall_static) {
+ calling_scope = EG(called_scope);
+ if (UNEXPECTED(!calling_scope)) {
+ return 0;
+ }
+ }
+
+ if (
+ calling_scope
+ && obj_ce
+ && calling_scope != obj_ce
+ && !instanceof_function(obj_ce, calling_scope TSRMLS_CC)
+ && !instanceof_function(calling_scope, obj_ce TSRMLS_CC)
+ ) {
+ calling_scope = NULL;
+ }
+
+ switch (info->type) {
+
+ case ZEPHIR_FCALL_TYPE_FUNC:
+
+ l = (size_t)(info->func_length) + 1;
+ c = (char*) info->func_name;
+ len = 2 * ppzce_size + l + 1;
+ buf = emalloc(len);
+
+ memcpy(buf, c, l);
+ memcpy(buf + l, &calling_scope, ppzce_size);
+ memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size);
+ buf[len - 1] = '\0';
+ break;
+
+ case ZEPHIR_FCALL_TYPE_CLASS_SELF_METHOD:
+ case ZEPHIR_FCALL_TYPE_CLASS_STATIC_METHOD:
+ case ZEPHIR_FCALL_TYPE_CLASS_PARENT_METHOD:
+ l = (size_t)(info->func_length) + 2; /* reserve 1 char for fcall-type */
+ c = (char*) info->func_name;
+ len = 2 * ppzce_size + l + 1;
+ buf = emalloc(len);
+
+ buf[0] = info->type;
+ memcpy(buf + 1, c, l - 1);
+ memcpy(buf + l, &calling_scope, ppzce_size);
+ memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size);
+ buf[len - 1] = '\0';
+ break;
+
+ case ZEPHIR_FCALL_TYPE_CE_METHOD:
+ case ZEPHIR_FCALL_TYPE_ZVAL_METHOD:
+ l = (size_t)(info->func_length) + 1;
+ c = (char*) info->func_name;
+ len = 2 * ppzce_size + l + 1;
+ buf = emalloc(len);
+
+ memcpy(buf, c, l);
+ memcpy(buf + l, &calling_scope, ppzce_size);
+ memcpy(buf + l + ppzce_size, &obj_ce, ppzce_size);
+ buf[len - 1] = '\0';
+ break;
}
if (EXPECTED(buf != NULL)) {
@@ -334,7 +432,7 @@ ZEPHIR_ATTR_NONNULL static void zephir_fcall_populate_fci_cache(zend_fcall_info_
default:
#ifndef ZEPHIR_RELEASE
- fprintf(stderr, "%s: unknown call type (%d)\n", __func__, (int)type);
+ fprintf(stderr, "%s: unknown call type (%d)\n", __func__, (int) type);
abort();
#endif
fcic->initialized = 0; /* not strictly necessary but just to be safe */
@@ -347,8 +445,8 @@ ZEPHIR_ATTR_NONNULL static void zephir_fcall_populate_fci_cache(zend_fcall_info_
* Calls a function/method in the PHP userland
*/
int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir_call_type type,
- zval *function_name, zval **retval_ptr_ptr, zephir_fcall_cache_entry **cache_entry, zend_uint param_count,
- zval *params[] TSRMLS_DC)
+ zval *function_name, zval **retval_ptr_ptr, zephir_fcall_cache_entry **cache_entry, int cache_slot, zend_uint param_count,
+ zval *params[], zephir_fcall_info *info TSRMLS_DC)
{
zval ***params_ptr, ***params_array = NULL;
zval **static_params_array[10];
@@ -362,6 +460,7 @@ int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir
ulong fcall_key_hash;
zephir_fcall_cache_entry **temp_cache_entry = NULL;
zend_class_entry *old_scope = EG(scope);
+ int reload_cache = 1;
assert(obj_ce || !object_pp);
@@ -381,7 +480,7 @@ int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir
zend_uint i;
if (UNEXPECTED(param_count > 10)) {
- params_array = (zval***)emalloc(param_count * sizeof(zval**));
+ params_array = (zval***) emalloc(param_count * sizeof(zval**));
params_ptr = params_array;
for (i = 0; i < param_count; ++i) {
params_array[i] = ¶ms[i];
@@ -410,7 +509,24 @@ int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir
if (!cache_entry || !*cache_entry) {
if (zephir_globals_ptr->cache_enabled) {
- fcall_key_hash = zephir_make_fcall_key(&fcall_key, &fcall_key_len, (object_pp && type != zephir_fcall_ce ? Z_OBJCE_PP(object_pp) : obj_ce), type, function_name TSRMLS_CC);
+
+ if (cache_slot > 0) {
+ if (zephir_globals_ptr->scache[cache_slot]) {
+ reload_cache = 0;
+ temp_cache_entry = &zephir_globals_ptr->scache[cache_slot];
+ if (cache_entry) {
+ *cache_entry = *temp_cache_entry;
+ }
+ }
+ }
+
+ if (reload_cache) {
+ if (info) {
+ fcall_key_hash = zephir_make_fcall_info_key(&fcall_key, &fcall_key_len, (object_pp && type != zephir_fcall_ce ? Z_OBJCE_PP(object_pp) : obj_ce), type, info TSRMLS_CC);
+ } else {
+ fcall_key_hash = zephir_make_fcall_key(&fcall_key, &fcall_key_len, (object_pp && type != zephir_fcall_ce ? Z_OBJCE_PP(object_pp) : obj_ce), type, function_name TSRMLS_CC);
+ }
+ }
}
}
@@ -426,6 +542,8 @@ int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir
fcic.initialized = 0;
fcic.function_handler = NULL;
+ fcic.calling_scope = NULL;
+ fcic.called_scope = NULL;
if (!cache_entry || !*cache_entry) {
if (fcall_key && zend_hash_quick_find(zephir_globals_ptr->fcache, fcall_key, fcall_key_len, fcall_key_hash, (void**)&temp_cache_entry) != FAILURE) {
zephir_fcall_populate_fci_cache(&fcic, &fci, type TSRMLS_CC);
@@ -442,7 +560,7 @@ int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir
zephir_fcall_populate_fci_cache(&fcic, &fci, type TSRMLS_CC);
#ifndef ZEPHIR_RELEASE
fcic.function_handler = (*cache_entry)->f;
- ++(*temp_cache_entry)->times;
+ ++(*cache_entry)->times;
#else
fcic.function_handler = *cache_entry;
#endif
@@ -456,7 +574,11 @@ int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir
//}
/* fcic.initialized = 0; */
+#if PHP_VERSION_ID >= 50600
+ status = ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER(&fci, &fcic, info TSRMLS_CC);
+#else
status = ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER(&fci, &fcic TSRMLS_CC);
+#endif
/*
if (fcic.initialized && cache_entry) {
@@ -490,22 +612,23 @@ int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir
if (!cache_entry || !*cache_entry) {
if (EXPECTED(status != FAILURE) && fcall_key && !temp_cache_entry && fcic.initialized) {
#ifndef ZEPHIR_RELEASE
- zephir_fcall_cache_entry *temp_cache_entry = malloc(sizeof(zephir_fcall_cache_entry));
- temp_cache_entry->f = fcic.function_handler;
- temp_cache_entry->times = 0;
+ zephir_fcall_cache_entry *cache_entry_temp = malloc(sizeof(zephir_fcall_cache_entry));
+ cache_entry_temp->f = fcic.function_handler;
+ cache_entry_temp->times = 0;
#else
- zephir_fcall_cache_entry *temp_cache_entry = fcic.function_handler;
+ zephir_fcall_cache_entry *cache_entry_temp = fcic.function_handler;
#endif
- if (FAILURE == zend_hash_quick_add(zephir_globals_ptr->fcache, fcall_key, fcall_key_len, fcall_key_hash, &temp_cache_entry, sizeof(zephir_fcall_cache_entry*), NULL)) {
+ if (FAILURE == zend_hash_quick_add(zephir_globals_ptr->fcache, fcall_key, fcall_key_len, fcall_key_hash, &cache_entry_temp, sizeof(zephir_fcall_cache_entry*), NULL)) {
#ifndef ZEPHIR_RELEASE
free(temp_cache_entry);
#endif
} else {
-#ifdef ZEPHIR_RELEASE
if (cache_entry) {
- *cache_entry = temp_cache_entry;
+ *cache_entry = cache_entry_temp;
+ if (cache_slot > 0) {
+ zephir_globals_ptr->scache[cache_slot] = *cache_entry;
+ }
}
-#endif
}
}
}
@@ -529,12 +652,15 @@ int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir
}
int zephir_call_func_aparams(zval **return_value_ptr, const char *func_name, uint func_length,
- zephir_fcall_cache_entry **cache_entry,
+ zephir_fcall_cache_entry **cache_entry, int cache_slot,
uint param_count, zval **params TSRMLS_DC)
{
int status;
zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv;
- zval *func;
+ zval *func = NULL;
+#if PHP_VERSION_ID >= 50600
+ zephir_fcall_info info;
+#endif
#ifndef ZEPHIR_RELEASE
if (return_value_ptr && *return_value_ptr) {
@@ -544,9 +670,23 @@ int zephir_call_func_aparams(zval **return_value_ptr, const char *func_name, uin
}
#endif
+#if PHP_VERSION_ID >= 50600
+
+ info.type = ZEPHIR_FCALL_TYPE_FUNC;
+ info.class_name = NULL;
+ info.func_name = func_name;
+ info.func_length = func_length;
+
+ status = zephir_call_user_function(NULL, NULL, zephir_fcall_function, func, rvp, cache_entry, cache_slot, param_count, params, &info TSRMLS_CC);
+
+#else
+
ALLOC_INIT_ZVAL(func);
ZVAL_STRINGL(func, func_name, func_length, 0);
- status = zephir_call_user_function(NULL, NULL, zephir_fcall_function, func, rvp, cache_entry, param_count, params TSRMLS_CC);
+
+ status = zephir_call_user_function(NULL, NULL, zephir_fcall_function, func, rvp, cache_entry, 0, param_count, params, NULL TSRMLS_CC);
+
+#endif
if (status == FAILURE && !EG(exception)) {
zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined function %s()", func_name);
@@ -566,18 +706,20 @@ int zephir_call_func_aparams(zval **return_value_ptr, const char *func_name, uin
zval_ptr_dtor(&rv);
}
+#if PHP_VERSION_ID < 50600
if (Z_REFCOUNT_P(func) > 1) {
zval_copy_ctor(func);
} else {
ZVAL_NULL(func);
}
zval_ptr_dtor(&func);
+#endif
return status;
}
int zephir_call_zval_func_aparams(zval **return_value_ptr, zval *func_name,
- zephir_fcall_cache_entry **cache_entry,
+ zephir_fcall_cache_entry **cache_entry, int cache_slot,
uint param_count, zval **params TSRMLS_DC)
{
int status;
@@ -591,7 +733,7 @@ int zephir_call_zval_func_aparams(zval **return_value_ptr, zval *func_name,
}
#endif
- status = zephir_call_user_function(NULL, NULL, zephir_fcall_function, func_name, rvp, cache_entry, param_count, params TSRMLS_CC);
+ status = zephir_call_user_function(NULL, NULL, zephir_fcall_function, func_name, rvp, cache_entry, cache_slot, param_count, params, NULL TSRMLS_CC);
if (status == FAILURE && !EG(exception)) {
zephir_throw_exception_format(spl_ce_RuntimeException TSRMLS_CC, "Call to undefined function %s()", Z_TYPE_P(func_name) ? Z_STRVAL_P(func_name) : "undefined");
@@ -616,14 +758,19 @@ int zephir_call_zval_func_aparams(zval **return_value_ptr, zval *func_name,
int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *ce, zephir_call_type type, zval *object,
const char *method_name, uint method_len,
- zephir_fcall_cache_entry **cache_entry,
+ zephir_fcall_cache_entry **cache_entry, int cache_slot,
uint param_count, zval **params TSRMLS_DC)
{
char *possible_method;
zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv;
- zval *fn;
+ zval *fn = NULL;
+#if PHP_VERSION_ID < 50600
zval *mn;
+#endif
int status;
+#if PHP_VERSION_ID >= 50600
+ zephir_fcall_info info;
+#endif
#ifndef ZEPHIR_RELEASE
if (return_value_ptr && *return_value_ptr) {
@@ -643,6 +790,49 @@ int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *
}
}
+#if PHP_VERSION_ID >= 50600
+
+ if (!cache_entry || !*cache_entry) {
+
+ switch (type) {
+
+ case zephir_fcall_parent:
+ info.type = ZEPHIR_FCALL_TYPE_CLASS_PARENT_METHOD;
+ break;
+
+ case zephir_fcall_self:
+ assert(!ce);
+ info.type = ZEPHIR_FCALL_TYPE_CLASS_SELF_METHOD;
+ break;
+
+ case zephir_fcall_static:
+ assert(!ce);
+ info.type = ZEPHIR_FCALL_TYPE_CLASS_STATIC_METHOD;
+ break;
+
+ case zephir_fcall_ce:
+ assert(ce != NULL);
+ info.type = ZEPHIR_FCALL_TYPE_CE_METHOD;
+ info.ce = ce;
+ break;
+
+ case zephir_fcall_method:
+ default:
+ assert(object != NULL);
+ info.type = ZEPHIR_FCALL_TYPE_ZVAL_METHOD;
+ info.object_ptr = object;
+ info.ce = ce;
+ break;
+ }
+
+ info.func_name = method_name;
+ info.func_length = method_len;
+ }
+
+ status = zephir_call_user_function(object ? &object : NULL, ce, type, fn, rvp, cache_entry, cache_slot, param_count, params, &info TSRMLS_CC);
+
+#else
+
ALLOC_INIT_ZVAL(fn);
if (!cache_entry || !*cache_entry) {
@@ -673,11 +863,16 @@ int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *
ZVAL_STRINGL(fn, "undefined", sizeof("undefined")-1, 1);
}
- status = zephir_call_user_function(object ? &object : NULL, ce, type, fn, rvp, cache_entry, param_count, params TSRMLS_CC);
+ status = zephir_call_user_function(object ? &object : NULL, ce, type, fn, rvp, cache_entry, cache_slot, param_count, params, NULL TSRMLS_CC);
+
+#endif
+
if (status == FAILURE && !EG(exception)) {
if (ce) {
possible_method = zephir_fcall_possible_method(ce, method_name TSRMLS_CC);
+ } else {
+ possible_method = "undefined";
}
switch (type) {
@@ -734,7 +929,9 @@ int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *
zval_ptr_dtor(&rv);
}
+#if PHP_VERSION_ID < 50600
zval_ptr_dtor(&fn);
+#endif
return status;
}
@@ -798,7 +995,7 @@ int zephir_call_user_func_array_noex(zval *return_value, zval *handler, zval *pa
/**
* Latest version of zend_throw_exception_internal
*/
-void zephir_throw_exception_internal(zval *exception TSRMLS_DC)
+static void zephir_throw_exception_internal(zval *exception TSRMLS_DC)
{
if (exception != NULL) {
zval *previous = EG(exception);
@@ -1123,7 +1320,60 @@ int zephir_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache
#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
+ */
void zephir_eval_php(zval *str, zval *retval_ptr, char *context TSRMLS_DC)
{
- zend_eval_string_ex(Z_STRVAL_P(str), retval_ptr, context, 1 TSRMLS_CC);
+ zend_op_array *new_op_array = NULL;
+ zend_uint original_compiler_options;
+ zend_op_array *original_active_op_array = EG(active_op_array);
+
+ original_compiler_options = CG(compiler_options);
+ CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL;
+ new_op_array = zend_compile_string(str, context TSRMLS_CC);
+ CG(compiler_options) = original_compiler_options;
+
+ if (new_op_array)
+ {
+ zval *local_retval_ptr = NULL;
+ zval **original_return_value_ptr_ptr = EG(return_value_ptr_ptr);
+ zend_op **original_opline_ptr = EG(opline_ptr);
+ int orig_interactive = CG(interactive);
+
+ EG(return_value_ptr_ptr) = &local_retval_ptr;
+ EG(active_op_array) = new_op_array;
+ EG(no_extensions) = 1;
+ if (!EG(active_symbol_table)) {
+ zend_rebuild_symbol_table(TSRMLS_C);
+ }
+ CG(interactive) = 0;
+
+ zend_try {
+ zend_execute(new_op_array TSRMLS_CC);
+ } zend_catch {
+ destroy_op_array(new_op_array TSRMLS_CC);
+ efree(new_op_array);
+ zend_bailout();
+ } zend_end_try();
+
+ CG(interactive) = orig_interactive;
+ if (local_retval_ptr) {
+ if (retval_ptr) {
+ COPY_PZVAL_TO_ZVAL(*retval_ptr, local_retval_ptr);
+ } else {
+ zval_ptr_dtor(&local_retval_ptr);
+ }
+ } else if (retval_ptr) {
+ INIT_ZVAL(*retval_ptr);
+ }
+
+ EG(no_extensions) = 0;
+ EG(opline_ptr) = original_opline_ptr;
+ EG(active_op_array) = original_active_op_array;
+ destroy_op_array(new_op_array TSRMLS_CC);
+ efree(new_op_array);
+ EG(return_value_ptr_ptr) = original_return_value_ptr_ptr;
+ }
}
diff --git a/ext/kernel/fcall.h b/ext/kernel/fcall.h
index fb8f55af..30788eee 100644
--- a/ext/kernel/fcall.h
+++ b/ext/kernel/fcall.h
@@ -24,6 +24,9 @@
#include "php_ext.h"
#include "kernel/main.h"
#include "kernel/memory.h"
+#include "kernel/fcall_internal.h"
+#include "kernel/extended/fcall.h"
+
#include
#include
@@ -36,19 +39,6 @@ typedef enum _zephir_call_type {
zephir_fcall_function
} zephir_call_type;
-#ifndef ZEPHIR_RELEASE
-
-typedef struct _zephir_fcall_cache_entry {
- zend_function *f;
- zend_uint times;
-} zephir_fcall_cache_entry;
-
-#else
-
-typedef zend_function zephir_fcall_cache_entry;
-
-#endif
-
/**
* @addtogroup callfuncs Calling Functions
* @{
@@ -71,13 +61,17 @@ typedef zend_function zephir_fcall_cache_entry;
* @note If the call fails or an exception occurs, the memory frame is @em not restored.
* In this case if @c return_value_ptr is not @c NULL, *return_value_ptr is set to @c NULL
*/
-#define ZEPHIR_CALL_FUNCTIONW(return_value_ptr, func_name, ...) \
+#define ZEPHIR_CALL_FUNCTIONW(return_value_ptr, func_name, cache, cache_slot, ...) \
do { \
+ zephir_fcall_cache_entry **cache_entry_ = cache; \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(func_name)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, sizeof(func_name)-1, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
- } \
- else { \
+ if (cache_entry_ && *cache_entry_) { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams_fast(return_value_ptr, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } else { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } \
+ } else { \
ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, strlen(func_name), ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
@@ -90,18 +84,39 @@ typedef zend_function zephir_fcall_cache_entry;
* @note If the call fails or an exception occurs, the memory frame is restored.
* In this case if @c return_value_ptr is not @c NULL, *return_value_ptr is set to @c NULL
*/
-#define ZEPHIR_CALL_FUNCTION(return_value_ptr, func_name, cache, ...) \
+#if PHP_VERSION_ID >= 50600
+
+#define ZEPHIR_CALL_FUNCTION(return_value_ptr, func_name, cache, cache_slot, ...) \
do { \
+ zephir_fcall_cache_entry **cache_entry_ = cache; \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
if (__builtin_constant_p(func_name)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, sizeof(func_name)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ if (cache_entry_ && *cache_entry_) { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams_fast(return_value_ptr, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } else { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } \
+ } else { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
- else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, strlen(func_name), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } while (0)
+
+#else
+
+#define ZEPHIR_CALL_FUNCTION(return_value_ptr, func_name, cache, cache_slot, ...) \
+ do { \
+ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
+ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
+ if (__builtin_constant_p(func_name)) { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } else { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_func_aparams(return_value_ptr, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
+#endif
+
/**
* @brief Invokes a function @a func_name passing @c return_value and @c return_value_ptr
* as return value address; returns if the function fails due to an error or exception.
@@ -111,14 +126,14 @@ typedef zend_function zephir_fcall_cache_entry;
* @li if @c return_value_ptr is not @c NULL, @c *return_value_ptr is initialized with @c ALLOC_INIT_ZVAL
* @li otherwise, if @c return_value is not @c NULL, @c return_value and @c *return_value are not changed
*/
-#define ZEPHIR_RETURN_CALL_FUNCTIONW(func_name, cache, ...) \
+#define ZEPHIR_RETURN_CALL_FUNCTIONW(func_name, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(func_name)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, sizeof(func_name)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, strlen(func_name), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
@@ -131,14 +146,14 @@ typedef zend_function zephir_fcall_cache_entry;
* @li if @c return_value_ptr is not @c NULL, @c *return_value_ptr is initialized with @c ALLOC_INIT_ZVAL
* @li otherwise, if @c return_value is not @c NULL, @c return_value and @c *return_value are not changed
*/
-#define ZEPHIR_RETURN_CALL_FUNCTION(func_name, cache, ...) \
+#define ZEPHIR_RETURN_CALL_FUNCTION(func_name, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(func_name)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, sizeof(func_name)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, sizeof(func_name)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, strlen(func_name), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_function(return_value, return_value_ptr, func_name, strlen(func_name), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
@@ -150,16 +165,11 @@ typedef zend_function zephir_fcall_cache_entry;
* @note If the call fails or an exception occurs, the memory frame is restored.
* In this case if @c return_value_ptr is not @c NULL, *return_value_ptr is set to @c NULL
*/
-#define ZEPHIR_CALL_ZVAL_FUNCTION(return_value_ptr, func_name, cache, ...) \
+#define ZEPHIR_CALL_ZVAL_FUNCTION(return_value_ptr, func_name, cache, cache_slot, ...) \
do { \
- zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
- ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
- if (__builtin_constant_p(func_name)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_zval_func_aparams(return_value_ptr, func_name, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
- } \
- else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_zval_func_aparams(return_value_ptr, func_name, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
- } \
+ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
+ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_zval_func_aparams(return_value_ptr, func_name, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} while (0)
/**
@@ -171,98 +181,161 @@ typedef zend_function zephir_fcall_cache_entry;
* @li if @c return_value_ptr is not @c NULL, @c *return_value_ptr is initialized with @c ALLOC_INIT_ZVAL
* @li otherwise, if @c return_value is not @c NULL, @c return_value and @c *return_value are not changed
*/
-#define ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(func_name, cache, ...) \
+#define ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(func_name, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
- if (__builtin_constant_p(func_name)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_zval_function(return_value, return_value_ptr, func_name, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
- } \
- else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_zval_function(return_value, return_value_ptr, func_name, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
- } \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_zval_function(return_value, return_value_ptr, func_name, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} while (0)
/**
* @}
*/
-#define ZEPHIR_CALL_METHODW(return_value_ptr, object, method, cache, ...) \
+/* Saves the if pointer, and called/calling scope */
+#define ZEPHIR_BACKUP_THIS_PTR() \
+ zval *old_this_ptr = this_ptr;
+
+#define ZEPHIR_RESTORE_THIS_PTR() ZEPHIR_SET_THIS(old_this_ptr)
+
+#define ZEPHIR_SET_THIS(pzv) EG(This) = pzv;
+
+#define ZEPHIR_BACKUP_SCOPE() \
+ zend_class_entry *old_scope = EG(scope); \
+ zend_class_entry *old_called_scope = EG(called_scope);
+
+#define ZEPHIR_RESTORE_SCOPE() \
+ EG(called_scope) = old_called_scope; \
+ EG(scope) = old_scope; \
+
+#define ZEPHIR_SET_SCOPE(_scope, _scope_called) \
+ EG(scope) = _scope; \
+ EG(called_scope) = _scope_called; \
+
+/* End internal calls */
+
+#define ZEPHIR_CALL_METHODW(return_value_ptr, object, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_CALL_METHOD(return_value_ptr, object, method, cache, ...) \
+#define ZEPHIR_CALL_METHOD(return_value_ptr, object, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } else { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
- else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } while (0)
+
+#define ZEPHIR_RETURN_CALL_METHODW(object, method, cache, cache_slot, ...) \
+ do { \
+ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
+ if (__builtin_constant_p(method)) { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } else { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_RETURN_CALL_METHODW(object, method, cache, ...) \
+#define ZEPHIR_RETURN_CALL_METHOD(object, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } else { \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
- else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } while (0)
+
+#define ZEPHIR_CALL_METHOD_ZVAL(return_value_ptr, object, method, cache, cache_slot, ...) \
+ do { \
+ char *method_name; \
+ int method_len; \
+ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
+ if (Z_TYPE_P(method) == IS_STRING) { \
+ method_len = Z_STRLEN_P(method); \
+ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \
+ } else { \
+ method_len = 0; \
+ method_name = zend_str_tolower_dup("", 0); \
} \
+ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ efree(method_name); \
} while (0)
-#define ZEPHIR_RETURN_CALL_METHOD(object, method, cache, ...) \
+#define ZEPHIR_RETURN_CALL_METHODW_ZVAL(object, method, cache, cache_slot, ...) \
do { \
+ char *method_name; \
+ int method_len; \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
- if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ if (Z_TYPE_P(method) == IS_STRING) { \
+ method_len = Z_STRLEN_P(method); \
+ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \
+ } else { \
+ method_len = 0; \
+ method_name = zend_str_tolower_dup("", 0); \
} \
- else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ efree(method_name); \
+ } while (0)
+
+#define ZEPHIR_RETURN_CALL_METHOD_ZVAL(object, method, cache, cache_slot, ...) \
+ do { \
+ char *method_name; \
+ int method_len; \
+ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
+ if (Z_TYPE_P(method) == IS_STRING) { \
+ method_len = Z_STRLEN_P(method); \
+ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \
+ } else { \
+ method_len = 0; \
+ method_name = zend_str_tolower_dup("", 0); \
} \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ efree(method_name); \
} while (0)
-#define ZEPHIR_CALL_METHOD_THIS(return_value_ptr, method, cache, ...) \
+#define ZEPHIR_CALL_METHOD_THIS(return_value_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, THIS_CE, zephir_fcall_method, this_ptr, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, THIS_CE, zephir_fcall_method, this_ptr, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, THIS_CE, zephir_fcall_method, this_ptr, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, THIS_CE, zephir_fcall_method, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_CALL_PARENTW(return_value_ptr, class_entry, this_ptr, method, cache, ...) \
+#define ZEPHIR_CALL_PARENTW(return_value_ptr, class_entry, this_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_CALL_PARENT(return_value_ptr, class_entry, this_ptr, method, cache, ...) \
+#define ZEPHIR_CALL_PARENT(return_value_ptr, class_entry, this_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
@@ -277,37 +350,37 @@ typedef zend_function zephir_fcall_cache_entry;
} \
} while (0)
-#define ZEPHIR_RETURN_CALL_PARENT(class_entry, this_ptr, method, cache, ...) \
+#define ZEPHIR_RETURN_CALL_PARENT(class_entry, this_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_CALL_SELFW(return_value_ptr, method, cache, ...) \
+#define ZEPHIR_CALL_SELFW(return_value_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, cache, sizeof(method)-1, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, cache, cache_slot, sizeof(method)-1, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, cache, strlen(method), ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, cache, cache_slot, strlen(method), ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_CALL_SELF(return_value_ptr, method, cache, ...) \
+#define ZEPHIR_CALL_SELF(return_value_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
@@ -322,14 +395,14 @@ typedef zend_function zephir_fcall_cache_entry;
} \
} while (0)
-#define ZEPHIR_RETURN_CALL_SELF(method, cache, ...) \
+#define ZEPHIR_RETURN_CALL_SELF(method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_self, NULL, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_self, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
@@ -344,64 +417,64 @@ typedef zend_function zephir_fcall_cache_entry;
} \
} while (0)
-#define ZEPHIR_CALL_STATIC(return_value_ptr, method, cache, ...) \
+#define ZEPHIR_CALL_STATIC(return_value_ptr, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_RETURN_CALL_STATICW(method, cache, ...) \
+#define ZEPHIR_RETURN_CALL_STATICW(method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- RETURN_ON_FAILURE(zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC)); \
+ RETURN_ON_FAILURE(zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC)); \
} \
else { \
- RETURN_ON_FAILURE(zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC)); \
+ RETURN_ON_FAILURE(zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC)); \
} \
} while (0)
-#define ZEPHIR_RETURN_CALL_STATIC(method, cache, ...) \
+#define ZEPHIR_RETURN_CALL_STATIC(method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_CALL_CE_STATICW(return_value_ptr, class_entry, method, cache, ...) \
+#define ZEPHIR_CALL_CE_STATICW(return_value_ptr, class_entry, method, cache, cache_slot, ...) \
do { \
zval *params[] = {__VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, cache, sizeof(params)/sizeof(zval*), params TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, cache, cache_slot, sizeof(params)/sizeof(zval*), params TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, sizeof(params)/sizeof(zval*), params TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, cache_slot, sizeof(params)/sizeof(zval*), params TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_CALL_CE_STATIC(return_value_ptr, class_entry, method, cache, ...) \
+#define ZEPHIR_CALL_CE_STATIC(return_value_ptr, class_entry, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
} while (0)
-#define ZEPHIR_RETURN_CALL_CE_STATICW(class_entry, method, cache, ...) \
+#define ZEPHIR_RETURN_CALL_CE_STATICW(class_entry, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
@@ -412,15 +485,64 @@ typedef zend_function zephir_fcall_cache_entry;
} \
} while (0)
-#define ZEPHIR_RETURN_CALL_CE_STATIC(class_entry, method, cache, ...) \
+#define ZEPHIR_RETURN_CALL_CE_STATIC(class_entry, method, cache, cache_slot, ...) \
do { \
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
if (__builtin_constant_p(method)) { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, sizeof(method)-1, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
} \
else { \
- ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ } \
+ } while (0)
+
+#define ZEPHIR_CALL_CE_STATIC_ZVAL(return_value_ptr, class_entry, method, cache, cache_slot, ...) \
+ do { \
+ char *method_name; \
+ int method_len; \
+ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
+ if (Z_TYPE_P(method) == IS_STRING) { \
+ method_len = Z_STRLEN_P(method); \
+ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \
+ } else { \
+ method_len = 0; \
+ method_name = zend_str_tolower_dup("", 0); \
+ } \
+ ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
+ ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, class_entry, zephir_fcall_ce, NULL, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ efree(method_name); \
+ } while (0)
+
+#define ZEPHIR_RETURN_CALL_CE_STATICW_ZVAL(class_entry, method, cache, cache_slot, ...) \
+ do { \
+ char *method_name; \
+ int method_len; \
+ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
+ if (Z_TYPE_P(method) == IS_STRING) { \
+ method_len = Z_STRLEN_P(method); \
+ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \
+ } else { \
+ method_len = 0; \
+ method_name = zend_str_tolower_dup("", 0); \
+ } \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method_name, method_len, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ efree(method_name); \
+ } while (0)
+
+#define ZEPHIR_RETURN_CALL_CE_STATIC_ZVAL(class_entry, method, cache, cache_slot, ...) \
+ do { \
+ char *method_name; \
+ int method_len; \
+ zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
+ if (Z_TYPE_P(method) == IS_STRING) { \
+ method_len = Z_STRLEN_P(method); \
+ method_name = zend_str_tolower_dup(Z_STRVAL_P(method), method_len); \
+ } else { \
+ method_len = 0; \
+ method_name = zend_str_tolower_dup("", 0); \
} \
+ ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, return_value_ptr, class_entry, zephir_fcall_ce, NULL, method_name, method_len, cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_) TSRMLS_CC); \
+ efree(method_name); \
} while (0)
/** Use these functions to call functions in the PHP userland using an arbitrary zval as callable */
@@ -436,11 +558,13 @@ typedef zend_function zephir_fcall_cache_entry;
} while (0)
int zephir_call_func_aparams(zval **return_value_ptr, const char *func_name, uint func_length,
- zephir_fcall_cache_entry **cache_entry,
+ zephir_fcall_cache_entry **cache_entry, int cache_slot,
uint param_count, zval **params TSRMLS_DC);
+int zephir_call_func_aparams_fast(zval **return_value_ptr, zephir_fcall_cache_entry **cache_entry, uint param_count, zval **params TSRMLS_DC);
+
int zephir_call_zval_func_aparams(zval **return_value_ptr, zval *func_name,
- zephir_fcall_cache_entry **cache_entry,
+ zephir_fcall_cache_entry **cache_entry, int cache_slot,
uint param_count, zval **params TSRMLS_DC) ZEPHIR_ATTR_WARN_UNUSED_RESULT;
/**
@@ -453,7 +577,7 @@ int zephir_call_zval_func_aparams(zval **return_value_ptr, zval *func_name,
* @param param_count Number of parameters
*/
ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_function(zval *return_value, zval **return_value_ptr,
- const char *func, uint func_len, zephir_fcall_cache_entry **cache_entry, uint param_count, zval **params TSRMLS_DC)
+ const char *func, uint func_len, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC)
{
zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv;
int status;
@@ -463,7 +587,7 @@ ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_function(zva
*return_value_ptr = NULL;
}
- status = zephir_call_func_aparams(rvp, func, func_len, cache_entry, param_count, params TSRMLS_CC);
+ status = zephir_call_func_aparams(rvp, func, func_len, cache_entry, cache_slot, param_count, params TSRMLS_CC);
if (status == FAILURE) {
if (return_value_ptr && EG(exception)) {
@@ -490,7 +614,7 @@ ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_function(zva
* @param param_count Number of parameters
*/
ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_zval_function(zval *return_value, zval **return_value_ptr,
- zval *func, zephir_fcall_cache_entry **cache_entry, uint param_count, zval **params TSRMLS_DC)
+ zval *func, zephir_fcall_cache_entry **cache_entry, int cache_slot, uint param_count, zval **params TSRMLS_DC)
{
zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv;
int status;
@@ -500,7 +624,7 @@ ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_zval_functio
*return_value_ptr = NULL;
}
- status = zephir_call_zval_func_aparams(rvp, func, cache_entry, param_count, params TSRMLS_CC);
+ status = zephir_call_zval_func_aparams(rvp, func, cache_entry, cache_slot, param_count, params TSRMLS_CC);
if (status == FAILURE) {
if (return_value_ptr && EG(exception)) {
@@ -517,15 +641,20 @@ ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_zval_functio
return SUCCESS;
}
-int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *ce, zephir_call_type type, zval *object,
+int zephir_call_class_method_aparams(zval **return_value_ptr,
+ zend_class_entry *ce,
+ zephir_call_type type,
+ zval *object,
const char *method_name, uint method_len,
zephir_fcall_cache_entry **cache_entry,
- uint param_count, zval **params TSRMLS_DC) ZEPHIR_ATTR_WARN_UNUSED_RESULT;
+ int cache_slot,
+ uint param_count,
+ zval **params TSRMLS_DC) ZEPHIR_ATTR_WARN_UNUSED_RESULT;
ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_class_method(zval *return_value,
zval **return_value_ptr, zend_class_entry *ce, zephir_call_type type, zval *object,
const char *method_name, uint method_len,
- zephir_fcall_cache_entry **cache_entry,
+ zephir_fcall_cache_entry **cache_entry, int cache_slot,
uint param_count, zval **params TSRMLS_DC)
{
zval *rv = NULL, **rvp = return_value_ptr ? return_value_ptr : &rv;
@@ -536,7 +665,7 @@ ZEPHIR_ATTR_WARN_UNUSED_RESULT static inline int zephir_return_call_class_method
*return_value_ptr = NULL;
}
- status = zephir_call_class_method_aparams(rvp, ce, type, object, method_name, method_len, cache_entry, param_count, params TSRMLS_CC);
+ status = zephir_call_class_method_aparams(rvp, ce, type, object, method_name, method_len, cache_entry, cache_slot, param_count, params TSRMLS_CC);
if (status == FAILURE) {
if (return_value_ptr && EG(exception)) {
@@ -667,8 +796,12 @@ ZEPHIR_ATTR_WARN_UNUSED_RESULT ZEPHIR_ATTR_NONNULL static inline int zephir_has_
int zephir_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC);
#define ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER zephir_call_function
#else
+#if PHP_VERSION_ID >= 50600
+#define ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER zephir_call_function_opt
+#else
#define ZEPHIR_ZEND_CALL_FUNCTION_WRAPPER zend_call_function
#endif
+#endif
#ifndef zend_error_noreturn
#define zend_error_noreturn zend_error
diff --git a/ext/kernel/fcall.h.gch b/ext/kernel/fcall.h.gch
new file mode 100644
index 00000000..06248332
Binary files /dev/null and b/ext/kernel/fcall.h.gch differ
diff --git a/ext/kernel/fcall_internal.h b/ext/kernel/fcall_internal.h
new file mode 100644
index 00000000..5c4ae534
--- /dev/null
+++ b/ext/kernel/fcall_internal.h
@@ -0,0 +1,3 @@
+#ifndef ZEPHIR_KERNEL_FCALL_INTERNAL_H
+#define ZEPHIR_KERNEL_FCALL_INTERNAL_H
+#endif
diff --git a/ext/kernel/fcall_internal.h.gch b/ext/kernel/fcall_internal.h.gch
new file mode 100644
index 00000000..3daf04c3
Binary files /dev/null and b/ext/kernel/fcall_internal.h.gch differ
diff --git a/ext/kernel/file.h b/ext/kernel/file.h
index 2ed05fff..7da226aa 100644
--- a/ext/kernel/file.h
+++ b/ext/kernel/file.h
@@ -20,6 +20,8 @@
#ifndef ZEPHIR_KERNEL_FILE_H
#define ZEPHIR_KERNEL_FILE_H
+#include
+
int zephir_file_exists(zval *filename TSRMLS_DC);
int zephir_compare_mtime(zval *filename1, zval *filename2 TSRMLS_DC);
void zephir_fix_path(zval **return_value, zval *path, zval *directory_separator TSRMLS_DC);
diff --git a/ext/kernel/file.h.gch b/ext/kernel/file.h.gch
new file mode 100644
index 00000000..413f2e86
Binary files /dev/null and b/ext/kernel/file.h.gch differ
diff --git a/ext/kernel/filter.h b/ext/kernel/filter.h
index 92a5d93d..6564e383 100644
--- a/ext/kernel/filter.h
+++ b/ext/kernel/filter.h
@@ -17,6 +17,11 @@
+------------------------------------------------------------------------+
*/
+#ifndef ZEPHIR_KERNEL_FILTER_H
+#define ZEPHIR_KERNEL_FILTER_H
+
+#include
+
/** Low level filters */
void zephir_filter_alphanum(zval *return_value, zval *param);
void zephir_filter_identifier(zval *return_value, zval *param);
@@ -29,3 +34,5 @@ void zephir_escape_css(zval *return_value, zval *param);
void zephir_escape_js(zval *return_value, zval *param);
void zephir_escape_htmlattr(zval *return_value, zval *param);
void zephir_escape_html(zval *return_value, zval *str, zval *quote_style, zval *charset TSRMLS_DC);
+
+#endif
\ No newline at end of file
diff --git a/ext/kernel/filter.h.gch b/ext/kernel/filter.h.gch
new file mode 100644
index 00000000..4aa0e8fc
Binary files /dev/null and b/ext/kernel/filter.h.gch differ
diff --git a/ext/kernel/globals.h b/ext/kernel/globals.h
index d4e89972..bc3a677d 100644
--- a/ext/kernel/globals.h
+++ b/ext/kernel/globals.h
@@ -21,7 +21,10 @@
#ifndef ZEPHIR_KERNEL_GLOBALS_H
#define ZEPHIR_KERNEL_GLOBALS_H
+#include
+
#define ZEPHIR_MAX_MEMORY_STACK 48
+#define ZEPHIR_MAX_CACHE_SLOTS 512
/** Memory frame */
typedef struct _zephir_memory_entry {
@@ -51,6 +54,19 @@ typedef struct _zephir_function_cache {
zend_function *func;
} zephir_function_cache;
+#ifndef ZEPHIR_RELEASE
+
+typedef struct _zephir_fcall_cache_entry {
+ zend_function *f;
+ zend_uint times;
+} zephir_fcall_cache_entry;
+
+#else
+
+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
@@ -142,6 +158,12 @@ typedef struct _zephir_function_cache {
# define __func__ __FUNCTION__
#endif
+#if defined(__GNUC__)
+# define ZEPHIR_NO_OPT __attribute__((optimize("O0")))
+#else
+# define ZEPHIR_NO_OPT
+#endif
+
/*#if PHP_VERSION_ID > 50399
# define ZLK_DC , const struct _zend_literal* key
# define ZLK_CC , key
@@ -152,13 +174,9 @@ typedef struct _zephir_function_cache {
# define ZLK_NULL_CC
#endif*/
-#if PHP_VERSION_ID < 50600
#ifdef ZTS
#define zephir_nts_static
#else
-#define zephir_nts_static static
-#endif
-#else
#define zephir_nts_static
#endif
diff --git a/ext/kernel/globals.h.gch b/ext/kernel/globals.h.gch
new file mode 100644
index 00000000..ec5f2b58
Binary files /dev/null and b/ext/kernel/globals.h.gch differ
diff --git a/ext/kernel/hash.c b/ext/kernel/hash.c
index bac5a7e7..0f75d421 100644
--- a/ext/kernel/hash.c
+++ b/ext/kernel/hash.c
@@ -24,9 +24,65 @@
#include "php.h"
#include "php_ext.h"
+#include
#include "kernel/memory.h"
+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 {
+ if (nSize > 3) {
+ ht->nTableSize = nSize + (nSize >> 2);
+ } else {
+ ht->nTableSize = 3;
+ }
+ }
+
+#if ZEND_DEBUG
+ 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;
+ ht->pListTail = NULL;
+ ht->nNumOfElements = 0;
+ ht->nNextFreeElement = 0;
+ ht->pInternalPointer = NULL;
+ ht->persistent = persistent;
+ 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;
+}
+
int zephir_hash_exists(const HashTable *ht, const char *arKey, uint nKeyLength)
{
ulong h;
@@ -328,5 +384,3 @@ int zephir_hash_unset(HashTable *ht, zval *key)
return 0;
}
}
-
-
diff --git a/ext/kernel/hash.h b/ext/kernel/hash.h
index 0a18a431..ab9dc665 100644
--- a/ext/kernel/hash.h
+++ b/ext/kernel/hash.h
@@ -1,26 +1,32 @@
/*
- +------------------------------------------------------------------------+
- | Zephir Language |
- +------------------------------------------------------------------------+
- | Copyright (c) 2011-2015 Zephir Team (http://www.zephir-lang.com) |
- +------------------------------------------------------------------------+
- | This source file is subject to the New BSD License that is bundled |
- | with this package in the file docs/LICENSE.txt. |
- | |
- | If you did not receive a copy of the license and are unable to |
- | obtain it through the world-wide-web, please send an email |
- | to license@zephir-lang.com so we can send you a copy immediately. |
- +------------------------------------------------------------------------+
- | Authors: Andres Gutierrez |
- | Eduar Carvajal |
- | Vladimir Kolesnikov |
- +------------------------------------------------------------------------+
+ +------------------------------------------------------------------------+
+ | Zephir Language |
+ +------------------------------------------------------------------------+
+ | Copyright (c) 2011-2015 Zephir Team (http://www.zephir-lang.com) |
+ +------------------------------------------------------------------------+
+ | This source file is subject to the New BSD License that is bundled |
+ | with this package in the file docs/LICENSE.txt. |
+ | |
+ | If you did not receive a copy of the license and are unable to |
+ | obtain it through the world-wide-web, please send an email |
+ | to license@zephir-lang.com so we can send you a copy immediately. |
+ +------------------------------------------------------------------------+
+ | Authors: Andres Gutierrez |
+ | Eduar Carvajal |
+ | Vladimir Kolesnikov |
+ +------------------------------------------------------------------------+
*/
#ifndef ZEPHIR_KERNEL_HASH_H
#define ZEPHIR_KERNEL_HASH_H
+#include
+#include
+#include
+
+int zephir_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent);
+
int zephir_hash_exists(const HashTable *ht, const char *arKey, uint nKeyLength);
int zephir_hash_quick_exists(const HashTable *ht, const char *arKey, uint nKeyLength, ulong h);
int zephir_hash_find(const HashTable *ht, const char *arKey, uint nKeyLength, void **pData);
@@ -34,6 +40,8 @@ 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;
@@ -46,8 +54,27 @@ 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
HashPosition *current = pos ? pos : &ht->pInternalPointer;
if (*current) {
*current = (*current)->pListLast;
@@ -55,6 +82,25 @@ static zend_always_inline int zephir_hash_move_backwards_ex(HashTable *ht, HashP
} else {
return FAILURE;
}
+#else
+ uint idx = *pos;
+
+ IS_CONSISTENT(ht);
+
+ if (idx != INVALID_IDX) {
+ while (idx > 0) {
+ idx--;
+ if (Z_TYPE(ht->arData[idx].val) != IS_UNDEF) {
+ *pos = idx;
+ return SUCCESS;
+ }
+ }
+ *pos = INVALID_IDX;
+ return SUCCESS;
+ } else {
+ return FAILURE;
+ }
+#endif
}
#endif
diff --git a/ext/kernel/hash.h.gch b/ext/kernel/hash.h.gch
new file mode 100644
index 00000000..0464701d
Binary files /dev/null and b/ext/kernel/hash.h.gch differ
diff --git a/ext/kernel/iterator.h b/ext/kernel/iterator.h
index 31de51e7..f8a6002c 100644
--- a/ext/kernel/iterator.h
+++ b/ext/kernel/iterator.h
@@ -21,6 +21,9 @@
#ifndef ZEPHIR_KERNEL_ITERATOR_H
#define ZEPHIR_KERNEL_ITERATOR_H
+#include
+#include
+
zend_object_iterator *zephir_get_iterator(zval *iterator TSRMLS_DC);
#endif
diff --git a/ext/kernel/iterator.h.gch b/ext/kernel/iterator.h.gch
new file mode 100644
index 00000000..8e3e85ec
Binary files /dev/null and b/ext/kernel/iterator.h.gch differ
diff --git a/ext/kernel/main.c b/ext/kernel/main.c
index 451ff476..e39782e9 100644
--- a/ext/kernel/main.c
+++ b/ext/kernel/main.c
@@ -290,6 +290,20 @@ int zephir_is_callable(zval *var TSRMLS_DC) {
return (int) retval;
}
+int zephir_is_scalar(zval *var) {
+
+ switch (Z_TYPE_P(var)) {
+ case IS_BOOL:
+ case IS_DOUBLE:
+ case IS_LONG:
+ case IS_STRING:
+ return 1;
+ break;
+ }
+
+ return 0;
+}
+
/**
* Initialize an array to start an iteration over it
*/
diff --git a/ext/kernel/main.h b/ext/kernel/main.h
index 18d116c2..4069a5b6 100644
--- a/ext/kernel/main.h
+++ b/ext/kernel/main.h
@@ -20,9 +20,9 @@
#ifndef ZEPHIR_KERNEL_MAIN_H
#define ZEPHIR_KERNEL_MAIN_H
-#include "Zend/zend_interfaces.h"
-#include "ext/spl/spl_exceptions.h"
-#include "ext/spl/spl_iterators.h"
+#include
+#include
+#include
/** Main macros */
#define PH_DEBUG 0
@@ -38,12 +38,16 @@
#define PH_COPY 1024
#define PH_CTOR 4096
+#ifndef zend_uint
+ #define zend_uint uint
+#endif
+
#define SL(str) ZEND_STRL(str)
#define SS(str) ZEND_STRS(str)
#define ISL(str) (zephir_interned_##str), (sizeof(#str)-1)
#define ISS(str) (zephir_interned_##str), (sizeof(#str))
-#include "Zend/zend_constants.h"
+#include
#include "kernel/exception.h"
/* Compatibility with PHP 5.3 */
@@ -67,6 +71,7 @@ int zephir_init_global(char *global, unsigned int global_length TSRMLS_DC);
int zephir_get_global(zval **arr, const char *global, unsigned int global_length TSRMLS_DC);
int zephir_is_callable(zval *var TSRMLS_DC);
+int zephir_is_scalar(zval *var);
int zephir_function_exists(const zval *function_name TSRMLS_DC);
int zephir_function_exists_ex(const char *func_name, unsigned int func_len TSRMLS_DC);
int zephir_function_quick_exists_ex(const char *func_name, unsigned int func_len, unsigned long key TSRMLS_DC);
@@ -389,14 +394,15 @@ static inline char *_str_erealloc(char *str, size_t new_len, size_t old_len) {
#define ZEPHIR_GET_IMKEY(var, it) \
{\
- int key_type, str_key_len; \
+ int key_type; uint str_key_len; \
ulong int_key; \
char *str_key; \
\
ZEPHIR_INIT_NVAR(var); \
key_type = it->funcs->get_current_key(it, &str_key, &str_key_len, &int_key TSRMLS_CC); \
if (key_type == HASH_KEY_IS_STRING) { \
- ZVAL_STRINGL(var, str_key, str_key_len, 1); \
+ ZVAL_STRINGL(var, str_key, str_key_len - 1, 1); \
+ efree(str_key); \
} else { \
if (key_type == HASH_KEY_IS_LONG) { \
ZVAL_LONG(var, int_key); \
@@ -464,6 +470,25 @@ 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; \
+ ZEPHIR_INIT_ZVAL_NREF(obj_ptr); \
+ Z_TYPE_P(obj_ptr) = IS_OBJECT; \
+ Z_OBJVAL_P(obj_ptr) = zend_objects_new(&object, class_type TSRMLS_CC); \
+ object_properties_init(object, class_type); \
+ }
+
+#define ZEPHIR_MAKE_REF(obj) Z_SET_ISREF_P(obj);
+#define ZEPHIR_UNREF(obj) Z_UNSET_ISREF_P(obj);
+
#define ZEPHIR_REGISTER_INTERFACE(ns, classname, lower_ns, name, methods) \
{ \
zend_class_entry ce; \
@@ -547,6 +572,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)
+#define zephir_is_php_version(id) (PHP_VERSION_ID / 10 == id / 10 ? 1 : 0)
#endif /* ZEPHIR_KERNEL_MAIN_H */
diff --git a/ext/kernel/main.h.gch b/ext/kernel/main.h.gch
new file mode 100644
index 00000000..00995223
Binary files /dev/null and b/ext/kernel/main.h.gch differ
diff --git a/ext/kernel/math.c b/ext/kernel/math.c
new file mode 100644
index 00000000..022e6f9e
--- /dev/null
+++ b/ext/kernel/math.c
@@ -0,0 +1,256 @@
+
+/*
+ +------------------------------------------------------------------------+
+ | Zephir Language |
+ +------------------------------------------------------------------------+
+ | Copyright (c) 2011-2015 Zephir Team (http://www.zephir-lang.com) |
+ +------------------------------------------------------------------------+
+ | This source file is subject to the New BSD License that is bundled |
+ | with this package in the file docs/LICENSE.txt. |
+ | |
+ | If you did not receive a copy of the license and are unable to |
+ | obtain it through the world-wide-web, please send an email |
+ | to license@zephir-lang.com so we can send you a copy immediately. |
+ +------------------------------------------------------------------------+
+ | Authors: Andres Gutierrez |
+ | Eduar Carvajal |
+ +------------------------------------------------------------------------+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+#include
+#include
+
+#include "php_ext.h"
+#include "kernel/main.h"
+#include "kernel/memory.h"
+#include "kernel/string.h"
+#include "kernel/operators.h"
+
+#include "Zend/zend_operators.h"
+
+double zephir_floor(zval *op1 TSRMLS_DC)
+{
+ switch (Z_TYPE_P(op1)) {
+ case IS_LONG:
+ return (double) Z_LVAL_P(op1);
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
+ }
+ return floor(zephir_get_numberval(op1));
+}
+
+double zephir_sin(zval *op1 TSRMLS_DC)
+{
+ switch (Z_TYPE_P(op1)) {
+ case IS_LONG:
+ return sin(Z_LVAL_P(op1));
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
+ }
+
+ return sin(zephir_get_numberval(op1));
+}
+
+double zephir_asin(zval *op1 TSRMLS_DC)
+{
+ switch (Z_TYPE_P(op1)) {
+ case IS_LONG:
+ return asin(Z_LVAL_P(op1));
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
+ }
+
+ return asin(zephir_get_numberval(op1));
+}
+
+double zephir_cos(zval *op1 TSRMLS_DC)
+{
+ switch (Z_TYPE_P(op1)) {
+ case IS_LONG:
+ return cos(Z_LVAL_P(op1));
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
+ }
+
+ return cos(zephir_get_numberval(op1));
+}
+
+double zephir_acos(zval *op1 TSRMLS_DC)
+{
+ switch (Z_TYPE_P(op1)) {
+ case IS_LONG:
+ return acos(Z_LVAL_P(op1));
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
+ }
+
+ return acos(zephir_get_numberval(op1));
+}
+
+double zephir_sqrt(zval *op1 TSRMLS_DC)
+{
+ switch (Z_TYPE_P(op1)) {
+ case IS_LONG:
+ return sqrt(Z_LVAL_P(op1));
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
+ }
+
+ return sqrt(zephir_get_numberval(op1));
+}
+
+double zephir_tan(zval *op1 TSRMLS_DC)
+{
+ switch (Z_TYPE_P(op1)) {
+ case IS_LONG:
+ return tan(Z_LVAL_P(op1));
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
+ }
+
+ return tan(zephir_get_numberval(op1));
+}
+
+
+double zephir_ceil(zval *op1 TSRMLS_DC)
+{
+ switch (Z_TYPE_P(op1)) {
+ case IS_LONG:
+ return (double) Z_LVAL_P(op1);
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
+ }
+ return ceil(zephir_get_numberval(op1));
+}
+
+extern double _php_math_round(double value, int places, int mode);
+
+void zephir_round(zval *return_value, zval *op1, zval *op2, zval *op3 TSRMLS_DC)
+{
+ int places = 0;
+ long mode = PHP_ROUND_HALF_UP;
+ double return_val;
+
+ convert_scalar_to_number_ex(&op1);
+
+ if (op2) {
+ places = zephir_get_intval_ex(op2);
+ }
+ if (op3) {
+ mode = zephir_get_intval_ex(op3);
+ }
+
+ switch (Z_TYPE_PP(&op1)) {
+ case IS_LONG:
+ /* Simple case - long that doesn't need to be rounded. */
+ if (places >= 0) {
+ RETURN_DOUBLE((double) Z_LVAL_PP(&op1));
+ }
+ /* break omitted intentionally */
+
+ case IS_DOUBLE:
+ return_val = (Z_TYPE_PP(&op1) == IS_LONG) ? (double)Z_LVAL_PP(&op1) : Z_DVAL_PP(&op1);
+ return_val = _php_math_round(return_val, places, mode);
+ RETURN_DOUBLE(return_val);
+ break;
+
+ default:
+ RETURN_FALSE;
+ break;
+ }
+}
+
+#if PHP_VERSION_ID < 50600
+#include "Zend/zend_multiply.h"
+void zephir_pow_function_ex(zval *return_value, zval *zbase, zval *zexp TSRMLS_DC)
+{
+ /* make sure we're dealing with numbers */
+ convert_scalar_to_number(zbase TSRMLS_CC);
+ convert_scalar_to_number(zexp TSRMLS_CC);
+
+ /* if both base and exponent were longs, we'll try to get a long out */
+ if (Z_TYPE_P(zbase) == IS_LONG && Z_TYPE_P(zexp) == IS_LONG && Z_LVAL_P(zexp) >= 0) {
+ long l1 = 1, l2 = Z_LVAL_P(zbase), i = Z_LVAL_P(zexp);
+
+ if (i == 0) {
+ RETURN_LONG(1L);
+ } else if (l2 == 0) {
+ RETURN_LONG(0);
+ }
+
+ /* calculate pow(long,long) in O(log exp) operations, bail if overflow */
+ while (i >= 1) {
+ int overflow;
+ double dval = 0.0;
+
+ if (i % 2) {
+ --i;
+ ZEND_SIGNED_MULTIPLY_LONG(l1, l2, l1, dval, overflow);
+ if (overflow) RETURN_DOUBLE(dval * pow(l2, i));
+ } else {
+ i /= 2;
+ ZEND_SIGNED_MULTIPLY_LONG(l2, l2, l2, dval,overflow);
+ if (overflow) RETURN_DOUBLE((double)l1 * pow(dval, i));
+ }
+ if (i == 0) {
+ RETURN_LONG(l1);
+ }
+ }
+ }
+ convert_to_double(zbase);
+ convert_to_double(zexp);
+
+ RETURN_DOUBLE(pow(Z_DVAL_P(zbase), Z_DVAL_P(zexp)));
+}
+#endif
+
+
+
+long zephir_mt_rand(long min, long max TSRMLS_DC) {
+
+ long number;
+
+ if (max < min) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%ld) is smaller than min(%ld)", max, min);
+ return 0;
+ }
+
+ if (!BG(mt_rand_is_seeded)) {
+ php_mt_srand(GENERATE_SEED() TSRMLS_CC);
+ }
+
+ number = (long) (php_mt_rand(TSRMLS_C) >> 1);
+ RAND_RANGE(number, min, max, PHP_MT_RAND_MAX);
+
+ return number;
+}
diff --git a/ext/kernel/math.h b/ext/kernel/math.h
new file mode 100644
index 00000000..f323bf38
--- /dev/null
+++ b/ext/kernel/math.h
@@ -0,0 +1,41 @@
+
+/*
+ +------------------------------------------------------------------------+
+ | Zephir Language |
+ +------------------------------------------------------------------------+
+ | Copyright (c) 2011-2015 Zephir Team (http://www.zephir-lang.com) |
+ +------------------------------------------------------------------------+
+ | This source file is subject to the New BSD License that is bundled |
+ | with this package in the file docs/LICENSE.txt. |
+ | |
+ | If you did not receive a copy of the license and are unable to |
+ | obtain it through the world-wide-web, please send an email |
+ | to license@zephir-lang.com so we can send you a copy immediately. |
+ +------------------------------------------------------------------------+
+ | Authors: Andres Gutierrez |
+ | Eduar Carvajal |
+ +------------------------------------------------------------------------+
+*/
+
+#ifndef ZEPHIR_KERNEL_MATH_H
+#define ZEPHIR_KERNEL_MATH_H
+
+#include
+#include
+
+double zephir_sin(zval *op1 TSRMLS_DC);
+double zephir_asin(zval *op1 TSRMLS_DC);
+double zephir_tan(zval *op1 TSRMLS_DC);
+double zephir_cos(zval *op1 TSRMLS_DC);
+double zephir_acos(zval *op1 TSRMLS_DC);
+double zephir_sqrt(zval *op1 TSRMLS_DC);
+
+double zephir_floor(zval *op1 TSRMLS_DC);
+double zephir_ceil(zval *op1 TSRMLS_DC);
+
+void zephir_round(zval *return_value, zval *op1, zval *op2, zval *op3 TSRMLS_DC);
+void zephir_pow(zval *return_value, zval *op1, zval *op2 TSRMLS_DC);
+
+long zephir_mt_rand(long min, long max TSRMLS_DC);
+
+#endif
diff --git a/ext/kernel/math.h.gch b/ext/kernel/math.h.gch
new file mode 100644
index 00000000..9b3cbc52
Binary files /dev/null and b/ext/kernel/math.h.gch differ
diff --git a/ext/kernel/memory.c b/ext/kernel/memory.c
index 223b91ac..f61e8242 100644
--- a/ext/kernel/memory.c
+++ b/ext/kernel/memory.c
@@ -161,7 +161,7 @@ static void zephir_memory_restore_stack_common(zend_zephir_globals_def *g TSRMLS
ptr = active_memory->addresses[i];
if (EXPECTED(ptr != NULL && *(ptr) != NULL)) {
if (Z_REFCOUNT_PP(ptr) == 1) {
- if (!Z_ISREF_PP(ptr)) {
+ if (!Z_ISREF_PP(ptr) || Z_TYPE_PP(ptr) == IS_OBJECT) {
zval_ptr_dtor(ptr);
} else {
efree(*ptr);
@@ -420,7 +420,7 @@ int zephir_cleanup_fcache(void *pDest TSRMLS_DC, int num_args, va_list args, zen
assert(hash_key->arKey != NULL);
assert(hash_key->nKeyLength > 2 * sizeof(zend_class_entry**));
- memcpy(&scope, &hash_key->arKey[len - 2 * sizeof(zend_class_entry**)], sizeof(zend_class_entry*));
+ memcpy(&scope, &hash_key->arKey[(len -1) - 2 * sizeof(zend_class_entry**)], sizeof(zend_class_entry*));
/*
#ifndef ZEPHIR_RELEASE
@@ -593,7 +593,7 @@ void ZEND_FASTCALL zephir_memory_alloc(zval **var TSRMLS_DC)
*/
void ZEND_FASTCALL zephir_ptr_dtor(zval **var)
{
- if (!Z_ISREF_PP(var)) {
+ if (!Z_ISREF_PP(var) || Z_TYPE_PP(var) == IS_OBJECT) {
zval_ptr_dtor(var);
} else {
if (Z_REFCOUNT_PP(var) == 0) {
diff --git a/ext/kernel/memory.h b/ext/kernel/memory.h
index 9ba73c88..c1c7222d 100644
--- a/ext/kernel/memory.h
+++ b/ext/kernel/memory.h
@@ -21,6 +21,11 @@
#ifndef ZEPHIR_KERNEL_MEMORY_H
#define ZEPHIR_KERNEL_MEMORY_H
+#include
+#include
+#include "php_ext.h"
+#include "kernel/globals.h"
+
#define ZEPHIR_NUM_PREALLOCATED_FRAMES 25
/* Variable Tracking */
@@ -216,7 +221,7 @@ void zephir_deinitialize_memory(TSRMLS_D);
#define ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(ppzv) \
do { \
- zval **tmp_ = (ppzv); \
+ zval ** restrict tmp_ = (ppzv); \
if (tmp_ != NULL) { \
if (*tmp_) { \
zephir_ptr_dtor(tmp_); \
diff --git a/ext/kernel/memory.h.gch b/ext/kernel/memory.h.gch
new file mode 100644
index 00000000..e52c9ffc
Binary files /dev/null and b/ext/kernel/memory.h.gch differ
diff --git a/ext/kernel/object.c b/ext/kernel/object.c
index 5a378b3c..efa09566 100644
--- a/ext/kernel/object.c
+++ b/ext/kernel/object.c
@@ -89,7 +89,9 @@ int zephir_is_instance_of(zval *object, const char *class_name, unsigned int cla
ce = Z_OBJCE_P(object);
if (ce->name_length == class_length) {
- return !zend_binary_strcasecmp(ce->name, ce->name_length, class_name, class_length);
+ if (!zend_binary_strcasecmp(ce->name, ce->name_length, class_name, class_length)) {
+ return 1;
+ }
}
temp_ce = zend_fetch_class(class_name, class_length, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC);
@@ -480,7 +482,7 @@ int zephir_read_property(zval **result, zval *object, const char *property_name,
if (Z_TYPE_P(object) != IS_OBJECT) {
if (silent == PH_NOISY) {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Trying to get property of non-object");
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Trying to get property \"%s\" of non-object", property_name);
}
ALLOC_INIT_ZVAL(*result);
@@ -600,7 +602,7 @@ zval* zephir_fetch_property_this_quick(zval *object, const char *property_name,
} else {
if (silent == PH_NOISY) {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Trying to get property of non-object");
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Trying to get property \"%s\" of non-object", property_name);
}
}
@@ -699,7 +701,7 @@ int zephir_return_property_quick(zval *return_value, zval **return_value_ptr, zv
EG(scope) = old_scope;
} else {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Trying to get property of non-object");
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Trying to get property \"%s\" of non-object", property_name);
}
ZVAL_NULL(return_value);
@@ -839,7 +841,8 @@ int zephir_update_property_zval(zval *object, const char *property_name, unsigne
/**
* Updates properties on this_ptr (quick)
- * Variables must be defined in the class definition. This function ignores magic methods or dynamic properties
+ * If a variable is not defined in the class definition, this fallbacks to update_property_zval
+ * function ignores magic methods or dynamic properties
*/
int zephir_update_property_this_quick(zval *object, const char *property_name, zend_uint property_length, zval *value, ulong key TSRMLS_DC){
@@ -892,7 +895,7 @@ int zephir_update_property_this_quick(zval *object, const char *property_name, z
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 (likely(zephir_hash_quick_find(&ce->properties_info, property_name, property_length + 1, key, (void **) &property_info) == SUCCESS)) {
assert(property_info != NULL);
/** This is as zend_std_write_property, but we're not interesed in validate properties visibility */
@@ -929,6 +932,9 @@ int zephir_update_property_this_quick(zval *object, const char *property_name, z
}
}
+ } else {
+ EG(scope) = old_scope;
+ return zephir_update_property_zval(object, property_name, property_length, value TSRMLS_CC);
}
}
@@ -943,7 +949,7 @@ int zephir_update_property_this_quick(zval *object, const char *property_name, z
* Updates properties on this_ptr
* Variables must be defined in the class definition. This function ignores magic methods or dynamic properties
*/
-int zephir_update_property_this(zval *object, char *property_name, unsigned int property_length, zval *value TSRMLS_DC){
+int zephir_update_property_this(zval *object, char *property_name, unsigned int property_length, zval *value TSRMLS_DC) {
return zephir_update_property_this_quick(object, property_name, property_length, value, zend_inline_hash_func(property_name, property_length + 1) TSRMLS_CC);
}
@@ -951,7 +957,7 @@ int zephir_update_property_this(zval *object, char *property_name, unsigned int
/**
* Checks whether obj is an object and updates zval property with another zval
*/
-int zephir_update_property_zval_zval(zval *object, zval *property, zval *value TSRMLS_DC){
+int zephir_update_property_zval_zval(zval *object, zval *property, zval *value TSRMLS_DC) {
if (Z_TYPE_P(property) != IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property should be string");
@@ -1029,14 +1035,9 @@ int zephir_update_property_array(zval *object, const char *property, zend_uint p
*/
int zephir_update_property_array_multi(zval *object, const char *property, zend_uint property_length, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...) {
va_list ap;
- long old_l[ZEPHIR_MAX_ARRAY_LEVELS], old_ll[ZEPHIR_MAX_ARRAY_LEVELS];
- char *s, *old_s[ZEPHIR_MAX_ARRAY_LEVELS], old_type[ZEPHIR_MAX_ARRAY_LEVELS];
- zval *fetched, *tmp_arr, *tmp, *p, *item, *old_item[ZEPHIR_MAX_ARRAY_LEVELS], *old_p[ZEPHIR_MAX_ARRAY_LEVELS];
- int i, j, l, ll, re_update, must_continue, wrap_tmp;
+ zval *tmp_arr;
int separated = 0;
- va_start(ap, types_count);
-
if (Z_TYPE_P(object) == IS_OBJECT) {
zephir_read_property(&tmp_arr, object, property, property_length, PH_NOISY TSRMLS_CC);
@@ -1075,179 +1076,7 @@ int zephir_update_property_array_multi(zval *object, const char *property, zend_
}
va_start(ap, types_count);
-
- p = tmp_arr;
-
- for (i = 0; i < types_length; ++i) {
- re_update = 0;
- must_continue = 0;
- wrap_tmp = 0;
-
- old_p[i] = p;
- switch (types[i]) {
-
- case 's':
- s = va_arg(ap, char*);
- l = va_arg(ap, int);
- old_s[i] = s;
- old_l[i] = l;
- if (zephir_array_isset_string_fetch(&fetched, p, s, l + 1, 0 TSRMLS_CC)) {
- if (Z_TYPE_P(fetched) == IS_ARRAY) {
- if (i == (types_length - 1)) {
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- zephir_array_update_string(&p, s, l, value, PH_COPY | PH_SEPARATE);
- } else {
- p = fetched;
- }
- must_continue = 1;
- }
- } else {
- Z_DELREF_P(fetched);
- }
- if (!must_continue) {
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- if (i == (types_length - 1)) {
- zephir_array_update_string(&p, s, l, value, PH_COPY | PH_SEPARATE);
- } else {
- MAKE_STD_ZVAL(tmp);
- array_init(tmp);
- zephir_array_update_string(&p, s, l, &tmp, PH_SEPARATE);
- if (re_update) {
- wrap_tmp = 1;
- } else {
- p = tmp;
- }
- }
- }
- break;
-
- case 'l':
- ll = va_arg(ap, long);
- old_ll[i] = ll;
- if (zephir_array_isset_long_fetch(&fetched, p, ll, 0 TSRMLS_CC)) {
- if (Z_TYPE_P(fetched) == IS_ARRAY) {
- if (i == (types_length - 1)) {
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- zephir_array_update_long(&p, ll, value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- } else {
- p = fetched;
- }
- must_continue = 1;
- }
- } else {
- Z_DELREF_P(fetched);
- }
- if (!must_continue) {
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- if (i == (types_length - 1)) {
- zephir_array_update_long(&p, ll, value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- } else {
- MAKE_STD_ZVAL(tmp);
- array_init(tmp);
- zephir_array_update_long(&p, ll, &tmp, PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- if (re_update) {
- wrap_tmp = 1;
- } else {
- p = tmp;
- }
- }
- }
- break;
-
- case 'z':
- item = va_arg(ap, zval*);
- old_item[i] = item;
- if (zephir_array_isset_fetch(&fetched, p, item, 0 TSRMLS_CC)) {
- if (Z_TYPE_P(fetched) == IS_ARRAY) {
- if (i == (types_length - 1)) {
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- zephir_array_update_zval(&p, item, value, PH_COPY | PH_SEPARATE);
- } else {
- p = fetched;
- }
- must_continue = 1;
- }
- } else {
- Z_DELREF_P(fetched);
- }
- if (!must_continue) {
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- if (i == (types_length - 1)) {
- zephir_array_update_zval(&p, item, value, PH_COPY | PH_SEPARATE);
- } else {
- MAKE_STD_ZVAL(tmp);
- array_init(tmp);
- zephir_array_update_zval(&p, item, &tmp, PH_SEPARATE);
- if (re_update) {
- wrap_tmp = 1;
- } else {
- p = tmp;
- }
- }
- }
- break;
-
- case 'a':
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- zephir_array_append(&p, *value, PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- break;
- }
-
- if (re_update) {
- for (j = i - 1; j >= 0; j--) {
-
- if (!re_update) {
- break;
- }
-
- re_update = Z_REFCOUNT_P(old_p[j]) > 1 && !Z_ISREF_P(old_p[j]);
- switch (old_type[j]) {
-
- case 's':
- if (j == i - 1) {
- zephir_array_update_string(&(old_p[j]), old_s[j], old_l[j], &p, PH_SEPARATE);
- } else {
- zephir_array_update_string(&(old_p[j]), old_s[j], old_l[j], &old_p[j+1], PH_SEPARATE);
- }
- if (wrap_tmp) {
- p = tmp;
- wrap_tmp = 0;
- }
- break;
-
- case 'l':
- if (j == i - 1) {
- zephir_array_update_long(&(old_p[j]), old_ll[j], &p, PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- } else {
- zephir_array_update_long(&(old_p[j]), old_ll[j], &old_p[j+1], PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- }
- if (wrap_tmp) {
- p = tmp;
- wrap_tmp = 0;
- }
- break;
-
- case 'z':
- if (j == i - 1) {
- zephir_array_update_zval(&(old_p[j]), old_item[j], &p, PH_SEPARATE);
- } else {
- zephir_array_update_zval(&(old_p[j]), old_item[j], &old_p[j+1], PH_SEPARATE);
- }
- if (wrap_tmp) {
- p = tmp;
- wrap_tmp = 0;
- }
- break;
- }
-
- }
- }
-
- if (i != (types_length - 1)) {
- old_type[i] = types[i];
- }
- }
-
+ zephir_array_update_multi_ex(&tmp_arr, value, types, types_length, types_count, ap TSRMLS_CC);
va_end(ap);
if (separated) {
@@ -1679,10 +1508,7 @@ int zephir_update_static_property_ce_cache(zend_class_entry *ce, const char *nam
int zephir_update_static_property_array_multi_ce(zend_class_entry *ce, const char *property, zend_uint property_length, zval **value TSRMLS_DC, const char *types, int types_length, int types_count, ...) {
va_list ap;
- long old_l[ZEPHIR_MAX_ARRAY_LEVELS], old_ll[ZEPHIR_MAX_ARRAY_LEVELS];
- char *s, *old_s[ZEPHIR_MAX_ARRAY_LEVELS], old_type[ZEPHIR_MAX_ARRAY_LEVELS];
- zval *fetched, *tmp, *tmp_arr, *p, *item, *old_item[ZEPHIR_MAX_ARRAY_LEVELS], *old_p[ZEPHIR_MAX_ARRAY_LEVELS];
- int i, j, l, ll, re_update, must_continue, wrap_tmp;
+ zval *tmp_arr;
int separated = 0;
tmp_arr = zephir_fetch_static_property_ce(ce, property, property_length TSRMLS_CC);
@@ -1724,176 +1550,7 @@ int zephir_update_static_property_array_multi_ce(zend_class_entry *ce, const cha
}
va_start(ap, types_count);
-
- p = tmp_arr;
- for (i = 0; i < types_length; ++i) {
-
- re_update = 0;
- must_continue = 0;
- wrap_tmp = 0;
-
- old_p[i] = p;
- switch (types[i]) {
-
- case 's':
- s = va_arg(ap, char*);
- l = va_arg(ap, int);
- old_s[i] = s;
- old_l[i] = l;
- if (zephir_array_isset_string_fetch(&fetched, p, s, l + 1, 0 TSRMLS_CC)) {
- if (Z_TYPE_P(fetched) == IS_ARRAY) {
- if (i == (types_length - 1)) {
- zephir_array_update_string(&fetched, s, l, value, PH_COPY | PH_SEPARATE);
- } else {
- p = fetched;
- }
- must_continue = 1;
- }
- } else {
- Z_DELREF_P(fetched);
- }
- if (!must_continue) {
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- if (i == (types_length - 1)) {
- zephir_array_update_string(&p, s, l, value, PH_COPY | PH_SEPARATE);
- } else {
- MAKE_STD_ZVAL(tmp);
- array_init(tmp);
- zephir_array_update_string(&p, s, l, &tmp, PH_SEPARATE);
- if (re_update) {
- wrap_tmp = 1;
- } else {
- p = tmp;
- }
- }
- }
- break;
-
- case 'l':
- ll = va_arg(ap, long);
- old_ll[i] = ll;
- if (zephir_array_isset_long_fetch(&fetched, p, ll, 0 TSRMLS_CC)) {
- if (Z_TYPE_P(fetched) == IS_ARRAY) {
- if (i == (types_length - 1)) {
- zephir_array_update_long(&fetched, ll, value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- } else {
- p = fetched;
- }
- must_continue = 1;
- }
- } else {
- Z_DELREF_P(fetched);
- }
- if (!must_continue) {
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- if (i == (types_length - 1)) {
- zephir_array_update_long(&p, ll, value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- } else {
- MAKE_STD_ZVAL(tmp);
- array_init(tmp);
- zephir_array_update_long(&p, ll, &tmp, PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- if (re_update) {
- wrap_tmp = 1;
- } else {
- p = tmp;
- }
- }
- }
- break;
-
- case 'z':
- item = va_arg(ap, zval*);
- old_item[i] = item;
- if (zephir_array_isset_fetch(&fetched, p, item, 0 TSRMLS_CC)) {
- if (Z_TYPE_P(fetched) == IS_ARRAY) {
- if (i == (types_length - 1)) {
- zephir_array_update_zval(&fetched, item, value, PH_COPY | PH_SEPARATE);
- } else {
- p = fetched;
- }
- must_continue = 1;
- }
- } else {
- Z_DELREF_P(fetched);
- }
- if (!must_continue) {
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- if (i == (types_length - 1)) {
- zephir_array_update_zval(&p, item, value, PH_COPY | PH_SEPARATE);
- } else {
- MAKE_STD_ZVAL(tmp);
- array_init(tmp);
- zephir_array_update_zval(&p, item, &tmp, PH_SEPARATE);
- if (re_update) {
- wrap_tmp = 1;
- } else {
- p = tmp;
- }
- }
- }
- break;
-
- case 'a':
- re_update = Z_REFCOUNT_P(p) > 1 && !Z_ISREF_P(p);
- zephir_array_append(&p, *value, PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- break;
- }
-
- if (re_update) {
- for (j = i - 1; j >= 0; j--) {
-
- if (!re_update) {
- break;
- }
-
- re_update = Z_REFCOUNT_P(old_p[j]) > 1 && !Z_ISREF_P(old_p[j]);
- switch (old_type[j]) {
-
- case 's':
- if (j == i - 1) {
- zephir_array_update_string(&(old_p[j]), old_s[j], old_l[j], &p, PH_SEPARATE);
- } else {
- zephir_array_update_string(&(old_p[j]), old_s[j], old_l[j], &old_p[j+1], PH_SEPARATE);
- }
- if (wrap_tmp) {
- p = tmp;
- wrap_tmp = 0;
- }
- break;
-
- case 'l':
- if (j == i - 1) {
- zephir_array_update_long(&(old_p[j]), old_ll[j], &p, PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- } else {
- zephir_array_update_long(&(old_p[j]), old_ll[j], &old_p[j+1], PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
- }
- if (wrap_tmp) {
- p = tmp;
- wrap_tmp = 0;
- }
- break;
-
- case 'z':
- if (j == i - 1) {
- zephir_array_update_zval(&(old_p[j]), old_item[j], &p, PH_SEPARATE);
- } else {
- zephir_array_update_zval(&(old_p[j]), old_item[j], &old_p[j+1], PH_SEPARATE);
- }
- if (wrap_tmp) {
- p = tmp;
- wrap_tmp = 0;
- }
- break;
- }
-
- }
- }
-
- if (i != (types_length - 1)) {
- old_type[i] = types[i];
- }
- }
-
+ zephir_array_update_multi_ex(&tmp_arr, value, types, types_length, types_count, ap TSRMLS_CC);
va_end(ap);
if (separated) {
@@ -1948,7 +1605,7 @@ int zephir_create_instance(zval *return_value, const zval *class_name TSRMLS_DC)
object_init_ex(return_value, ce);
if (zephir_has_constructor_ce(ce)) {
- return zephir_call_class_method_aparams(NULL, ce, zephir_fcall_method, return_value, SL("__construct"), NULL, 0, NULL TSRMLS_CC);
+ return zephir_call_class_method_aparams(NULL, ce, zephir_fcall_method, return_value, SL("__construct"), NULL, 0, 0, NULL TSRMLS_CC);
}
return SUCCESS;
@@ -2010,7 +1667,7 @@ int zephir_create_instance_params(zval *return_value, const zval *class_name, zv
params_ptr = NULL;
}
- outcome = zephir_call_class_method_aparams(NULL, ce, zephir_fcall_method, return_value, SL("__construct"), NULL, param_count, params_ptr TSRMLS_CC);
+ outcome = zephir_call_class_method_aparams(NULL, ce, zephir_fcall_method, return_value, SL("__construct"), NULL, 0, param_count, params_ptr TSRMLS_CC);
if (unlikely(params_arr != NULL)) {
efree(params_arr);
@@ -2171,4 +1828,3 @@ int zephir_create_closure_ex(zval *return_value, zval *this_ptr, zend_class_entr
#endif
return SUCCESS;
}
-
diff --git a/ext/kernel/object.h b/ext/kernel/object.h
index 0582d7a5..7490625a 100644
--- a/ext/kernel/object.h
+++ b/ext/kernel/object.h
@@ -21,6 +21,12 @@
#ifndef ZEPHIR_KERNEL_OBJECT_H
#define ZEPHIR_KERNEL_OBJECT_H
+#include
+#include
+
+#include "kernel/globals.h"
+#include "kernel/main.h"
+
/** Class Retrieving/Checking */
int zephir_class_exists(const zval *class_name, int autoload TSRMLS_DC);
int zephir_interface_exists(const zval *interface_name, int autoload TSRMLS_DC);
diff --git a/ext/kernel/object.h.gch b/ext/kernel/object.h.gch
new file mode 100644
index 00000000..4d2c4d5b
Binary files /dev/null and b/ext/kernel/object.h.gch differ
diff --git a/ext/kernel/operators.c b/ext/kernel/operators.c
index b0545868..bf30db3a 100644
--- a/ext/kernel/operators.c
+++ b/ext/kernel/operators.c
@@ -22,9 +22,10 @@
#include "config.h"
#endif
-#include "php.h"
-#include "ext/standard/php_string.h"
-#include "ext/standard/php_math.h"
+#include
+#include
+#include
+
#include "php_ext.h"
#include "kernel/main.h"
#include "kernel/memory.h"
@@ -371,7 +372,11 @@ 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;
@@ -629,6 +634,18 @@ int zephir_less_equal(zval *op1, zval *op2 TSRMLS_DC) {
int zephir_less_long(zval *op1, long op2 TSRMLS_DC) {
zval result, op2_zval;
ZVAL_LONG(&op2_zval, op2);
+
+ is_smaller_function(&result, op1, &op2_zval TSRMLS_CC);
+ return Z_BVAL(result);
+}
+
+/**
+ * Check if a zval is less than a double value
+ */
+int zephir_less_double(zval *op1, double op2 TSRMLS_DC) {
+ zval result, op2_zval;
+ ZVAL_DOUBLE(&op2_zval, op2);
+
is_smaller_function(&result, op1, &op2_zval TSRMLS_CC);
return Z_BVAL(result);
}
@@ -636,6 +653,7 @@ int zephir_less_long(zval *op1, long op2 TSRMLS_DC) {
int zephir_less_equal_long(zval *op1, long op2 TSRMLS_DC) {
zval result, op2_zval;
ZVAL_LONG(&op2_zval, op2);
+
is_smaller_or_equal_function(&result, op1, &op2_zval TSRMLS_CC);
return Z_BVAL(result);
}
@@ -655,6 +673,18 @@ int zephir_greater(zval *op1, zval *op2 TSRMLS_DC) {
int zephir_greater_long(zval *op1, long op2 TSRMLS_DC) {
zval result, op2_zval;
ZVAL_LONG(&op2_zval, op2);
+
+ is_smaller_or_equal_function(&result, op1, &op2_zval TSRMLS_CC);
+ return !Z_BVAL(result);
+}
+
+/**
+ * Check if a zval is greater than a double value
+ */
+int zephir_greater_double(zval *op1, double op2 TSRMLS_DC) {
+ zval result, op2_zval;
+ ZVAL_DOUBLE(&op2_zval, op2);
+
is_smaller_or_equal_function(&result, op1, &op2_zval TSRMLS_CC);
return !Z_BVAL(result);
}
@@ -868,109 +898,118 @@ double zephir_safe_div_double_zval(double op1, zval *op2 TSRMLS_DC) {
return op1 / ((double) zephir_get_numberval(op2));
}
-void zephir_floor(zval *return_value, zval *op1 TSRMLS_DC)
-{
- convert_scalar_to_number_ex(&op1);
-
- if (Z_TYPE_PP(&op1) == IS_DOUBLE) {
- RETURN_DOUBLE(floor(Z_DVAL_PP(&op1)));
- } else if (Z_TYPE_PP(&op1) == IS_LONG) {
- convert_to_double_ex(&op1);
- RETURN_DOUBLE(Z_DVAL_PP(&op1));
+/**
+ * Do safe divisions between two longs
+ */
+long zephir_safe_mod_long_long(long op1, long op2 TSRMLS_DC) {
+ if (!op2) {
+ zend_error(E_WARNING, "Division by zero");
+ return 0;
}
- RETURN_FALSE;
+ return op1 % op2;
}
-void zephir_ceil(zval *return_value, zval *op1 TSRMLS_DC)
-{
- convert_scalar_to_number_ex(&op1);
-
- if (Z_TYPE_PP(&op1) == IS_DOUBLE) {
- RETURN_DOUBLE(ceil(Z_DVAL_PP(&op1)));
- } else if (Z_TYPE_PP(&op1) == IS_LONG) {
- convert_to_double_ex(&op1);
- RETURN_DOUBLE(Z_DVAL_PP(&op1));
+/**
+ * Do safe divisions between two long/double
+ */
+long zephir_safe_mod_long_double(long op1, double op2 TSRMLS_DC) {
+ if (!op2) {
+ zend_error(E_WARNING, "Division by zero");
+ return 0;
}
- RETURN_FALSE;
+ return op1 % (long) op2;
}
-extern double _php_math_round(double value, int places, int mode);
-
-void zephir_round(zval *return_value, zval *op1, zval *op2, zval *op3 TSRMLS_DC)
-{
- int places = 0;
- long mode = PHP_ROUND_HALF_UP;
- double return_val;
+/**
+ * Do safe divisions between two double/long
+ */
+long zephir_safe_mod_double_long(double op1, long op2 TSRMLS_DC) {
+ if (!op2) {
+ zend_error(E_WARNING, "Division by zero");
+ return 0;
+ }
+ return (long) op1 % op2;
+}
- convert_scalar_to_number_ex(&op1);
+/**
+ * Do safe divisions between two doubles
+ */
+long zephir_safe_mod_double_double(double op1, double op2 TSRMLS_DC) {
+ if (!op2) {
+ zend_error(E_WARNING, "Division by zero");
+ return 0;
+ }
+ return (long) op1 % (long) op2;
+}
- if (op2) {
- places = zephir_get_intval_ex(op2);
+/**
+ * Do safe divisions between two zval/long
+ */
+long zephir_safe_mod_zval_long(zval *op1, long op2 TSRMLS_DC) {
+ if (!op2) {
+ zend_error(E_WARNING, "Division by zero");
+ return 0;
}
- if (op3) {
- mode = zephir_get_intval_ex(op3);
+ switch (Z_TYPE_P(op1)) {
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
}
+ return ((long) zephir_get_numberval(op1)) % (long) op2;
+}
- switch (Z_TYPE_PP(&op1)) {
- case IS_LONG:
- /* Simple case - long that doesn't need to be rounded. */
- if (places >= 0) {
- RETURN_DOUBLE((double) Z_LVAL_PP(&op1));
- }
- /* break omitted intentionally */
-
- case IS_DOUBLE:
- return_val = (Z_TYPE_PP(&op1) == IS_LONG) ? (double)Z_LVAL_PP(&op1) : Z_DVAL_PP(&op1);
- return_val = _php_math_round(return_val, places, mode);
- RETURN_DOUBLE(return_val);
+/**
+ * Do safe divisions between two zval/double
+ */
+long zephir_safe_mod_zval_double(zval *op1, double op2 TSRMLS_DC) {
+ if (!op2) {
+ zend_error(E_WARNING, "Division by zero");
+ return 0;
+ }
+ switch (Z_TYPE_P(op1)) {
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
break;
+ }
+ return ((long) zephir_get_numberval(op1)) % (long) op2;
+}
- default:
- RETURN_FALSE;
+/**
+ * Do safe divisions between two long/zval
+ */
+long zephir_safe_mod_long_zval(long op1, zval *op2 TSRMLS_DC) {
+ if (!zephir_get_numberval(op2)) {
+ zend_error(E_WARNING, "Division by zero");
+ return 0;
+ }
+ switch (Z_TYPE_P(op2)) {
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
break;
}
+ return op1 % ((long) zephir_get_numberval(op2));
}
-#if PHP_VERSION_ID < 50600
-#include "Zend/zend_multiply.h"
-void zephir_pow_function_ex(zval *return_value, zval *zbase, zval *zexp TSRMLS_DC)
-{
- /* make sure we're dealing with numbers */
- convert_scalar_to_number(zbase TSRMLS_CC);
- convert_scalar_to_number(zexp TSRMLS_CC);
-
- /* if both base and exponent were longs, we'll try to get a long out */
- if (Z_TYPE_P(zbase) == IS_LONG && Z_TYPE_P(zexp) == IS_LONG && Z_LVAL_P(zexp) >= 0) {
- long l1 = 1, l2 = Z_LVAL_P(zbase), i = Z_LVAL_P(zexp);
-
- if (i == 0) {
- RETURN_LONG(1L);
- } else if (l2 == 0) {
- RETURN_LONG(0);
- }
-
- /* calculate pow(long,long) in O(log exp) operations, bail if overflow */
- while (i >= 1) {
- int overflow;
- double dval = 0.0;
-
- if (i % 2) {
- --i;
- ZEND_SIGNED_MULTIPLY_LONG(l1, l2, l1, dval, overflow);
- if (overflow) RETURN_DOUBLE(dval * pow(l2, i));
- } else {
- i /= 2;
- ZEND_SIGNED_MULTIPLY_LONG(l2, l2, l2, dval,overflow);
- if (overflow) RETURN_DOUBLE((double)l1 * pow(dval, i));
- }
- if (i == 0) {
- RETURN_LONG(l1);
- }
- }
+/**
+ * Do safe divisions between two double/zval
+ */
+long zephir_safe_mod_double_zval(double op1, zval *op2 TSRMLS_DC) {
+ if (!zephir_get_numberval(op2)) {
+ zend_error(E_WARNING, "Division by zero");
+ return 0;
}
- convert_to_double(zbase);
- convert_to_double(zexp);
-
- RETURN_DOUBLE(pow(Z_DVAL_P(zbase), Z_DVAL_P(zexp)));
+ switch (Z_TYPE_P(op2)) {
+ case IS_ARRAY:
+ case IS_OBJECT:
+ case IS_RESOURCE:
+ zend_error(E_WARNING, "Unsupported operand types");
+ break;
+ }
+ return (long) op1 % ((long) zephir_get_numberval(op2));
}
-#endif
diff --git a/ext/kernel/operators.h b/ext/kernel/operators.h
index 7c953a01..9878e3bb 100644
--- a/ext/kernel/operators.h
+++ b/ext/kernel/operators.h
@@ -21,6 +21,9 @@
#ifndef ZEPHIR_KERNEL_OPERATORS_H
#define ZEPHIR_KERNEL_OPERATORS_H
+#include
+#include
+
/** Strict comparing */
#define ZEPHIR_IS_LONG(op1, op2) ((Z_TYPE_P(op1) == IS_LONG && Z_LVAL_P(op1) == op2) || zephir_compare_strict_long(op1, op2 TSRMLS_CC))
#define ZEPHIR_IS_DOUBLE(op1, op2) ((Z_TYPE_P(op1) == IS_DOUBLE && Z_DVAL_P(op1) == op2) || zephir_compare_strict_double(op1, op2 TSRMLS_CC))
@@ -82,12 +85,12 @@
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, t) sub_function(result, left, right TSRMLS_CC)
-#define zephir_add_function(result, left, right, t) zephir_add_function_ex(result, left, right TSRMLS_CC)
+#define zephir_sub_function(result, left, right) sub_function(result, left, right TSRMLS_CC)
#else
-#define zephir_add_function(result, left, right, t) fast_add_function(result, left, right TSRMLS_CC)
-#define zephir_sub_function(result, left, right, t) fast_sub_function(result, left, right TSRMLS_CC)
+#define zephir_sub_function(result, left, right) fast_sub_function(result, left, right TSRMLS_CC)
#endif
#if PHP_VERSION_ID < 50600
@@ -133,9 +136,11 @@ int zephir_is_identical(zval *op1, zval *op2 TSRMLS_DC);
int zephir_less(zval *op1, zval *op2 TSRMLS_DC);
int zephir_less_long(zval *op1, long op2 TSRMLS_DC);
+int zephir_less_double(zval *op1, double op2 TSRMLS_DC);
int zephir_greater(zval *op1, zval *op2 TSRMLS_DC);
int zephir_greater_long(zval *op1, long op2 TSRMLS_DC);
+int zephir_greater_double(zval *op1, double op2 TSRMLS_DC);
int zephir_less_equal(zval *op1, zval *op2 TSRMLS_DC);
int zephir_less_equal_long(zval *op1, long op2 TSRMLS_DC);
@@ -152,10 +157,14 @@ double zephir_safe_div_zval_double(zval *op1, double op2 TSRMLS_DC);
double zephir_safe_div_long_zval(long op1, zval *op2 TSRMLS_DC);
double zephir_safe_div_double_zval(double op1, zval *op2 TSRMLS_DC);
-void zephir_floor(zval *return_value, zval *op1 TSRMLS_DC);
-void zephir_ceil(zval *return_value, zval *op1 TSRMLS_DC);
-void zephir_round(zval *return_value, zval *op1, zval *op2, zval *op3 TSRMLS_DC);
-void zephir_pow(zval *return_value, zval *op1, zval *op2 TSRMLS_DC);
+long zephir_safe_mod_long_long(long op1, long op2 TSRMLS_DC);
+long zephir_safe_mod_long_double(long op1, double op2 TSRMLS_DC);
+long zephir_safe_mod_double_long(double op1, long op2 TSRMLS_DC);
+long zephir_safe_mod_double_double(double op1, double op2 TSRMLS_DC);
+long zephir_safe_mod_zval_long(zval *op1, long op2 TSRMLS_DC);
+long zephir_safe_mod_zval_double(zval *op1, double op2 TSRMLS_DC);
+long zephir_safe_mod_long_zval(long op1, zval *op2 TSRMLS_DC);
+long zephir_safe_mod_double_zval(double op1, zval *op2 TSRMLS_DC);
#define zephir_get_numberval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_doubleval(z))
#define zephir_get_intval(z) (Z_TYPE_P(z) == IS_LONG ? Z_LVAL_P(z) : zephir_get_intval_ex(z))
@@ -307,7 +316,7 @@ void zephir_pow(zval *return_value, zval *op1, zval *op2 TSRMLS_DC);
#define zephir_is_true(value) \
(Z_TYPE_P(value) == IS_NULL ? 0 : \
(Z_TYPE_P(value) == IS_BOOL ? Z_BVAL_P(value) : \
- (Z_TYPE_P(value) == IS_LONG ? Z_LVAL_P(value) : \
+ (Z_TYPE_P(value) == IS_LONG ? (Z_LVAL_P(value) ? 1 : 0) : \
zend_is_true(value) \
) \
) \
diff --git a/ext/kernel/operators.h.gch b/ext/kernel/operators.h.gch
new file mode 100644
index 00000000..cb70329f
Binary files /dev/null and b/ext/kernel/operators.h.gch differ
diff --git a/ext/kernel/output.h b/ext/kernel/output.h
index 7da88cc4..db406106 100644
--- a/ext/kernel/output.h
+++ b/ext/kernel/output.h
@@ -21,6 +21,8 @@
#ifndef ZEPHIR_KERNEL_OUTPUT_H
#define ZEPHIR_KERNEL_OUTPUT_H
+#include
+
void zephir_ob_start(TSRMLS_D);
void zephir_ob_get_contents(zval *result TSRMLS_DC);
int zephir_ob_end_flush(TSRMLS_D);
diff --git a/ext/kernel/output.h.gch b/ext/kernel/output.h.gch
new file mode 100644
index 00000000..3958cd84
Binary files /dev/null and b/ext/kernel/output.h.gch differ
diff --git a/ext/kernel/persistent.h b/ext/kernel/persistent.h
index 2d89686b..400cfb21 100644
--- a/ext/kernel/persistent.h
+++ b/ext/kernel/persistent.h
@@ -17,5 +17,12 @@
+------------------------------------------------------------------------+
*/
+#ifndef ZEPHIR_KERNEL_PERSISTENT_H
+#define ZEPHIR_KERNEL_PERSISTENT_H
+
+#include
+
int zephir_persistent_store(zval *service, zval *object TSRMLS_DC);
int zephir_persistent_fetch(zval *return_value, zval *service TSRMLS_DC);
+
+#endif
\ No newline at end of file
diff --git a/ext/kernel/persistent.h.gch b/ext/kernel/persistent.h.gch
new file mode 100644
index 00000000..2149fc06
Binary files /dev/null and b/ext/kernel/persistent.h.gch differ
diff --git a/ext/kernel/require.c b/ext/kernel/require.c
index ed96cc8b..bff12c36 100644
--- a/ext/kernel/require.c
+++ b/ext/kernel/require.c
@@ -40,7 +40,8 @@
int zephir_require_ret(zval **return_value_ptr, const char *require_path TSRMLS_DC)
{
zend_file_handle file_handle;
- int ret, use_ret, mode;
+ int ret, use_ret;
+ zend_op_array *new_op_array;
#ifndef ZEPHIR_RELEASE
if (return_value_ptr && *return_value_ptr) {
@@ -55,37 +56,32 @@ int zephir_require_ret(zval **return_value_ptr, const char *require_path TSRMLS_
return FAILURE;
}
- mode = ENFORCE_SAFE_MODE | USE_PATH | STREAM_OPEN_FOR_INCLUDE;
-
- if (strlen(require_path) < 7 || memcmp(require_path, "phar://", 7)) {
- /* No phar archive */
- mode |= IGNORE_URL;
- }
-
use_ret = !!return_value_ptr;
- ret = php_stream_open_for_zend_ex(require_path, &file_handle, mode TSRMLS_CC);
- if (ret == SUCCESS) {
-
- int dummy = 1;
- zend_op_array *new_op_array;
+ file_handle.filename = require_path;
+ file_handle.free_filename = 0;
+ file_handle.type = ZEND_HANDLE_FILENAME;
+ file_handle.opened_path = NULL;
+ file_handle.handle.fp = NULL;
+ new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
+ if (new_op_array) {
+ if (file_handle.handle.stream.handle) {
+ int dummy = 1;
+
+ if (!file_handle.opened_path) {
+ file_handle.opened_path = estrdup(require_path);
+ }
- if (!file_handle.opened_path) {
- file_handle.opened_path = estrdup(require_path);
+ zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path) + 1, (void *)&dummy, sizeof(int), NULL);
+ zend_destroy_file_handle(&file_handle TSRMLS_CC);
}
-
- zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL);
- new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC);
- zend_destroy_file_handle(&file_handle TSRMLS_CC);
-
- if (new_op_array) {
-
- zval **original_return_value = EG(return_value_ptr_ptr);
+ {
+ zval **original_return_value = EG(return_value_ptr_ptr);
zend_op_array *original_active_op_array = EG(active_op_array);
- zend_op **original_opline_ptr = EG(opline_ptr);
+ zend_op **original_opline_ptr = EG(opline_ptr);
EG(return_value_ptr_ptr) = return_value_ptr;
- EG(active_op_array) = new_op_array;
+ EG(active_op_array) = new_op_array;
zend_execute(new_op_array TSRMLS_CC);
zend_exception_restore(TSRMLS_C);
@@ -95,19 +91,14 @@ int zephir_require_ret(zval **return_value_ptr, const char *require_path TSRMLS_
if (EG(exception)) {
assert(!return_value_ptr || !*return_value_ptr);
ret = FAILURE;
- } else {
- ret = SUCCESS;
}
-
- if (!use_ret) {
- if (EG(return_value_ptr_ptr)) {
- zval_ptr_dtor(EG(return_value_ptr_ptr));
- }
+ else {
+ ret = SUCCESS;
}
EG(return_value_ptr_ptr) = original_return_value;
- EG(active_op_array) = original_active_op_array;
- EG(opline_ptr) = original_opline_ptr;
+ EG(active_op_array) = original_active_op_array;
+ EG(opline_ptr) = original_opline_ptr;
return ret;
}
}
diff --git a/ext/kernel/require.h.gch b/ext/kernel/require.h.gch
new file mode 100644
index 00000000..ce9b08fd
Binary files /dev/null and b/ext/kernel/require.h.gch differ
diff --git a/ext/kernel/session.h b/ext/kernel/session.h
index 0acc4306..dd562ab8 100644
--- a/ext/kernel/session.h
+++ b/ext/kernel/session.h
@@ -21,6 +21,9 @@
#ifndef ZEPHIR_KERNEL_SESSION_H
#define ZEPHIR_KERNEL_SESSION_H
+#include
+#include
+
void zephir_session_start(TSRMLS_D);
void zephir_session_destroy(TSRMLS_D);
void zephir_get_session_id(zval *return_value, zval **return_value_ptr TSRMLS_DC);
diff --git a/ext/kernel/session.h.gch b/ext/kernel/session.h.gch
new file mode 100644
index 00000000..7bc90b57
Binary files /dev/null and b/ext/kernel/session.h.gch differ
diff --git a/ext/kernel/string.c b/ext/kernel/string.c
index 47e5764a..e409cca0 100644
--- a/ext/kernel/string.c
+++ b/ext/kernel/string.c
@@ -141,7 +141,7 @@ void zephir_strtolower_inplace(zval *s) {
/**
* Fast call to php join function
*/
-void zephir_fast_join(zval *result, zval *glue, zval *pieces TSRMLS_DC){
+void zephir_fast_join(zval *result, zval *glue, zval *pieces TSRMLS_DC) {
if (Z_TYPE_P(glue) != IS_STRING || Z_TYPE_P(pieces) != IS_ARRAY) {
ZVAL_NULL(result);
@@ -212,7 +212,7 @@ void zephir_append_printable_zval(smart_str *implstr, zval **tmp TSRMLS_DC) {
* This function is an adaption of the php_implode function
*
*/
-void zephir_fast_join_str(zval *return_value, char *glue, unsigned int glue_length, zval *pieces TSRMLS_DC){
+void zephir_fast_join_str(zval *return_value, char *glue, unsigned int glue_length, zval *pieces TSRMLS_DC) {
zval **tmp;
HashTable *arr;
@@ -254,9 +254,9 @@ void zephir_fast_join_str(zval *return_value, char *glue, unsigned int glue_leng
/**
* Convert dash/underscored texts returning camelized
*/
-void zephir_camelize(zval *return_value, const zval *str){
+void zephir_camelize(zval *return_value, const zval *str) {
- int i, len;
+ int i, len, first = 0;
smart_str camelize_str = {0};
char *marker, ch;
@@ -268,41 +268,46 @@ void zephir_camelize(zval *return_value, const zval *str){
marker = Z_STRVAL_P(str);
len = Z_STRLEN_P(str);
- for (i = 0; i < len - 1; i++) {
- ch = *marker;
- if (i == 0 || ch == '-' || ch == '_') {
+ for (i = 0; i < len; i++) {
+
+ ch = marker[i];
+
+ if (first == 0) {
+
if (ch == '-' || ch == '_') {
- i++;
- marker++;
+ continue;
}
- smart_str_appendc(&camelize_str, toupper(*marker));
- }
- else {
- smart_str_appendc(&camelize_str, tolower(*marker));
+ first = 1;
+ smart_str_appendc(&camelize_str, toupper(ch));
+ continue;
}
- marker++;
- }
+ if (ch == '-' || ch == '_') {
+ if (i != (len - 1)) {
+ i++;
+ ch = marker[i];
+ smart_str_appendc(&camelize_str, toupper(ch));
+ }
+ continue;
+ }
- if (likely(i == len - 1)) {
- smart_str_appendc(&camelize_str, *marker);
+ smart_str_appendc(&camelize_str, tolower(ch));
}
smart_str_0(&camelize_str);
if (camelize_str.c) {
RETURN_STRINGL(camelize_str.c, camelize_str.len, 0);
- } else {
- RETURN_EMPTY_STRING();
}
+ RETURN_EMPTY_STRING();
}
/**
* Convert dash/underscored texts returning camelized
*/
-void zephir_uncamelize(zval *return_value, const zval *str){
+void zephir_uncamelize(zval *return_value, const zval *str) {
unsigned int i;
smart_str uncamelize_str = {0};
@@ -315,10 +320,13 @@ void zephir_uncamelize(zval *return_value, const zval *str){
marker = Z_STRVAL_P(str);
for (i = 0; i < Z_STRLEN_P(str); i++) {
+
ch = *marker;
+
if (ch == '\0') {
break;
}
+
if (ch >= 'A' && ch <= 'Z') {
if (i > 0) {
smart_str_appendc(&uncamelize_str, '_');
@@ -327,6 +335,7 @@ void zephir_uncamelize(zval *return_value, const zval *str){
} else {
smart_str_appendc(&uncamelize_str, (*marker));
}
+
marker++;
}
smart_str_0(&uncamelize_str);
@@ -341,7 +350,7 @@ void zephir_uncamelize(zval *return_value, const zval *str){
/**
* Fast call to explode php function
*/
-void zephir_fast_explode(zval *return_value, zval *delimiter, zval *str, long limit TSRMLS_DC){
+void zephir_fast_explode(zval *return_value, zval *delimiter, zval *str, long limit TSRMLS_DC) {
if (unlikely(Z_TYPE_P(str) != IS_STRING || Z_TYPE_P(delimiter) != IS_STRING)) {
zend_error(E_WARNING, "Invalid arguments supplied for explode()");
@@ -355,7 +364,7 @@ void zephir_fast_explode(zval *return_value, zval *delimiter, zval *str, long li
/**
* Fast call to explode php function
*/
-void zephir_fast_explode_str(zval *return_value, const char *delimiter, int delimiter_length, zval *str, long limit TSRMLS_DC){
+void zephir_fast_explode_str(zval *return_value, const char *delimiter, int delimiter_length, zval *str, long limit TSRMLS_DC) {
zval delimiter_zval;
@@ -467,7 +476,6 @@ void zephir_fast_strpos_str(zval *return_value, const zval *haystack, char *need
} else {
ZVAL_BOOL(return_value, 0);
}
-
}
/**
@@ -500,16 +508,15 @@ void zephir_fast_stripos_str(zval *return_value, zval *haystack, char *needle, u
} else {
ZVAL_BOOL(return_value, 0);
}
-
}
-
/**
* Immediate function resolution for str_replace function
*/
-void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject TSRMLS_DC) {
+void zephir_fast_str_replace(zval **return_value_ptr, zval *search, zval *replace, zval *subject TSRMLS_DC) {
zval replace_copy, search_copy;
+ zval *return_value = *return_value_ptr;
int copy_replace = 0, copy_search = 0;
if (Z_TYPE_P(subject) != IS_STRING) {
@@ -524,7 +531,9 @@ void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zv
if (Z_TYPE_P(search) == IS_ARRAY) {
do {
zval *params[] = { search, replace, subject };
- zephir_call_func_aparams(&return_value, "str_replace", sizeof("str_replace")-1, NULL, 3, params TSRMLS_CC);
+ zval_ptr_dtor(return_value_ptr);
+ *return_value_ptr = NULL;
+ zephir_call_func_aparams(return_value_ptr, "str_replace", sizeof("str_replace")-1, NULL, 0, 3, params TSRMLS_CC);
return;
} while(0);
}
@@ -575,7 +584,6 @@ void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zv
if (copy_search) {
zval_dtor(search);
}
-
}
/**
@@ -592,11 +600,12 @@ void zephir_fast_trim(zval *return_value, zval *str, zval *charlist, int where T
str = ©
}
}
- if (charlist && Z_TYPE_P(charlist) == IS_STRING) {
- php_trim(Z_STRVAL_P(str), Z_STRLEN_P(str), Z_STRVAL_P(charlist), Z_STRLEN_P(charlist), return_value, where TSRMLS_CC);
- } else {
- php_trim(Z_STRVAL_P(str), Z_STRLEN_P(str), NULL, 0, return_value, where TSRMLS_CC);
- }
+
+ if (charlist && Z_TYPE_P(charlist) == IS_STRING) {
+ php_trim(Z_STRVAL_P(str), Z_STRLEN_P(str), Z_STRVAL_P(charlist), Z_STRLEN_P(charlist), return_value, where TSRMLS_CC);
+ } else {
+ php_trim(Z_STRVAL_P(str), Z_STRLEN_P(str), NULL, 0, return_value, where TSRMLS_CC);
+ }
if (use_copy) {
zval_dtor(©);
@@ -661,10 +670,10 @@ void zephir_fast_strtoupper(zval *return_value, zval *str) {
/**
* Checks if a zval string starts with a zval string
*/
-int zephir_start_with(const zval *str, const zval *compared, zval *case_sensitive){
+int zephir_start_with(const zval *str, const zval *compared, zval *case_sensitive) {
- int sensitive = 0;
int i;
+ int sensitive = 0;
char *op1_cursor, *op2_cursor;
if (Z_TYPE_P(str) != IS_STRING || Z_TYPE_P(compared) != IS_STRING) {
@@ -686,6 +695,7 @@ int zephir_start_with(const zval *str, const zval *compared, zval *case_sensitiv
op1_cursor = Z_STRVAL_P(str);
op2_cursor = Z_STRVAL_P(compared);
for (i = 0; i < Z_STRLEN_P(compared); i++) {
+
if (tolower(*op1_cursor) != tolower(*op2_cursor)) {
return 0;
}
@@ -700,7 +710,7 @@ int zephir_start_with(const zval *str, const zval *compared, zval *case_sensitiv
/**
* Checks if a zval string starts with a string
*/
-int zephir_start_with_str(const zval *str, char *compared, unsigned int compared_length){
+int zephir_start_with_str(const zval *str, char *compared, unsigned int compared_length) {
if (Z_TYPE_P(str) != IS_STRING || compared_length > Z_STRLEN_P(str)) {
return 0;
@@ -712,7 +722,7 @@ int zephir_start_with_str(const zval *str, char *compared, unsigned int compared
/**
* Checks if a string starts with other string
*/
-int zephir_start_with_str_str(char *str, unsigned int str_length, char *compared, unsigned int compared_length){
+int zephir_start_with_str_str(char *str, unsigned int str_length, char *compared, unsigned int compared_length) {
if (compared_length > str_length) {
return 0;
@@ -724,7 +734,7 @@ int zephir_start_with_str_str(char *str, unsigned int str_length, char *compared
/**
* Checks if a zval string ends with a zval string
*/
-int zephir_end_with(const zval *str, const zval *compared, zval *case_sensitive){
+int zephir_end_with(const zval *str, const zval *compared, zval *case_sensitive) {
int sensitive = 0;
int i;
@@ -750,6 +760,7 @@ int zephir_end_with(const zval *str, const zval *compared, zval *case_sensitive)
op2_cursor = Z_STRVAL_P(compared);
for (i = 0; i < Z_STRLEN_P(compared); ++i) {
+
if (tolower(*op1_cursor) != tolower(*op2_cursor)) {
return 0;
}
@@ -764,7 +775,7 @@ int zephir_end_with(const zval *str, const zval *compared, zval *case_sensitive)
/**
* Checks if a zval string ends with a *char string
*/
-int zephir_end_with_str(const zval *str, char *compared, unsigned int compared_length){
+int zephir_end_with_str(const zval *str, char *compared, unsigned int compared_length) {
if (Z_TYPE_P(str) != IS_STRING) {
return 0;
@@ -805,49 +816,61 @@ void zephir_random_string(zval *return_value, const zval *type, const zval *leng
for (i = 0; i < Z_LVAL_P(length); i++) {
switch (Z_LVAL_P(type)) {
+
case PH_RANDOM_ALNUM:
rand_type = (long) (php_mt_rand(TSRMLS_C) >> 1);
RAND_RANGE(rand_type, 0, 3, PHP_MT_RAND_MAX);
break;
+
case PH_RANDOM_ALPHA:
rand_type = (long) (php_mt_rand(TSRMLS_C) >> 1);
RAND_RANGE(rand_type, 1, 2, PHP_MT_RAND_MAX);
break;
+
case PH_RANDOM_HEXDEC:
rand_type = (long) (php_mt_rand(TSRMLS_C) >> 1);
RAND_RANGE(rand_type, 0, 1, PHP_MT_RAND_MAX);
break;
+
case PH_RANDOM_NUMERIC:
rand_type = 0;
break;
+
case PH_RANDOM_NOZERO:
rand_type = 5;
break;
+
default:
continue;
}
switch (rand_type) {
+
case 0:
ch = (long) (php_mt_rand(TSRMLS_C) >> 1);
RAND_RANGE(ch, '0', '9', PHP_MT_RAND_MAX);
break;
+
case 1:
ch = (long) (php_mt_rand(TSRMLS_C) >> 1);
RAND_RANGE(ch, 'a', 'f', PHP_MT_RAND_MAX);
break;
+
case 2:
ch = (long) (php_mt_rand(TSRMLS_C) >> 1);
RAND_RANGE(ch, 'a', 'z', PHP_MT_RAND_MAX);
break;
+
case 3:
ch = (long) (php_mt_rand(TSRMLS_C) >> 1);
RAND_RANGE(ch, 'A', 'Z', PHP_MT_RAND_MAX);
break;
+
case 5:
ch = (long) (php_mt_rand(TSRMLS_C) >> 1);
RAND_RANGE(ch, '1', '9', PHP_MT_RAND_MAX);
break;
+
default:
continue;
}
@@ -855,7 +878,6 @@ void zephir_random_string(zval *return_value, const zval *type, const zval *leng
smart_str_appendc(&random_str, (unsigned int) ch);
}
-
smart_str_0(&random_str);
if (random_str.len) {
@@ -864,7 +886,6 @@ void zephir_random_string(zval *return_value, const zval *type, const zval *leng
smart_str_free(&random_str);
RETURN_EMPTY_STRING();
}
-
}
/**
@@ -898,7 +919,6 @@ void zephir_remove_extra_slashes(zval *return_value, const zval *str) {
removed_str[i] = '\0';
RETURN_STRINGL(removed_str, i, 0);
-
}
/**
@@ -919,6 +939,7 @@ int zephir_spprintf(char **message, int max_len, char *format, ...)
* Makes a substr like the PHP function. This function SUPPORT negative from and length
*/
void zephir_substr(zval *return_value, zval *str, long f, long l, int flags) {
+
zval copy;
int use_copy = 0;
int str_len;
@@ -943,18 +964,31 @@ void zephir_substr(zval *return_value, zval *str, long f, long l, int flags) {
}
if ((l < 0 && -l > str_len)) {
+ if (use_copy) {
+ zval_dtor(str);
+ }
RETURN_FALSE;
- } else if (l > str_len) {
- l = str_len;
+ } else {
+ if (l > str_len) {
+ l = str_len;
+ }
}
if (f > str_len) {
+ if (use_copy) {
+ zval_dtor(str);
+ }
RETURN_FALSE;
- } else if (f < 0 && -f > str_len) {
- f = 0;
+ } else {
+ if (f < 0 && -f > str_len) {
+ f = 0;
+ }
}
if (l < 0 && (l + str_len - f) < 0) {
+ if (use_copy) {
+ zval_dtor(str);
+ }
RETURN_FALSE;
}
@@ -979,6 +1013,9 @@ void zephir_substr(zval *return_value, zval *str, long f, long l, int flags) {
}
if (f >= str_len) {
+ if (use_copy) {
+ zval_dtor(str);
+ }
RETURN_FALSE;
}
@@ -986,7 +1023,20 @@ void zephir_substr(zval *return_value, zval *str, long f, long l, int flags) {
l = str_len - f;
}
- RETURN_STRINGL(Z_STRVAL_P(str) + f, l, 1);
+ if (!l) {
+ if (use_copy) {
+ zval_dtor(str);
+ }
+ RETURN_EMPTY_STRING();
+ }
+
+ ZVAL_STRINGL(return_value, Z_STRVAL_P(str) + f, l, 1);
+
+ if (use_copy) {
+ zval_dtor(str);
+ }
+
+ return;
}
void zephir_append_printable_array(smart_str *implstr, zval *value TSRMLS_DC) {
@@ -1183,23 +1233,29 @@ void zephir_crc32(zval *return_value, zval *str TSRMLS_DC) {
str = ©
}
}
+
p = Z_STRVAL_P(str);
nr = Z_STRLEN_P(str);
crc = crcinit^0xFFFFFFFF;
for (; nr--; ++p) {
- crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32tab[(crc ^ (*p)) & 0xFF ];
+ crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32tab[(crc ^ (*p)) & 0xFF];
+ }
+
+ if (use_copy) {
+ zval_dtor(str);
}
- RETVAL_LONG(crc^0xFFFFFFFF);
+
+ RETVAL_LONG(crc ^ 0xFFFFFFFF);
}
-#if ZEPHIR_USE_PHP_PCRE
+#ifdef ZEPHIR_USE_PHP_PCRE
/**
* Execute preg-match without function lookup in the PHP userland
*/
-void zephir_preg_match(zval *return_value, zval **return_value_ptr, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC)
-{
+void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC) {
+
zval copy;
int use_copy = 0;
pcre_cache_entry *pce;
@@ -1226,11 +1282,11 @@ void zephir_preg_match(zval *return_value, zval **return_value_ptr, zval *regex,
RETURN_FALSE;
}
- if (flags != 0 || offset != 0) {
- php_pcre_match_impl(pce, Z_STRVAL_P(subject), Z_STRLEN_P(subject), return_value, matches, global, 1, flags, offset TSRMLS_CC);
- } else {
- php_pcre_match_impl(pce, Z_STRVAL_P(subject), Z_STRLEN_P(subject), return_value, matches, global, 0, 0, 0 TSRMLS_CC);
- }
+ if (flags != 0 || offset != 0) {
+ php_pcre_match_impl(pce, Z_STRVAL_P(subject), Z_STRLEN_P(subject), return_value, matches, global, 1, flags, offset TSRMLS_CC);
+ } else {
+ php_pcre_match_impl(pce, Z_STRVAL_P(subject), Z_STRLEN_P(subject), return_value, matches, global, 0, 0, 0 TSRMLS_CC);
+ }
if (use_copy) {
zval_dtor(©);
@@ -1239,37 +1295,45 @@ void zephir_preg_match(zval *return_value, zval **return_value_ptr, zval *regex,
#else
-void zephir_preg_match(zval *return_value, zval **return_value_ptr, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC)
+void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC)
{
+ zval tmp_flags;
+ zval tmp_offset;
+ zval *rv = NULL;
+ zval **rvp = &rv;
+
if (matches) {
Z_SET_ISREF_P(matches);
}
+ ZEPHIR_SINIT_VAR(tmp_flags);
+ ZEPHIR_SINIT_VAR(tmp_offset);
+ ZVAL_LONG(&tmp_flags, flags);
+ ZVAL_LONG(&tmp_offset, offset);
- if (global) {
- if (flags != 0 || offset != 0) {
- //zephir_call_func_params(return_value, return_value_ptr, SL("preg_match_all") TSRMLS_CC, (matches ? 3 : 2), regex, subject, matches, flags, offset);
- } else {
- //zephir_call_func_params(return_value, return_value_ptr, SL("preg_match_all") TSRMLS_CC, (matches ? 3 : 2), regex, subject, matches);
- }
- } else {
- if (flags != 0 || offset != 0) {
- //zephir_call_func_params(return_value, return_value_ptr, SL("preg_match") TSRMLS_CC, (matches ? 3 : 2), regex, subject, matches, flags, offset);
+ {
+ zval *tmp_params[5] = { regex, subject, matches, &tmp_flags, &tmp_offset };
+
+ if (global) {
+ zephir_call_func_aparams(rvp, SL("preg_match_all"), NULL, 0, 5, tmp_params TSRMLS_CC);
} else {
- //zephir_call_func_params(return_value, return_value_ptr, SL("preg_match") TSRMLS_CC, (matches ? 3 : 2), regex, subject, matches);
+ zephir_call_func_aparams(rvp, SL("preg_match"), NULL, 0, 5, tmp_params TSRMLS_CC);
}
}
-
if (matches) {
Z_UNSET_ISREF_P(matches);
}
+
+ if (return_value) {
+ COPY_PZVAL_TO_ZVAL(*return_value, rv);
+ }
}
#endif /* ZEPHIR_USE_PHP_PCRE */
#ifdef ZEPHIR_USE_PHP_JSON
-int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int opts TSRMLS_DC)
-{
+int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int opts TSRMLS_DC) {
+
smart_str buf = { NULL, 0, 0 };
php_json_encode(&buf, v, opts TSRMLS_CC);
@@ -1279,8 +1343,8 @@ int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int
return SUCCESS;
}
-int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zend_bool assoc TSRMLS_DC)
-{
+int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zend_bool assoc TSRMLS_DC) {
+
zval copy;
int use_copy = 0;
@@ -1302,8 +1366,8 @@ int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zen
#else
-int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int opts TSRMLS_DC)
-{
+int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int opts TSRMLS_DC) {
+
zval zopts;
zval *params[2];
@@ -1313,11 +1377,11 @@ int zephir_json_encode(zval *return_value, zval **return_value_ptr, zval *v, int
params[0] = v;
params[1] = &zopts;
- return zephir_return_call_function(return_value, NULL, ZEND_STRL("json_encode"), NULL, 2, params TSRMLS_CC);
+ return zephir_return_call_function(return_value, NULL, ZEND_STRL("json_encode"), NULL, 0, 2, params TSRMLS_CC);
}
-int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zend_bool assoc TSRMLS_DC)
-{
+int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zend_bool assoc TSRMLS_DC) {
+
zval zassoc;
zval *params[2];
@@ -1327,13 +1391,13 @@ int zephir_json_decode(zval *return_value, zval **return_value_ptr, zval *v, zen
params[0] = v;
params[1] = &zassoc;
- return zephir_return_call_function(return_value, NULL, ZEND_STRL("json_decode"), NULL, 2, params TSRMLS_CC);
+ return zephir_return_call_function(return_value, NULL, ZEND_STRL("json_decode"), NULL, 0, 2, params TSRMLS_CC);
}
#endif /* ZEPHIR_USE_PHP_JSON */
-void zephir_lcfirst(zval *return_value, zval *s)
-{
+void zephir_lcfirst(zval *return_value, zval *s) {
+
zval copy;
char *c;
int use_copy = 0;
@@ -1359,8 +1423,8 @@ void zephir_lcfirst(zval *return_value, zval *s)
}
}
-void zephir_ucfirst(zval *return_value, zval *s)
-{
+void zephir_ucfirst(zval *return_value, zval *s) {
+
zval copy;
char *c;
int use_copy = 0;
@@ -1386,8 +1450,8 @@ void zephir_ucfirst(zval *return_value, zval *s)
}
}
-int zephir_http_build_query(zval *return_value, zval *params, char *sep TSRMLS_DC)
-{
+int zephir_http_build_query(zval *return_value, zval *params, char *sep TSRMLS_DC) {
+
if (Z_TYPE_P(params) == IS_ARRAY || Z_TYPE_P(params) == IS_OBJECT) {
smart_str formstr = { NULL, 0, 0 };
int res;
@@ -1420,8 +1484,7 @@ int zephir_http_build_query(zval *return_value, zval *params, char *sep TSRMLS_D
return FAILURE;
}
-void zephir_htmlspecialchars(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC)
-{
+void zephir_htmlspecialchars(zval *return_value, zval *string, zval *quoting, zval *charset TSRMLS_DC) {
zval copy;
char *escaped, *cs;
int qs, use_copy = 0;
@@ -1487,8 +1550,7 @@ void zephir_strval(zval *return_value, zval *v)
if (use_copy) {
zval *tmp = ©
ZVAL_ZVAL(return_value, tmp, 0, 0);
- }
- else {
+ } else {
ZVAL_ZVAL(return_value, v, 1, 0);
}
}
diff --git a/ext/kernel/string.h b/ext/kernel/string.h
index 2d05c090..aecea8f0 100644
--- a/ext/kernel/string.h
+++ b/ext/kernel/string.h
@@ -21,7 +21,9 @@
#ifndef ZEPHIR_KERNEL_STRING_H
#define ZEPHIR_KERNEL_STRING_H
+#include
#include
+#include "kernel/main.h"
#define ZEPHIR_TRIM_LEFT 1
#define ZEPHIR_TRIM_RIGHT 2
@@ -44,7 +46,7 @@ void zephir_fast_explode_str(zval *result, const char *delimiter, int delimiter_
void zephir_fast_strpos(zval *return_value, const zval *haystack, const zval *needle, unsigned int offset);
void zephir_fast_strpos_str(zval *return_value, const zval *haystack, char *needle, unsigned int needle_length);
void zephir_fast_stripos_str(zval *return_value, zval *haystack, char *needle, unsigned int needle_length);
-void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject TSRMLS_DC);
+void zephir_fast_str_replace(zval **return_value, zval *search, zval *replace, zval *subject TSRMLS_DC);
void zephir_fast_trim(zval *return_value, zval *str, zval *charlist, int where TSRMLS_DC);
void zephir_fast_strip_tags(zval *return_value, zval *str);
void zephir_fast_strtoupper(zval *return_value, zval *str);
@@ -79,7 +81,7 @@ void zephir_substr(zval *return_value, zval *str, long from, long length, int fl
zval *zephir_eol(int eol TSRMLS_DC);
/** Preg-Match */
-void zephir_preg_match(zval *return_value, zval **return_value_ptr, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC);
+void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *matches, int global, long flags, long offset TSRMLS_DC);
/** Base64 */
void zephir_base64_encode(zval *return_value, zval *data);
diff --git a/ext/kernel/string.h.gch b/ext/kernel/string.h.gch
new file mode 100644
index 00000000..76354d63
Binary files /dev/null and b/ext/kernel/string.h.gch differ
diff --git a/ext/kernel/time.c b/ext/kernel/time.c
index bc596ed7..60af95cf 100644
--- a/ext/kernel/time.c
+++ b/ext/kernel/time.c
@@ -1,17 +1,17 @@
/*
- +------------------------------------------------------------------------+
- | Zephir Language |
- +------------------------------------------------------------------------+
- | Copyright (c) 2011-2015 Zephir Team (http://www.zephir-lang.com) |
- +------------------------------------------------------------------------+
- | This source file is subject to the New BSD License that is bundled |
- | with this package in the file docs/LICENSE.txt. |
- | |
- | If you did not receive a copy of the license and are unable to |
- | obtain it through the world-wide-web, please send an email |
- | to license@zephir-lang.com so we can send you a copy immediately. |
- +------------------------------------------------------------------------+
+ +------------------------------------------------------------------------+
+ | Zephir Language |
+ +------------------------------------------------------------------------+
+ | Copyright (c) 2011-2015 Zephir Team (http://www.zephir-lang.com) |
+ +------------------------------------------------------------------------+
+ | This source file is subject to the New BSD License that is bundled |
+ | with this package in the file docs/LICENSE.txt. |
+ | |
+ | If you did not receive a copy of the license and are unable to |
+ | obtain it through the world-wide-web, please send an email |
+ | to license@zephir-lang.com so we can send you a copy immediately. |
+ +------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
diff --git a/ext/kernel/time.h b/ext/kernel/time.h
index 6197e03e..35ba1428 100644
--- a/ext/kernel/time.h
+++ b/ext/kernel/time.h
@@ -17,6 +17,9 @@
#ifndef ZEPHIR_KERNEL_TIME_H
#define ZEPHIR_KERNEL_TIME_H
+#include
+#include
+
#define MICRO_IN_SEC 1000000.00
void zephir_time(zval *return_value);
diff --git a/ext/kernel/time.h.gch b/ext/kernel/time.h.gch
new file mode 100644
index 00000000..5c9484d9
Binary files /dev/null and b/ext/kernel/time.h.gch differ
diff --git a/ext/kernel/variables.c b/ext/kernel/variables.c
index e3de7520..1f52356a 100644
--- a/ext/kernel/variables.c
+++ b/ext/kernel/variables.c
@@ -102,11 +102,9 @@ void zephir_var_export_ex(zval *return_value, zval **var TSRMLS_DC) {
ZVAL_STRINGL(return_value, buf.c, buf.len, 0);
}
-
/**
* var_dump outputs php variables without using the PHP userland
*/
void zephir_var_dump(zval **var TSRMLS_DC) {
php_var_dump(var, 1 TSRMLS_CC);
}
-
diff --git a/ext/kernel/variables.h b/ext/kernel/variables.h
index b8938ef4..8d74469f 100644
--- a/ext/kernel/variables.h
+++ b/ext/kernel/variables.h
@@ -18,6 +18,12 @@
+------------------------------------------------------------------------+
*/
+#ifndef ZEPHIR_KERNEL_VARIABLES_H
+#define ZEPHIR_KERNEL_VARIABLES_H
+
+#include
+#include
+
void zephir_serialize(zval *return_value, zval **var TSRMLS_DC);
void zephir_unserialize(zval *return_value, zval *var TSRMLS_DC);
@@ -25,3 +31,5 @@ void zephir_var_export(zval **var TSRMLS_DC);
void zephir_var_export_ex(zval *return_value, zval **var TSRMLS_DC);
void zephir_var_dump(zval **var TSRMLS_DC);
+
+#endif
\ No newline at end of file
diff --git a/ext/kernel/variables.h.gch b/ext/kernel/variables.h.gch
new file mode 100644
index 00000000..e21c2da8
Binary files /dev/null and b/ext/kernel/variables.h.gch differ
diff --git a/ext/php_ice.h b/ext/php_ice.h
index efae2c81..98093f00 100644
--- a/ext/php_ice.h
+++ b/ext/php_ice.h
@@ -11,10 +11,10 @@
#include "kernel/globals.h"
#define PHP_ICE_NAME "ice"
-#define PHP_ICE_VERSION "1.0.6"
+#define PHP_ICE_VERSION "1.0.35"
#define PHP_ICE_EXTNAME "ice"
#define PHP_ICE_AUTHOR "Ice Team"
-#define PHP_ICE_ZEPVERSION "0.6.0a"
+#define PHP_ICE_ZEPVERSION "0.8.0a"
#define PHP_ICE_DESCRIPTION "Simple and fast PHP framework delivered as C-extension. Copyright (c) 2014-2015 Ice Team."
@@ -34,6 +34,8 @@ ZEND_BEGIN_MODULE_GLOBALS(ice)
/** Function cache */
HashTable *fcache;
+ zephir_fcall_cache_entry *scache[ZEPHIR_MAX_CACHE_SLOTS];
+
/* Cache enabled */
unsigned int cache_enabled;
diff --git a/ice/arr.zep b/ice/arr.zep
index 66c6d0bb..7d88e085 100644
--- a/ice/arr.zep
+++ b/ice/arr.zep
@@ -15,7 +15,7 @@ use ArrayIterator;
class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
{
- protected _data = [] { get };
+ protected data = [] { get };
/**
* Arr constructor.
@@ -24,7 +24,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function __construct(array data = [])
{
- let this->_data = data;
+ let this->data = data;
}
/**
@@ -35,7 +35,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function has(string key) -> boolean
{
- return isset this->_data[key];
+ return isset this->data[key];
}
/**
@@ -44,13 +44,18 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*
* @param string key The data key
* @param mixed defaultValue The value to return if data key does not exist
+ * @param boolean required Throw exception if key is required but doesn't exist
* @return mixed
*/
- public function get(string key, var defaultValue = null)
+ public function get(string key, var defaultValue = null, boolean required = false)
{
var value;
- if fetch value, this->_data[key] {
+ if required && !this->has(key) {
+ throw new Exception(sprintf("The '%s' key is required", key));
+ }
+
+ if fetch value, this->data[key] {
return value;
}
@@ -66,7 +71,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function set(string key, var value) -> void
{
- let this->_data[key] = value;
+ let this->data[key] = value;
}
/**
@@ -102,7 +107,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function setData(array! data = []) -> void
{
- let this->_data = data;
+ let this->data = data;
}
/**
@@ -112,7 +117,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function keys() -> array
{
- return array_keys(this->_data);
+ return array_keys(this->data);
}
/**
@@ -123,7 +128,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function remove(string key) -> void
{
- unset this->_data[key];
+ unset this->data[key];
}
/**
@@ -133,7 +138,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function clear() -> void
{
- let this->_data = [];
+ let this->data = [];
}
/**
@@ -143,7 +148,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function count() -> int
{
- return count(this->_data);
+ return count(this->data);
}
/**
@@ -153,7 +158,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function getIterator() ->
{
- return new ArrayIterator(this->_data);
+ return new ArrayIterator(this->data);
}
/**
@@ -178,7 +183,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
{
var data, keys, key;
- let data = this->_data;
+ let data = this->data;
if typeof path == "array" {
// The path has already been separated into keys
@@ -260,7 +265,7 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
var key, value, tmp;
let tmp = [];
- for key, value in this->_data {
+ for key, value in this->data {
if typeof value == "object" {
if method_exists(value, "toArray") {
let tmp[key] = value->toArray();
@@ -361,6 +366,6 @@ class Arr implements \ArrayAccess, \Countable, \IteratorAggregate
*/
public function __unset(key) -> void
{
- unset this->_data[key];
+ unset this->data[key];
}
}
diff --git a/ice/assets.zep b/ice/assets.zep
new file mode 100644
index 00000000..3cf28413
--- /dev/null
+++ b/ice/assets.zep
@@ -0,0 +1,256 @@
+
+namespace Ice;
+
+/**
+ * Assets helper is designed to management css/js resources.
+ *
+ * @package Ice/Assets
+ * @category Helper
+ * @author Ice Team
+ * @copyright (c) 2014-2015 Ice Team
+ * @license http://iceframework.org/license
+ */
+class Assets
+{
+
+ protected di;
+ protected css = [] { get };
+ protected js = [] { get };
+ protected options = [] { set };
+
+ const NEVER = 0;
+ const NOT_EXIST = 1;
+ const IF_CHANGE = 2;
+ const ALWAYS = 3;
+
+ /**
+ * Assets constructor. Fetch Di and set it as a property.
+ */
+ public function __construct()
+ {
+ let this->di = Di::$fetch();
+ }
+
+ /**
+ * Retrieve a single option.
+ *
+ * @param string key The data key
+ * @param mixed defaultValue The value to return if data key does not exist
+ * @return mixed
+ */
+ public function getOption(var key, var defaultValue = null)
+ {
+ var value;
+
+ if fetch value, this->options[key] {
+ return value;
+ }
+
+ return defaultValue;
+ }
+
+ /**
+ * Add resource to assets, autodetect type.
+ *
+ * @param mixed parameters Parameters of link/script/style
+ * @param string version Version appending to the uri
+ * @param mixed minify Local minify option
+ * @return object this
+ */
+ public function add(var parameters, string version = null, var minify = null)
+ {
+ var content, type;
+
+ if typeof parameters == "string" {
+ let content = parameters,
+ parameters = [],
+ parameters[] = content;
+ } elseif !fetch content, parameters["content"] {
+ fetch content, parameters[0];
+ }
+
+ fetch type, parameters["type"];
+
+ if ends_with(content, ".css") || type == "text/css" {
+ this->addCss(parameters, version, minify);
+ } elseif ends_with(content, ".js") || type == "text/javascript" {
+ this->addJs(parameters, version, minify);
+ }
+
+ return this;
+ }
+
+ /**
+ * Add CSS resource to assets.
+ *
+ * @param array parameters Parameters of link/style
+ * @param string version Version appending to the uri
+ * @param mixed minify Local minify option
+ * @return object this
+ */
+ public function addCss(array! parameters, string version = null, var minify = null)
+ {
+
+ var content, local, tag;
+
+ let tag = this->di->get("tag", null, true);
+
+ if !fetch content, parameters["content"] {
+ fetch content, parameters[0];
+ }
+
+ if !fetch local, parameters["local"] {
+ let local = true;
+ }
+
+ // If local minify is not set
+ if minify === null {
+ // Get global minify option, default is NEVER
+ let minify = this->getOption("minify", self::NEVER);
+ }
+
+ // Do not minify external or minified resources
+ if !local || ends_with(content, ".min.css") {
+ let minify = self::NEVER;
+ }
+
+ // Check if resource is inline or in file
+ if isset parameters["content"] {
+ let this->css[] = tag->style(["content": minify ? this->minify(content, "css") : content]);
+ } else {
+ let parameters["href"] = this->prepare(content, "css", minify) . (version ? "?v=" . version : ""),
+ this->css[] = tag->link(parameters);
+ }
+
+ return this;
+ }
+
+ /**
+ * Add JS resource to assets.
+ *
+ * @param array parameters Parameters of script
+ * @param string version Version appending to the uri
+ * @param mixed minify Local minify option
+ * @return object this
+ */
+ public function addJs(array! parameters, string version = null, var minify = null)
+ {
+ var content, local, tag;
+
+ let tag = this->di->get("tag", null, true);
+
+ if !fetch content, parameters["content"] {
+ fetch content, parameters[0];
+ }
+
+ if !fetch local, parameters["local"] {
+ let local = true;
+ }
+
+ // If local minify is not set
+ if minify === null {
+ // Get global minify option, default is NEVER
+ let minify = this->getOption("minify", self::NEVER);
+ }
+
+ // Do not minify external or minified resources
+ if !local || ends_with(content, ".min.js") {
+ let minify = self::NEVER;
+ }
+
+ // Check if resource is inline or in file
+ if isset parameters["content"] {
+ let this->js[] = tag->script(["content": minify ? this->minify(content, "js") : content]);
+ } else {
+ let parameters["src"] = this->prepare(content, "js", minify) . (version ? "?v=" . version : ""),
+ this->js[] = tag->script(parameters);
+ }
+
+ return this;
+ }
+
+ /**
+ * Minify content
+ *
+ * @param string content Input text to minify
+ * @param string type Type of content
+ * @return string
+ */
+ protected function minify(string! content, type)
+ {
+ return this->di->get("filter", null, true)->sanitize(content, type . "min");
+ }
+
+ /**
+ * Prepare resource
+ *
+ * @param string uri The uri/url source path
+ * @param string type Type of content
+ * @param int minify Option of minify
+ * @return string New path to the source
+ */
+ protected function prepare(string! uri, string type, var minify)
+ {
+ var source, target, dir, file, uriMin, destination, exist, old, minified;
+
+ let source = this->getOption("source"),
+ target = this->getOption("target"),
+ dir = dirname(uri) . DIRECTORY_SEPARATOR,
+ file = basename(uri, "." . type),
+ uriMin = target . dir . file . ".min." . type,
+ destination = source . uriMin,
+ exist = false;
+
+ switch minify {
+ case self::NOT_EXIST:
+ let minify = !file_exists(destination);
+ break;
+ case self::IF_CHANGE:
+ if !file_exists(destination) {
+ let minify = true;
+ } else {
+ let minify = md5_file(destination);
+ }
+ break;
+ case self::ALWAYS:
+ let minify = true;
+ break;
+ default: // self::NEVER:
+ let minify = false;
+
+ if this->getOption("forceMinified") {
+ let exist = file_exists(destination);
+ }
+ break;
+ }
+
+ if !minify {
+ return exist ? uriMin : uri;
+ } else {
+ let minified = this->minify(file_get_contents(source . uri), type);
+
+ // Check if file was changed
+ if typeof minify == "string" {
+ if minify != md5(minified) {
+ let minify = true;
+ }
+ }
+
+ if minify === true {
+
+ if !is_dir(dirname(destination)) {
+ let old = umask(0);
+
+ mkdir(dirname(destination), 0777, true);
+ umask(old);
+ }
+
+ if file_put_contents(destination, minified) === false {
+ throw new Exception("Directory can't be written");
+ }
+ }
+
+ return uriMin;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ice/auth/driver.zep b/ice/auth/driver.zep
index 586327d0..e7438fb1 100644
--- a/ice/auth/driver.zep
+++ b/ice/auth/driver.zep
@@ -15,11 +15,11 @@ use Ice\Di;
abstract class Driver
{
- protected _session;
- protected _cookies;
- protected _request;
- protected _user;
- protected _options = [
+ protected session;
+ protected cookies;
+ protected request;
+ protected user;
+ protected options = [
"hash_method": "sha256",
"hash_key": "",
"session_key": "auth_user",
@@ -38,10 +38,10 @@ abstract class Driver
var di;
let di = Di::$fetch(),
- this->_options = array_merge(this->_options, options),
- this->_session = di->{"getSession"}(),
- this->_cookies = di->{"getCookies"}(),
- this->_request = di->{"getRequest"}();
+ this->options = array_merge(this->options, options),
+ this->session = di->get("session", null, true),
+ this->cookies = di->get("cookies", null, true),
+ this->request = di->get("request", null, true);
}
/**
@@ -68,17 +68,17 @@ abstract class Driver
var sessionRoles;
// Regenerate session_id
- this->_session->regenerate();
+ this->session->regenerate();
// Store user in session
- this->_session->set(this->getOption("session_key", "auth_user"), user);
+ this->session->set(this->getOption("session_key", "auth_user"), user);
// Check in session can improve performance
let sessionRoles = this->getOption("session_roles");
// Store user's roles in session
if sessionRoles {
- this->_session->set(sessionRoles, roles);
+ this->session->set(sessionRoles, roles);
}
}
@@ -93,7 +93,7 @@ abstract class Driver
{
var value;
- if fetch value, this->_options[key] {
+ if fetch value, this->options[key] {
return value;
}
return defaultValue;
@@ -107,7 +107,7 @@ abstract class Driver
*/
public function getUser(var defaultValue = null)
{
- return this->_session->get(this->getOption("session_key"), defaultValue);
+ return this->session->get(this->getOption("session_key"), defaultValue);
}
/**
@@ -146,7 +146,7 @@ abstract class Driver
let sessionRoles = this->getOption("session_roles");
if sessionRoles {
- let roles = this->_session->get(sessionRoles);
+ let roles = this->session->get(sessionRoles);
return in_array(role, roles);
} else {
return this->{"hasRole"}(user, role);
@@ -167,19 +167,19 @@ abstract class Driver
if destroy === true {
// Destroy the session completely
- this->_session->destroy();
+ this->session->destroy();
} else {
// Remove the user from the session
- this->_session->remove(this->getOption("session_key"));
+ this->session->remove(this->getOption("session_key"));
let sessionRoles = this->getOption("session_roles");
if sessionRoles {
- this->_session->remove(sessionRoles);
+ this->session->remove(sessionRoles);
}
// Regenerate session_id
- this->_session->regenerate();
+ this->session->regenerate();
}
// Double check
diff --git a/ice/auth/driver/file.zep b/ice/auth/driver/file.zep
index 2f1da216..3495ff12 100644
--- a/ice/auth/driver/file.zep
+++ b/ice/auth/driver/file.zep
@@ -1,6 +1,7 @@
namespace Ice\Auth\Driver;
+use Ice\Arr;
use Ice\Exception;
use Ice\Auth\Driver;
use Ice\Auth\Driver\DriverInterface;
@@ -17,7 +18,7 @@ use Ice\Auth\Driver\DriverInterface;
class File extends Driver implements DriverInterface
{
- protected _users { set };
+ protected users { set };
/**
* Gets the currently logged in user from the session. Returns NULL if no user is currently logged in.
@@ -29,19 +30,23 @@ class File extends Driver implements DriverInterface
{
var username, user;
- if !this->_user {
+ if !this->user {
let username = parent::getUser(defaultValue);
if username === defaultValue {
// User isn't currently logged in
- let this->_user = defaultValue;
+ let this->user = defaultValue;
} else {
- fetch user, this->_users[username];
- let this->_user = user;
+ fetch user, this->users[username];
+ let user["username"] = username,
+ this->user = user;
}
}
- return this->_user;
+ if this->user {
+ return new Arr(this->user);
+ }
+ return this->user;
}
/**
@@ -72,11 +77,11 @@ class File extends Driver implements DriverInterface
{
var user;
- if empty password {
- return false;
- }
+ if username && fetch user, this->users[username] {
+ if empty password {
+ return false;
+ }
- if username && fetch user, this->_users[username] {
if user["password"] === this->hash(password) {
// Complete the login
this->completeLogin(username, user["roles"]);
diff --git a/ice/auth/driver/model.zep b/ice/auth/driver/model.zep
index 936a2b24..91075181 100644
--- a/ice/auth/driver/model.zep
+++ b/ice/auth/driver/model.zep
@@ -31,7 +31,7 @@ class Model extends Driver implements DriverInterface
{
var token, user, userRoles, roles, role;
- let token = this->_cookies->get("auth_autologin");
+ let token = this->cookies->get("auth_autologin");
if token {
// Find the token
@@ -41,7 +41,7 @@ class Model extends Driver implements DriverInterface
// Get user for the token
let user = token->{"getUser"}();
- if user && token->{"useragent"} === sha1(this->_request->getUserAgent()) {
+ if user && token->{"useragent"} === sha1(this->request->getUserAgent()) {
// Get user's roles
let userRoles = user->{"getRoles"}(),
roles = [];
@@ -56,7 +56,7 @@ class Model extends Driver implements DriverInterface
token->update();
// Set the new token
- this->_cookies->set("auth_autologin", token->{"token"}, token->{"expires"});
+ this->cookies->set("auth_autologin", token->{"token"}, token->{"expires"});
// Complete the login with the found data
this->completeLogin(user, roles);
@@ -99,22 +99,28 @@ class Model extends Driver implements DriverInterface
{
var data;
- if !this->_user {
+ if !this->user {
let data = parent::getUser(defaultValue);
if data === defaultValue {
// User isn't currently logged in
- let this->_user = defaultValue;
- } else {
- let this->_user = unserialize(data);
+ let this->user = defaultValue;
+ } elseif typeof data == "string" {
+ var user;
+
+ let user = unserialize(data);
+
+ if user instanceof Users {
+ let this->user = user;
+ }
}
}
- if !this->_user {
- let this->_user = this->autoLogin();
+ if !this->user {
+ let this->user = this->autoLogin();
}
- return this->_user;
+ return this->user;
}
/**
@@ -147,10 +153,6 @@ class Model extends Driver implements DriverInterface
let user = null;
- if empty password {
- return false;
- }
-
if username {
if typeof username == "object" {
let user = username;
@@ -158,9 +160,16 @@ class Model extends Driver implements DriverInterface
let users = this->getOption("users", "Ice\\Auth\\Driver\\Model\\Users"),
user = {users}::findOne(["username": username]);
}
+ } else {
+ // Username not specified
+ return null;
}
if typeof user == "object" && (user instanceof Users) {
+ if empty password {
+ return false;
+ }
+
// Check if password match
if user->get("password") == this->hash(password) {
let userRoles = user->{"getRoles"}(),
@@ -177,14 +186,14 @@ class Model extends Driver implements DriverInterface
// Create a new autologin token
let lifetime = this->getOption("lifetime"),
token = new Tokens(),
- token->{"user_id"} = user->get("id"),
- token->{"useragent"} = sha1(this->_request->getUserAgent()),
+ token->{"user_id"} = user->getId(),
+ token->{"useragent"} = sha1(this->request->getUserAgent()),
token->{"created"} = time(),
token->{"expires"} = time() + lifetime;
if token->create() === true {
// Set the autologin cookie
- this->_cookies->set("auth_autologin", token->get("token"), token->get("expires"));
+ this->cookies->set("auth_autologin", token->get("token"), token->get("expires"));
}
}
@@ -196,7 +205,7 @@ class Model extends Driver implements DriverInterface
return false;
} else {
- // Username not specified or user not found
+ // User not found
return null;
}
}
@@ -235,14 +244,14 @@ class Model extends Driver implements DriverInterface
// Create a new autologin token
let lifetime = this->getOption("lifetime"),
token = new Tokens(),
- token->{"user_id"} = user->get("id"),
- token->{"useragent"} = sha1(this->_request->getUserAgent()),
+ token->{"user_id"} = user->getId(),
+ token->{"useragent"} = sha1(this->request->getUserAgent()),
token->{"created"} = time(),
token->{"expires"} = time() + lifetime;
if token->create() === true {
// Set the autologin cookie
- this->_cookies->set("auth_autologin", token->get("token"), token->get("expires"));
+ this->cookies->set("auth_autologin", token->get("token"), token->get("expires"));
}
}
@@ -270,11 +279,11 @@ class Model extends Driver implements DriverInterface
{
var token, tokens, user;
- let token = this->_cookies->get("auth_autologin");
+ let token = this->cookies->get("auth_autologin");
if token {
// Delete the autologin cookie to prevent re-login
- this->_cookies->remove("auth_autologin");
+ this->cookies->remove("auth_autologin");
// Clear the autologin token from the database
let token = Tokens::findOne(["token": token]);
@@ -290,7 +299,7 @@ class Model extends Driver implements DriverInterface
user = this->getUser();
if user {
- tokens->remove(["user_id": user->get("id")]);
+ tokens->remove(["user_id": user->getId()]);
}
}
@@ -326,7 +335,7 @@ class Model extends Driver implements DriverInterface
parent::completeLogin(serialize(user), roles);
- let this->_user = user;
+ let this->user = user;
}
}
diff --git a/ice/auth/driver/model/roles.zep b/ice/auth/driver/model/roles.zep
index 24837a5b..2a6c86e1 100644
--- a/ice/auth/driver/model/roles.zep
+++ b/ice/auth/driver/model/roles.zep
@@ -22,7 +22,7 @@ class Roles extends Model
*/
public function initialize()
{
- this->hasMany("id", "Ice\\Auth\\Driver\\Model\\Roles\\Users", "role_id", [
+ this->hasMany(this->getIdKey(), "Ice\\Auth\\Driver\\Model\\Roles\\Users", "role_id", [
"alias": "RolesUsers"
]);
}
diff --git a/ice/auth/driver/model/roles/users.zep b/ice/auth/driver/model/roles/users.zep
index cb9a8ea6..1fcb53e6 100644
--- a/ice/auth/driver/model/roles/users.zep
+++ b/ice/auth/driver/model/roles/users.zep
@@ -16,7 +16,7 @@ use Ice\Mvc\Model;
class Users extends Model
{
- protected _from = "roles_users";
+ protected from = "roles_users";
/**
* Initialize roles-users relations.
@@ -27,13 +27,13 @@ class Users extends Model
{
var auth;
- let auth = this->getDi()->{"getAuth"}();
+ let auth = this->getDi()->get("auth", null, true);
- this->belongsTo("user_id", auth->getOption("users", "Ice\\Auth\\Driver\\Model\\Users"), "id", [
+ this->belongsTo("user_id", auth->getOption("users", "Ice\\Auth\\Driver\\Model\\Users"), this->getIdKey(), [
"alias": "User"
]);
- this->belongsTo("role_id", "Ice\\Auth\\Driver\\Model\\Roles", "id", [
+ this->belongsTo("role_id", "Ice\\Auth\\Driver\\Model\\Roles", this->getIdKey(), [
"alias": "Role"
]);
}
diff --git a/ice/auth/driver/model/users.zep b/ice/auth/driver/model/users.zep
index 7a75dcd0..e6e73686 100644
--- a/ice/auth/driver/model/users.zep
+++ b/ice/auth/driver/model/users.zep
@@ -23,15 +23,15 @@ class Users extends Model
*/
public function initialize()
{
- this->hasMany("id", "Ice\\Auth\\Driver\\Model\\Users\\Tokens", "user_id", [
+ this->hasMany(this->getIdKey(), "Ice\\Auth\\Driver\\Model\\Users\\Tokens", "user_id", [
"alias": "Tokens"
]);
- this->hasMany("id", "Ice\\Auth\\Driver\\Model\\Roles\\Users", "user_id", [
+ this->hasMany(this->getIdKey(), "Ice\\Auth\\Driver\\Model\\Roles\\Users", "user_id", [
"alias": "Roles"
]);
- this->hasOne("id", "Ice\\Auth\\Driver\\Model\\Users\\Social", "user_id", [
+ this->hasOne(this->getIdKey(), "Ice\\Auth\\Driver\\Model\\Users\\Social", "user_id", [
"alias": "Social"
]);
}
@@ -69,7 +69,7 @@ class Users extends Model
return null;
}
- let roles = this->{"getRoles"}(["role_id": role->get("id")]);
+ let roles = this->{"getRoles"}(["role_id": role->getId()]);
// Return the role if user has the role otherwise false
return roles->count() ? roles->getIterator()->current() : false;
diff --git a/ice/auth/driver/model/users/social.zep b/ice/auth/driver/model/users/social.zep
index 857a6a2e..7b7d6060 100644
--- a/ice/auth/driver/model/users/social.zep
+++ b/ice/auth/driver/model/users/social.zep
@@ -15,7 +15,7 @@ use Ice\Mvc\Model;
class Social extends Model
{
- protected _from = "user_social";
+ protected from = "user_social";
/**
* Initialize relations.
@@ -26,9 +26,9 @@ class Social extends Model
{
var auth;
- let auth = this->getDi()->{"getAuth"}();
+ let auth = this->getDi()->get("auth", null, true);
- this->hasOne("user_id", auth->getOption("users", "Ice\\Auth\\Driver\\Model\\Users"), "id", [
+ this->hasOne("user_id", auth->getOption("users", "Ice\\Auth\\Driver\\Model\\Users"), this->getIdKey(), [
"alias": "User"
]);
}
diff --git a/ice/auth/driver/model/users/tokens.zep b/ice/auth/driver/model/users/tokens.zep
index 8884436f..f9432059 100644
--- a/ice/auth/driver/model/users/tokens.zep
+++ b/ice/auth/driver/model/users/tokens.zep
@@ -17,7 +17,7 @@ use Ice\Validation;
class Tokens extends Model
{
- protected _from = "user_tokens";
+ protected from = "user_tokens";
/**
* Initialize token's relations, remove expired tokens.
@@ -28,9 +28,9 @@ class Tokens extends Model
{
var auth;
- let auth = this->getDi()->{"getAuth"}();
+ let auth = this->getDi()->get("auth", null, true);
- this->belongsTo("user_id", auth->getOption("users", "Ice\\Auth\\Driver\\Model\\Users"), "id", [
+ this->belongsTo("user_id", auth->getOption("users", "Ice\\Auth\\Driver\\Model\\Users"), this->getIdKey(), [
"alias": "User",
"foreignKey": true
]);
@@ -55,7 +55,7 @@ class Tokens extends Model
*/
public function create(var fields = [], extra = null)
{
- let this->{"token"} = this->_generate();
+ let this->{"token"} = this->generate();
return parent::create(fields);
}
@@ -87,7 +87,7 @@ class Tokens extends Model
*/
public function update(var fields = [], extra = null)
{
- let this->{"token"} = this->_generate();
+ let this->{"token"} = this->generate();
return parent::update(fields);
}
@@ -98,7 +98,7 @@ class Tokens extends Model
* @return string
* @uses Text::random()
*/
- protected function _generate() -> string
+ protected function generate() -> string
{
var token;
diff --git a/ice/auth/social.zep b/ice/auth/social.zep
index e44d983c..ad0d96ef 100644
--- a/ice/auth/social.zep
+++ b/ice/auth/social.zep
@@ -15,7 +15,7 @@ use Ice\Auth\Social\SocialInterface;
class Social
{
- protected _adapter { get };
+ protected adapter { get };
/**
* Constructor.
@@ -24,7 +24,7 @@ class Social
*/
public function __construct( adapter)
{
- let this->_adapter = adapter;
+ let this->adapter = adapter;
}
/**
@@ -34,7 +34,7 @@ class Social
*/
public function authenticate()
{
- return this->_adapter->authenticate();
+ return this->adapter->authenticate();
}
/**
@@ -46,7 +46,7 @@ class Social
*/
public function get(string key, var defaultValue = null)
{
- return this->_adapter->get(key, defaultValue);
+ return this->adapter->get(key, defaultValue);
}
/**
@@ -57,6 +57,6 @@ class Social
* @return mixed
*/
public function __call(string method, arguments = null) {
- return call_user_func_array([this->_adapter, method], arguments);
+ return call_user_func_array([this->adapter, method], arguments);
}
}
diff --git a/ice/auth/social/adapter.zep b/ice/auth/social/adapter.zep
index b540d2ac..265f10e2 100644
--- a/ice/auth/social/adapter.zep
+++ b/ice/auth/social/adapter.zep
@@ -16,14 +16,14 @@ use Ice\Exception;
abstract class Adapter implements SocialInterface
{
- protected _accessToken { set, get };
- protected _clientId;
- protected _clientSecret;
- protected _redirectUri;
- protected _provider { get };
- protected _socialFieldsMap = [];
- protected _userInfo;
- protected _responseType = "code" { get };
+ protected accessToken { set, get };
+ protected clientId;
+ protected clientSecret;
+ protected redirectUri;
+ protected provider { get };
+ protected socialFieldsMap = [];
+ protected userInfo;
+ protected responseType = "code" { get };
const GET = 0;
const POST = 1;
@@ -39,24 +39,24 @@ abstract class Adapter implements SocialInterface
var clientId, clientSecret, redirectUri, tmp;
if !count(config) {
- let tmp = Di::$fetch()->{"getConfig"}()->get("auth");
+ let tmp = Di::$fetch()->get("config", null, true)->get("auth");
- if tmp && tmp->has(this->_provider) {
- let config = tmp->get(this->_provider)->toArray();
+ if tmp && tmp->has(this->provider) {
+ let config = tmp->get(this->provider)->toArray();
}
}
if fetch clientId, config["client_id"] {
- let this->_clientId = clientId;
+ let this->clientId = clientId;
}
if fetch clientSecret, config["client_secret"] {
- let this->_clientSecret = clientSecret;
+ let this->clientSecret = clientSecret;
}
if fetch redirectUri, config["redirect_uri"] {
- let this->_redirectUri = redirectUri;
+ let this->redirectUri = redirectUri;
}
- if !this->_clientId || !this->_clientSecret || !this->_redirectUri {
+ if !this->clientId || !this->clientSecret || !this->redirectUri {
throw new Exception(["Option `%s`, `%s`, `%s` are required", "client_id", "client_secret", "redirect_uri"]);
}
}
@@ -93,11 +93,11 @@ abstract class Adapter implements SocialInterface
public function has(string key) -> boolean
{
// Unify the key between adapters
- if isset this->_socialFieldsMap[key] {
- let key = this->_socialFieldsMap[key];
+ if isset this->socialFieldsMap[key] {
+ let key = this->socialFieldsMap[key];
}
- return isset this->_userInfo[key];
+ return isset this->userInfo[key];
}
/**
@@ -113,11 +113,11 @@ abstract class Adapter implements SocialInterface
var value;
// Unify the key between adapters
- if isset this->_socialFieldsMap[key] {
- let key = this->_socialFieldsMap[key];
+ if isset this->socialFieldsMap[key] {
+ let key = this->socialFieldsMap[key];
}
- if fetch value, this->_userInfo[key] {
+ if fetch value, this->userInfo[key] {
return value;
}
diff --git a/ice/auth/social/facebook.zep b/ice/auth/social/facebook.zep
index 1dd96d88..57cf59e4 100644
--- a/ice/auth/social/facebook.zep
+++ b/ice/auth/social/facebook.zep
@@ -20,11 +20,11 @@ class Facebook extends Adapter
*/
public function __construct(config = [])
{
- let this->_provider = "facebook";
+ let this->provider = "facebook";
parent::__construct(config);
- let this->_socialFieldsMap = [
+ let this->socialFieldsMap = [
"socialId": "id",
"email": "email",
"name": "name",
@@ -62,27 +62,27 @@ class Facebook extends Adapter
if isset _GET["code"] {
let params = [
- "client_id": this->_clientId,
- "redirect_uri": this->_redirectUri,
- "client_secret": this->_clientSecret,
+ "client_id": this->clientId,
+ "redirect_uri": this->redirectUri,
+ "client_secret": this->clientSecret,
"code": _GET["code"]
];
// Be able to store access_token in the session (message: This_authorization_code_has_expired_)
- if !this->_accessToken {
+ if !this->accessToken {
parse_str(this->call(parent::GET, "https://graph.facebook.com/oauth/access_token", params, false), tokenInfo);
if count(tokenInfo) > 0 && isset tokenInfo["access_token"] {
- let this->_accessToken = tokenInfo["access_token"];
+ let this->accessToken = tokenInfo["access_token"];
}
}
- if this->_accessToken {
- let params = ["access_token": this->_accessToken],
+ if this->accessToken {
+ let params = ["access_token": this->accessToken],
userInfo = this->call(parent::GET, "https://graph.facebook.com/me", params);
if isset userInfo["id"] {
- let this->_userInfo = userInfo,
+ let this->userInfo = userInfo,
result = true;
}
}
@@ -100,8 +100,8 @@ class Facebook extends Adapter
return [
"auth_url": "https://www.facebook.com/dialog/oauth",
"auth_params": [
- "client_id": this->_clientId,
- "redirect_uri": this->_redirectUri,
+ "client_id": this->clientId,
+ "redirect_uri": this->redirectUri,
"response_type": "code",
"scope": "email,user_birthday"
]
diff --git a/ice/auth/social/google.zep b/ice/auth/social/google.zep
index 63999d27..6268b635 100644
--- a/ice/auth/social/google.zep
+++ b/ice/auth/social/google.zep
@@ -20,11 +20,11 @@ class Google extends Adapter
*/
public function __construct(config = [])
{
- let this->_provider = "google";
+ let this->provider = "google";
parent::__construct(config);
- let this->_socialFieldsMap = [
+ let this->socialFieldsMap = [
"socialId": "id",
"email": "email",
"name": "name",
@@ -42,9 +42,9 @@ class Google extends Adapter
public function getBirthday()
{
if this->has("birthday") {
- let this->_userInfo["birthday"] = str_replace("0000", date("Y"), this->_userInfo["birthday"]);
+ let this->userInfo["birthday"] = str_replace("0000", date("Y"), this->userInfo["birthday"]);
- return date("d.m.Y", strtotime(this->_userInfo["birthday"]));
+ return date("d.m.Y", strtotime(this->userInfo["birthday"]));
}
return null;
@@ -63,28 +63,28 @@ class Google extends Adapter
if isset _GET["code"] {
let params = [
- "client_id": this->_clientId,
- "client_secret": this->_clientSecret,
- "redirect_uri": this->_redirectUri,
+ "client_id": this->clientId,
+ "client_secret": this->clientSecret,
+ "redirect_uri": this->redirectUri,
"grant_type": "authorization_code",
"code": _GET["code"]
];
// Be able to store access_token in the session (invalid_grant: Code was already redeemed)
- if !this->_accessToken {
+ if !this->accessToken {
let tokenInfo = this->call(parent::POST, "https://accounts.google.com/o/oauth2/token", params);
if isset tokenInfo["access_token"] {
- let this->_accessToken = tokenInfo["access_token"];
+ let this->accessToken = tokenInfo["access_token"];
}
}
- if this->_accessToken {
- let params["access_token"] = this->_accessToken,
+ if this->accessToken {
+ let params["access_token"] = this->accessToken,
userInfo = this->call(parent::GET, "https://www.googleapis.com/oauth2/v1/userinfo", params);
- if isset userInfo[this->_socialFieldsMap["socialId"]] {
- let this->_userInfo = userInfo,
+ if isset userInfo[this->socialFieldsMap["socialId"]] {
+ let this->userInfo = userInfo,
result = true;
}
}
@@ -102,9 +102,9 @@ class Google extends Adapter
return [
"auth_url": "https://accounts.google.com/o/oauth2/auth",
"auth_params": [
- "redirect_uri": this->_redirectUri,
+ "redirect_uri": this->redirectUri,
"response_type": "code",
- "client_id": this->_clientId,
+ "client_id": this->clientId,
"scope": "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
]
];
diff --git a/ice/auth/social/twitter.zep b/ice/auth/social/twitter.zep
index 77083f29..0f728393 100644
--- a/ice/auth/social/twitter.zep
+++ b/ice/auth/social/twitter.zep
@@ -20,18 +20,18 @@ class Twitter extends Adapter
*/
public function __construct(config = [])
{
- let this->_provider = "twitter";
+ let this->provider = "twitter";
parent::__construct(config);
- let this->_socialFieldsMap = [
+ let this->socialFieldsMap = [
"socialId": "id",
"email": "email",
"name": "name",
"sex": "sex",
"birthday": "bdate"
],
- this->_responseType = "oauth_token";
+ this->responseType = "oauth_token";
}
/**
@@ -96,7 +96,7 @@ class Twitter extends Adapter
userInfo = this->call(parent::GET, getDataUrl, params);
if isset userInfo["id"] {
- let this->_userInfo = userInfo,
+ let this->userInfo = userInfo,
result = true;
}
}
@@ -114,7 +114,7 @@ class Twitter extends Adapter
var requestTokenUrl, requestTokens, params;
let requestTokenUrl = "https://api.twitter.com/oauth/request_token",
- params = this->prepareUrlParams(requestTokenUrl, ["oauth_callback": this->_redirectUri]),
+ params = this->prepareUrlParams(requestTokenUrl, ["oauth_callback": this->redirectUri]),
requestTokens = this->call(parent::GET, requestTokenUrl, params, false);
parse_str(requestTokens, requestTokens);
@@ -135,7 +135,7 @@ class Twitter extends Adapter
var sigBaseStr, key;
let params = array_merge([
- "oauth_consumer_key": this->_clientId,
+ "oauth_consumer_key": this->clientId,
"oauth_nonce": md5(uniqid(rand(), true)),
"oauth_signature_method": "HMAC-SHA1",
"oauth_timestamp": time(),
@@ -146,7 +146,7 @@ class Twitter extends Adapter
ksort(params);
let sigBaseStr = type . "&" . urlencode(url) . "&" . urlencode(http_build_query(params)),
- key = this->_clientSecret . "&" . oauthToken,
+ key = this->clientSecret . "&" . oauthToken,
params["oauth_signature"] = base64_encode(hash_hmac("sha1", sigBaseStr, key, true)),
params = array_map("urlencode", params);
diff --git a/ice/cli/console.zep b/ice/cli/console.zep
index 3f172501..f562a8d3 100644
--- a/ice/cli/console.zep
+++ b/ice/cli/console.zep
@@ -1,6 +1,7 @@
namespace Ice\Cli;
+use Ice\Di;
use Ice\Di\Access;
/**
@@ -15,13 +16,27 @@ use Ice\Di\Access;
class Console extends Access
{
- protected _modules { get, set };
+ protected modules { get, set };
const NORMAL = 0;
const BOLD_BRIGHT = 1;
const UNDERLINE = 4;
const INVERSE = 7;
+ /**
+ * Console constructor
+ *
+ * @param Di $di
+ */
+ public function __construct( di = null)
+ {
+ // Set the dependency injector
+ parent::__construct(di);
+
+ // Register the console itself as a service
+ this->di->set("console", this);
+ }
+
/**
* Handle an command-line request.
*
@@ -32,11 +47,11 @@ class Console extends Access
{
var router, response, dispatcher;
- let router = this->_di->{"getRouter"}(),
+ let router = this->di->get("router", null, true),
response = router->handle(arguments),
- dispatcher = this->_di->{"getDispatcher"}();
+ dispatcher = this->di->get("dispatcher", null, true);
- dispatcher->setModules(this->_modules);
+ dispatcher->setModules(this->modules);
dispatcher->setModule(response["module"]);
dispatcher->setHandler(response["handler"]);
dispatcher->setAction(response["action"]);
diff --git a/ice/cli/dispatcher.zep b/ice/cli/dispatcher.zep
index 66c2127f..de45696f 100644
--- a/ice/cli/dispatcher.zep
+++ b/ice/cli/dispatcher.zep
@@ -16,5 +16,5 @@ use Ice\Cli\Task;
class Dispatcher extends \Ice\Dispatcher
{
- protected _handlerSuffix = "Task";
+ protected handlerSuffix = "Task";
}
\ No newline at end of file
diff --git a/ice/cli/router.zep b/ice/cli/router.zep
index d2231291..633e378c 100644
--- a/ice/cli/router.zep
+++ b/ice/cli/router.zep
@@ -16,14 +16,14 @@ use Ice\Exception;
class Router
{
- protected _defaultModule = "shell" { get, set };
- protected _defaultHandler = "main" { get, set };
- protected _defaultAction = "main" { get, set };
+ protected defaultModule = "shell" { get, set };
+ protected defaultHandler = "main" { get, set };
+ protected defaultAction = "main" { get, set };
- protected _module { get };
- protected _handler { get };
- protected _action { get };
- protected _params = [] { get };
+ protected module { get };
+ protected handler { get };
+ protected action { get };
+ protected params = [] { get };
/**
* Set defaults values
@@ -35,15 +35,15 @@ class Router
var module, handler, action;
if fetch module, defaults["module"] {
- let this->_defaultModule = module;
+ let this->defaultModule = module;
}
if fetch handler, defaults["handler"] {
- let this->_defaultHandler = handler;
+ let this->defaultHandler = handler;
}
if fetch action, defaults["action"] {
- let this->_defaultAction = action;
+ let this->defaultAction = action;
}
}
@@ -66,9 +66,9 @@ class Router
}
// Set the defaults
- let this->_module = this->_defaultModule,
- this->_handler = this->_defaultHandler,
- this->_action = this->_defaultAction,
+ let this->module = this->defaultModule,
+ this->handler = this->defaultHandler,
+ this->action = this->defaultAction,
params = [];
// Skip the first option, it is always the file executed
@@ -95,27 +95,27 @@ class Router
}
if isset params["module"] && params["module"] {
- let this->_module = params["module"];
+ let this->module = params["module"];
unset params["module"];
}
if isset params["handler"] && params["handler"] {
- let this->_handler = params["handler"];
+ let this->handler = params["handler"];
unset params["handler"];
}
if isset params["action"] && params["action"] {
- let this->_action = params["action"];
+ let this->action = params["action"];
unset params["action"];
}
if count(params) {
- let this->_params = params;
+ let this->params = params;
}
- return ["module": this->_module, "handler": this->_handler, "action": this->_action, "params": this->_params];
+ return ["module": this->module, "handler": this->handler, "action": this->action, "params": this->params];
}
}
diff --git a/ice/config.zep b/ice/config.zep
index 56e2b6e6..d310c5fb 100644
--- a/ice/config.zep
+++ b/ice/config.zep
@@ -45,12 +45,12 @@ class Config extends Arr
}
}
if hasNumericKey {
- let this->_data[key] = value;
+ let this->data[key] = value;
} else {
- let this->_data[key] = new Config(value);
+ let this->data[key] = new Config(value);
}
} else {
- let this->_data[key] = value;
+ let this->data[key] = value;
}
}
}
diff --git a/ice/config/json.zep b/ice/config/json.zep
new file mode 100644
index 00000000..8ad688e3
--- /dev/null
+++ b/ice/config/json.zep
@@ -0,0 +1,32 @@
+
+namespace Ice\Config;
+
+use Ice\Config;
+use Ice\Exception;
+
+/**
+ * Adapter for get config from json files.
+ *
+ * @package Ice/Config
+ * @category Configuration
+ * @author Ice Team
+ * @copyright (c) 2014-2015 Ice Team
+ * @license http://iceframework.org/license
+ */
+class Json extends Config
+{
+
+ /**
+ * Config json constructor.
+ *
+ * @param string data Path to the json file
+ */
+ public function __construct(var data = null)
+ {
+ if typeof data != "string" {
+ throw new Exception("The file path must be a string");
+ }
+
+ parent::__construct(json_decode(file_get_contents(data), true));
+ }
+}
diff --git a/ice/cookies.zep b/ice/cookies.zep
index 9d1532c7..d515a05d 100644
--- a/ice/cookies.zep
+++ b/ice/cookies.zep
@@ -13,21 +13,21 @@ namespace Ice;
class Cookies
{
- protected _di;
- protected _salt { get, set };
- protected _expiration = 0 { get, set };
- protected _path = "/" { get, set };
- protected _domain = null { get, set };
- protected _secure = false { get, set };
- protected _httpOnly = false { get, set };
- protected _encrypt = true { get, set };
+ protected di;
+ protected salt { get, set };
+ protected expiration = 0 { get, set };
+ protected path = "/" { get, set };
+ protected domain = null { get, set };
+ protected secure = false { get, set };
+ protected httpOnly = false { get, set };
+ protected encrypt = true { get, set };
public function __construct(string salt = null)
{
- let this->_di = Di::$fetch();
- let this->_salt = salt;
+ let this->di = Di::$fetch();
+ let this->salt = salt;
- //let this->_data = &_COOKIE;
+ //let this->data = &_COOKIE;
}
/**
@@ -67,8 +67,8 @@ class Cookies
if this->salt(key, value) == hash {
// Cookie signature is valid
- if this->_encrypt {
- let value = this->_di->{"getCrypt"}()->decrypt(value);
+ if this->encrypt {
+ let value = this->di->get("crypt", null, true)->decrypt(value);
}
return value;
@@ -94,19 +94,19 @@ class Cookies
{
if !lifetime {
// Use the default expiration
- let lifetime = (int) this->_expiration;
+ let lifetime = (int) this->expiration;
}
- if this->_encrypt {
+ if this->encrypt {
if !empty value {
- let value = this->_di->{"getCrypt"}()->encrypt(value);
+ let value = this->di->get("crypt", null, true)->encrypt(value);
}
}
// Add the salt to the cookie value
let value = this->salt(key, value) . "~" . value;
- return this->_setcookie(key, value, lifetime, this->_path, this->_domain, this->_secure, this->_httpOnly);
+ return this->setcookie(key, value, lifetime, this->path, this->domain, this->secure, this->httpOnly);
}
/**
@@ -121,7 +121,7 @@ class Cookies
unset _COOKIE[key];
// Nullify the cookie and make it expire
- return this->_setcookie(key, null, -86400, this->_path, this->_domain, this->_secure, this->_httpOnly);
+ return this->setcookie(key, null, -86400, this->path, this->domain, this->secure, this->httpOnly);
}
/**
@@ -137,14 +137,14 @@ class Cookies
var userAgent;
// Require a valid salt
- if !this->_salt {
+ if !this->salt {
throw new Exception("A valid cookie salt is required.");
}
// Determine the user agent
- let userAgent = this->_di->{"getRequest"}()->getUserAgent();
+ let userAgent = this->di->get("request", null, true)->getUserAgent();
- return sha1(userAgent . name . value . this->_salt);
+ return sha1(userAgent . name . value . this->salt);
}
/**
@@ -161,7 +161,7 @@ class Cookies
* @return bool
* @see setcookie
*/
- protected function _setcookie(string name, string value, int expire, string path, string domain, boolean secure, boolean httpOnly)
+ protected function setcookie(string name, string value, int expire, string path, string domain, boolean secure, boolean httpOnly)
{
return setcookie(name, value, expire, path, domain, secure, httpOnly);
}
diff --git a/ice/crypt.zep b/ice/crypt.zep
index ea6d92e6..386a3e4b 100644
--- a/ice/crypt.zep
+++ b/ice/crypt.zep
@@ -14,10 +14,10 @@ namespace Ice;
class Crypt
{
- protected _key;
- protected _cipher = "aes-256";
- protected _mode = "cbc";
- protected _block = 16;
+ protected key;
+ protected cipher = "aes-256";
+ protected mode = "cbc";
+ protected block = 16;
/**
* Create a new encrypter instance.
@@ -27,7 +27,7 @@ class Crypt
*/
public function __construct(string key)
{
- let this->_key = key;
+ let this->key = key;
}
/**
@@ -42,7 +42,7 @@ class Crypt
let iv = this->generateInputVector(),
value = this->addPadding(serialize(text)),
- value = base64_encode(this->_encrypt(value, iv));
+ value = base64_encode(this->doEncrypt(value, iv));
// Once we have the encrypted value we will go ahead base64_encode the input
// vector and create the MAC for the encrypted value so we can verify its
@@ -74,9 +74,9 @@ class Crypt
* @param string iv
* @return string
*/
- protected function _encrypt(string value, string iv) -> string
+ protected function doEncrypt(string value, string iv) -> string
{
- return openssl_encrypt(value, this->_cipher . "-" . this->_mode, this->_key, OPENSSL_RAW_DATA, iv);
+ return openssl_encrypt(value, this->cipher . "-" . this->mode, this->key, OPENSSL_RAW_DATA, iv);
}
/**
@@ -97,7 +97,7 @@ class Crypt
let value = base64_decode(payload["value"]),
iv = base64_decode(payload["iv"]);
- return unserialize(this->stripPadding(this->_decrypt(value, iv)));
+ return unserialize(this->stripPadding(this->doDecrypt(value, iv)));
}
/**
@@ -107,9 +107,9 @@ class Crypt
* @param string iv
* @return string
*/
- protected function _decrypt(string value, string iv) -> string
+ protected function doDecrypt(string value, string iv) -> string
{
- return openssl_decrypt(value, this->_cipher . "-" . this->_mode, this->_key, OPENSSL_RAW_DATA, iv);
+ return openssl_decrypt(value, this->cipher . "-" . this->mode, this->key, OPENSSL_RAW_DATA, iv);
}
/**
@@ -147,7 +147,7 @@ class Crypt
*/
protected function hash(string value) -> string
{
- return hash_hmac("sha256", value, this->_key);
+ return hash_hmac("sha256", value, this->key);
}
/**
@@ -161,7 +161,7 @@ class Crypt
var pad, len;
let len = strlen(value),
- pad = this->_block - (len % this->_block);
+ pad = this->block - (len % this->block);
return value . str_repeat(chr(pad), pad);
}
@@ -216,7 +216,7 @@ class Crypt
*/
protected function getIvSize() -> int
{
- return openssl_cipher_iv_length(this->_cipher . "-" . this->_mode);
+ return openssl_cipher_iv_length(this->cipher . "-" . this->mode);
}
/**
@@ -227,7 +227,7 @@ class Crypt
*/
public function setKey(string key)
{
- let this->_key = key;
+ let this->key = key;
}
/**
@@ -238,7 +238,7 @@ class Crypt
*/
public function setCipher(string cipher)
{
- let this->_cipher = cipher;
+ let this->cipher = cipher;
}
/**
@@ -249,6 +249,6 @@ class Crypt
*/
public function setMode(string mode)
{
- let this->_mode = mode;
+ let this->mode = mode;
}
}
diff --git a/ice/db.zep b/ice/db.zep
index 870159de..cc8827b8 100644
--- a/ice/db.zep
+++ b/ice/db.zep
@@ -1,6 +1,8 @@
namespace Ice;
+use Ice\Db\Driver\Mongo;
+use Ice\Db\Driver\Pdo;
use Ice\Db\DbInterface;
/**
@@ -15,22 +17,49 @@ use Ice\Db\DbInterface;
class Db
{
- protected _driver { get };
+ protected driver { get, set };
/**
* Db constructor.
*
- * @param DbInterface driver Database driver
+ * @param mixed driver
+ * @param string host
+ * @param int port
+ * @param string name
+ * @param string user
+ * @param string password
*/
- public function __construct( driver)
+ public function __construct(var driver, string host = null, int port = null, string name = null, string user = null, string password = null)
{
- let this->_driver = driver;
+ if typeof driver == "object" && (driver instanceof DbInterface) {
+ let this->driver = driver;
+ } elseif typeof driver == "string" {
+ if driver == "mongodb" {
+ let this->driver = new Mongo(
+ driver . "://" .
+ user . ":" .
+ password . "@" .
+ host . ":" .
+ port . "/" .
+ name,
+ name
+ );
+ } else {
+ let this->driver = new Pdo(
+ driver . ":host=" .
+ host . ";port=" .
+ port . ";dbname=" .
+ name,
+ user, password
+ );
+ }
+ }
}
/**
* Magic call, call driver's method.
*/
public function __call(string method, arguments = null) {
- return call_user_func_array([this->_driver, method], arguments);
+ return call_user_func_array([this->driver, method], arguments);
}
}
diff --git a/ice/db/driver/mongo.zep b/ice/db/driver/mongo.zep
index eae1eb40..31d27b52 100644
--- a/ice/db/driver/mongo.zep
+++ b/ice/db/driver/mongo.zep
@@ -2,6 +2,7 @@
namespace Ice\Db\Driver;
use Ice\Arr;
+use Ice\Exception;
use Ice\Db\DbInterface;
/**
@@ -16,22 +17,33 @@ use Ice\Db\DbInterface;
class Mongo implements DbInterface
{
- protected _id = "_id" { get };
- protected _type = "NOSQL" { get };
- protected _error;
- protected _client { get };
- protected _lastInsertId { get };
-
- /**
- * Instantiate mongo connection.
- *
- * @param string dsn
- * @param string dbname
- * @param array options
- */
+ protected id = "_id" { get };
+ protected type = "NOSQL" { get };
+ protected error;
+ protected client { get };
+ protected lastInsertId { get };
+
+ /**
+ * Instantiate mongo connection.
+ *
+ * @param string dsn
+ * @param string dbname
+ * @param array options
+ */
public function __construct(string dsn, string dbname = NULL, array options = [])
{
- let this->_client = new \MongoDB(new \MongoClient(dsn, options), dbname);
+ let this->client = new \MongoDB(new \MongoClient(dsn, options), dbname);
+ }
+
+ /**
+ * Get the id value.
+ *
+ * @param string id
+ * @return object
+ */
+ public function getIdValue(string id) -> object
+ {
+ return new \MongoId(id);
}
/**
@@ -90,6 +102,14 @@ class Mongo implements DbInterface
var filtered, collection, result, tmp;
switch typeof filters {
+ case "object":
+ // Find by MongoId
+ if filters instanceof \MongoId {
+ let filtered = [this->id: filters];
+ } else {
+ throw new Exception("Object must be an MongoId instance");
+ }
+ break;
case "array":
// Find by filters
let filtered = filters;
@@ -97,7 +117,7 @@ class Mongo implements DbInterface
case "integer":
case "string":
// Find by id
- let filtered = [this->_id: new \MongoId(filters)];
+ let filtered = [this->id: this->getIdValue(filters)];
break;
default:
// Find all
@@ -105,7 +125,7 @@ class Mongo implements DbInterface
break;
}
- let collection = this->_client->selectcollection(from),
+ let collection = this->client->selectcollection(from),
result = collection->find(filtered, fields);
if isset options["order"] {
@@ -121,7 +141,7 @@ class Mongo implements DbInterface
result = tmp->skip(options["offset"]);
}
- let this->_error = this->_client->lastError();
+ let this->error = this->client->lastError();
return result;
}
@@ -136,10 +156,10 @@ class Mongo implements DbInterface
{
var collection, status;
- let collection = this->_client->selectcollection(from),
+ let collection = this->client->selectcollection(from),
status = collection->insert(fields),
- this->_lastInsertId = fields[this->_id],
- this->_error = status;
+ this->lastInsertId = fields[this->id],
+ this->error = status;
return status["err"] === null ? true : status;
}
@@ -155,9 +175,9 @@ class Mongo implements DbInterface
{
var collection, status;
- let collection = this->_client->selectcollection(from),
+ let collection = this->client->selectcollection(from),
status = collection->update(filters, fields),
- this->_error = status;
+ this->error = status;
return status["err"] === null ? true : status;
}
@@ -172,9 +192,9 @@ class Mongo implements DbInterface
{
var collection, status;
- let collection = this->_client->selectcollection(from),
+ let collection = this->client->selectcollection(from),
status = collection->remove(filters),
- this->_error = status;
+ this->error = status;
return status["err"] === null ? true : status;
}
@@ -188,7 +208,7 @@ class Mongo implements DbInterface
{
var error;
- fetch error, this->_error["err"];
+ fetch error, this->error["err"];
return error;
}
diff --git a/ice/db/driver/pdo.zep b/ice/db/driver/pdo.zep
index ef00b037..d2ea223b 100644
--- a/ice/db/driver/pdo.zep
+++ b/ice/db/driver/pdo.zep
@@ -16,19 +16,19 @@ use Ice\Db\DbInterface;
class Pdo implements DbInterface
{
- protected _id = "id" { get };
- protected _type = "SQL" { get };
- protected _error;
- protected _client { get };
-
- /**
- * Instantiate pdo connection.
- *
- * @param string dsn
- * @param string user
- * @param string password
- * @param array options
- */
+ protected id = "id" { get };
+ protected type = "SQL" { get };
+ protected error;
+ protected client { get };
+
+ /**
+ * Instantiate pdo connection.
+ *
+ * @param string dsn
+ * @param string user
+ * @param string password
+ * @param array options
+ */
public function __construct(string dsn, string user = NULL, string password = NULL, array options = [])
{
var parts;
@@ -41,7 +41,18 @@ class Pdo implements DbInterface
let options[\PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES utf8;";
}
- let this->_client = new \Pdo(dsn, user, password, options);
+ let this->client = new \Pdo(dsn, user, password, options);
+ }
+
+ /**
+ * Get the id value.
+ *
+ * @param string id
+ * @return int
+ */
+ public function getIdValue(id) -> int
+ {
+ return (int) id;
}
/**
@@ -235,11 +246,11 @@ class Pdo implements DbInterface
let sql .= " OFFSET " . options["offset"];
}
- let query = this->_client->prepare(sql);
+ let query = this->client->prepare(sql);
query->execute(values);
- let this->_error = query->errorInfo();
+ let this->error = query->errorInfo();
return query;
}
@@ -263,9 +274,9 @@ class Pdo implements DbInterface
}
let sql = "INSERT INTO `" . from . "` (" . join(", ", columns) . ") VALUES (" . join(", ", array_keys(values)) . ")",
- query = this->_client->prepare(sql),
+ query = this->client->prepare(sql),
status = query->execute(values),
- this->_error = query->errorInfo();
+ this->error = query->errorInfo();
return status;
}
@@ -292,9 +303,9 @@ class Pdo implements DbInterface
let filtered = this->where(filters, values),
sql = "UPDATE `" . from . "` SET " . join(", ", columns) . " WHERE " . filtered[0],
values = array_merge(values, filtered[1]),
- query = this->_client->prepare(sql),
+ query = this->client->prepare(sql),
status = query->execute(values),
- this->_error = query->errorInfo();
+ this->error = query->errorInfo();
return status;
}
@@ -312,9 +323,9 @@ class Pdo implements DbInterface
let filtered = this->where(filters),
sql = "DELETE FROM `" . from . "` WHERE " . filtered[0],
values = filtered[1],
- query = this->_client->prepare(sql),
+ query = this->client->prepare(sql),
status = query->execute(values),
- this->_error = query->errorInfo();
+ this->error = query->errorInfo();
return status;
}
@@ -326,7 +337,7 @@ class Pdo implements DbInterface
*/
public function getLastInsertId() -> int
{
- return (int) this->_client->lastInsertId();
+ return (int) this->client->lastInsertId();
}
/**
@@ -338,7 +349,7 @@ class Pdo implements DbInterface
{
var error;
- fetch error, this->_error[0];
+ fetch error, this->error[0];
return error;
}
diff --git a/ice/di.zep b/ice/di.zep
index 8e27a526..94be64f4 100644
--- a/ice/di.zep
+++ b/ice/di.zep
@@ -13,19 +13,24 @@ namespace Ice;
class Di extends Arr
{
- protected static _di;
- protected _hooks = [];
+ protected static di;
+ protected hooks = [];
/**
- * Di constructor.
+ * Di constructor. Sets root path.
*
* @param array data Array of services
*/
public function __construct(array data = [])
{
+ // Set the root path
+ if !defined("__ROOT__") {
+ define("__ROOT__", realpath("../"), false);
+ }
+
parent::__construct(data);
- let self::_di = this;
+ let self::di = this;
}
/**
@@ -35,7 +40,7 @@ class Di extends Arr
*/
public static function $fetch() ->
{
- return self::_di;
+ return self::di;
}
/**
@@ -48,7 +53,7 @@ class Di extends Arr
{
var service;
let service = this->resolve(value),
- this->_data[key] = service;
+ this->data[key] = service;
}
/**
@@ -120,12 +125,12 @@ class Di extends Arr
*/
public function hook(string name, var callback, int priority = 10)
{
- if !isset this->_hooks[name] {
- let this->_hooks[name] = [[]];
+ if !isset this->hooks[name] {
+ let this->hooks[name] = [[]];
}
if typeof callback == "callable" {
- let this->_hooks[name][priority][] = callback;
+ let this->hooks[name][priority][] = callback;
}
}
/**
@@ -138,17 +143,17 @@ class Di extends Arr
{
var priority, callback;
- if !isset this->_hooks[name] {
- let this->_hooks[name] = [[]];
+ if !isset this->hooks[name] {
+ let this->hooks[name] = [[]];
}
- if !empty this->_hooks[name] {
+ if !empty this->hooks[name] {
// Sort by priority, low to high, if there's more than one priority
- //if count(this->_hooks[name]) > 1 {
- // ksort(this->_hooks[name]);
+ //if count(this->hooks[name]) > 1 {
+ // ksort(this->hooks[name]);
//}
- for priority in this->_hooks[name] {
+ for priority in this->hooks[name] {
if !empty priority {
for callback in priority {
call_user_func_array(callback, args);
@@ -169,9 +174,9 @@ class Di extends Arr
public function getHooks(string name = null) -> array | null
{
if name {
- return isset this->_hooks[name] ? this->_hooks[name] : null;
+ return isset this->hooks[name] ? this->hooks[name] : null;
} else {
- return this->_hooks;
+ return this->hooks;
}
}
/**
@@ -185,11 +190,11 @@ class Di extends Arr
{
var key;
- if name && isset this->_hooks[name] {
- let this->_hooks[name] = [[]];
+ if name && isset this->hooks[name] {
+ let this->hooks[name] = [[]];
} else {
- for key in array_keys(this->_hooks) {
- let this->_hooks[key] = [[]];
+ for key in array_keys(this->hooks) {
+ let this->hooks[key] = [[]];
}
}
}
diff --git a/ice/di/access.zep b/ice/di/access.zep
index b5d64ae6..686cb952 100644
--- a/ice/di/access.zep
+++ b/ice/di/access.zep
@@ -16,7 +16,7 @@ use Ice\Di;
class Access
{
- protected _di;
+ protected di;
/**
* Access constructor. Fetch di if not specified.
@@ -26,9 +26,9 @@ class Access
public function __construct( di = null)
{
if !di {
- let this->_di = Di::$fetch();
+ let this->di = Di::$fetch();
} else {
- let this->_di = di;
+ let this->di = di;
}
}
@@ -39,7 +39,7 @@ class Access
{
var di, service;
- let di = this->_di;
+ let di = this->di;
if property == "di" {
let this->{"di"} = di;
@@ -48,7 +48,7 @@ class Access
}
if di->has(property) {
- let service = di->{"get"}(property),
+ let service = di->get(property),
this->{property} = service;
return service;
diff --git a/ice/dispatcher.zep b/ice/dispatcher.zep
index 2df4b988..1c84a4b9 100644
--- a/ice/dispatcher.zep
+++ b/ice/dispatcher.zep
@@ -16,30 +16,31 @@ use Ice\Mvc\ModuleInterface;
abstract class Dispatcher
{
- protected _di;
- protected _defaultNamespace { get, set };
- protected _activeHandler { get };
- protected _lastHandler { get };
+ protected di;
+ protected defaultNamespace { get, set };
+ protected activeHandler { get };
+ protected lastHandler { get };
- protected _finished { get };
- protected _forwarded = false { get };
- protected _silent = false { set };
+ protected loops = 0 { get };
+ protected finished { get };
+ protected forwarded = false { get };
+ protected silent = false { set };
- protected _modules = [] { get, set };
- protected _module = null { get, set };
- protected _namespace = null { get, set };
- protected _handler = null { get, set };
- protected _action = null { get, set };
+ protected modules = [] { get, set };
+ protected module = null { get, set };
+ protected $namespace = null { get, set };
+ protected handler = null { get, set };
+ protected action = null { get, set };
- protected _params = [] { get, set };
- protected _returnedValue = null { get, set };
+ protected params = [] { get, set };
+ protected returnedValue = null { get, set };
- protected _handlerSuffix = "Handler" { get, set };
- protected _actionSuffix = "Action" { get, set };
+ protected handlerSuffix = "Handler" { get, set };
+ protected actionSuffix = "Action" { get, set };
- protected _previousModule = null;
- protected _previousHandler = null;
- protected _previousAction = null;
+ protected previousModule = null;
+ protected previousHandler = null;
+ protected previousAction = null;
const DISPATCH_CYCLIC = 1;
const HANDLER_NOT_FOUND = 2;
@@ -51,7 +52,18 @@ abstract class Dispatcher
*/
public function __construct()
{
- let this->_di = Di::$fetch();
+ let this->di = Di::$fetch();
+ }
+
+ /**
+ * Whether or not an param exists by key.
+ *
+ * @param string key The param key
+ * @return boolean
+ */
+ public function hasParam(string key) -> boolean
+ {
+ return isset this->params[key];
}
/**
@@ -62,24 +74,52 @@ abstract class Dispatcher
*/
public function setParam(var param, var value)
{
- let this->_params[param] = value;
+ let this->params[param] = value;
}
/**
- * Gets a param by its name or numeric index.
+ * Gets variable from params attribute applying filters if needed.
+ * If no parameters are given, return all.
*
- * @param mixed param
- * @param mixed defaultValue
+ *
+ * //Returns value from $params["id"] without sanitizing
+ * $id = $this->router->getParam("id");
+ *
+ * //Returns value from $params["title"] with sanitizing
+ * $title = $this->router->getParam("title", "escape|repeats");
+ *
+ * //Returns value from $params["id"] with a default value
+ * $id = $this->router->getParam("id", null, 150);
+ *
+ *
+ * @param string key Index to get
+ * @param string|array filters Filters to apply
+ * @param mixed defaultValue Default value if key not exist or value is empty and allowEmpty is false
+ * @param boolean allowEmpty
* @return mixed
*/
- public function getParam(param, defaultValue = null)
+ public function getParam(string key = null, var filters = null, var defaultValue = null, boolean allowEmpty = false)
{
- var value;
+ var params, value, filter;
+
+ let params = new Arr(this->params);
+
+ if !key {
+ return params;
+ } else {
+ let value = params->get(key, defaultValue);
+
+ if filters {
+ let filter = Di::$fetch()->get("filter", null, true),
+ value = filter->sanitize(value, filters);
+ }
+
+ if (value === "" || value === null) && allowEmpty === false {
+ return defaultValue;
+ }
- if fetch value, this->_params[param] {
return value;
}
- return defaultValue;
}
/**
@@ -89,7 +129,7 @@ abstract class Dispatcher
*/
public function getActiveMethod() -> string
{
- return this->_action . this->_actionSuffix;
+ return this->action . this->actionSuffix;
}
/**
@@ -99,23 +139,21 @@ abstract class Dispatcher
*/
public function dispatch()
{
- var handler, response, handlerName, actionName, params, handlerSuffix, actionSuffix, handlerClass, actionMethod;
+ var handler, response, handlerName, actionName, params, handlerSuffix, handlerClass, actionMethod;
var fresh, module, modules, moduleNamespace, path, moduleClass, loader;
- int i = 0;
- let response = this->_di->get("response"),
+ let response = this->di->get("response"),
fresh = true,
handler = null,
- handlerSuffix = this->_handlerSuffix,
- actionSuffix = this->_actionSuffix,
- this->_finished = false;
+ handlerSuffix = this->handlerSuffix,
+ this->finished = false;
- while !this->_finished {
- let i++;
+ while !this->finished {
+ let this->loops++;
// Throw an exception after 16 consecutive forwards
- if i == 16 {
- if this->_silent {
+ if this->loops > 16 {
+ if this->silent {
// 508 Loop Detected
response->setStatus(508);
response->setBody(response->getMessage(508));
@@ -125,12 +163,12 @@ abstract class Dispatcher
throw new Exception("Dispatcher has detected a cyclic routing causing stability problems", self::DISPATCH_CYCLIC);
}
- let this->_finished = true,
- modules = this->_modules;
+ let this->finished = true,
+ modules = this->modules;
if modules {
- if !fetch module, modules[this->_module] {
- throw new Exception(["Module '%s' isn't registered in the application container", this->_module]);
+ if !fetch module, modules[this->module] {
+ throw new Exception(["Module '%s' isn't registered in the application container", this->module]);
}
if typeof module != "array" {
@@ -152,26 +190,26 @@ abstract class Dispatcher
}
let loader = new Loader(),
- this->_namespace = moduleNamespace;
+ this->$namespace = moduleNamespace;
loader->addNamespace(moduleNamespace, path)->register();
- let module = create_instance_params(moduleNamespace . "\\" . moduleClass, [this->_di]);
+ let module = create_instance_params(moduleNamespace . "\\" . moduleClass, [this->di]);
module->registerAutoloaders();
- module->registerServices(this->_di);
+ module->registerServices(this->di);
}
- if !this->_defaultNamespace {
- this->setDefaultNamespace(this->_namespace . "\\" . this->getHandlerSuffix());
+ if !this->defaultNamespace {
+ this->setDefaultNamespace(this->$namespace . "\\" . this->getHandlerSuffix());
}
- let handlerName = this->_handler,
- actionName = this->_action,
- handlerClass = this->_defaultNamespace . "\\" . ucfirst(camelize(handlerName)) . handlerSuffix;
+ let handlerName = this->handler,
+ actionName = this->action,
+ handlerClass = this->defaultNamespace . "\\" . ucfirst(camelize(handlerName)) . handlerSuffix;
if !class_exists(handlerClass) {
- if this->_silent {
+ if this->silent {
// 404 Not Found
response->setStatus(404);
response->setBody(response->getMessage(404));
@@ -181,20 +219,19 @@ abstract class Dispatcher
throw new Exception(["%s handler class cannot be loaded", handlerClass], self::HANDLER_NOT_FOUND);
}
- let this->_lastHandler = handler,
+ let this->lastHandler = handler,
handler = new {handlerClass}(),
- this->_activeHandler = handler,
+ this->activeHandler = handler,
actionMethod = this->getActiveMethod();
if method_exists(handler, "before") {
handler->before();
- if this->_finished === false {
+ if this->finished === false {
continue;
}
}
-
// Call the 'initialize' method just once per request
if fresh === true {
if method_exists(handler, "initialize") {
@@ -204,7 +241,7 @@ abstract class Dispatcher
// Check if the method exists in the handler
if !method_exists(handler, actionMethod) {
- if this->_silent {
+ if this->silent {
// 404 Not Found
response->setStatus(404);
response->setBody(response->getMessage(404));
@@ -214,21 +251,21 @@ abstract class Dispatcher
throw new Exception(["Action '%s' was not found on handler '%s'", actionName, handlerName], self::ACTION_NOT_FOUND);
}
- let params = this->_params;
+ let params = this->params;
if typeof params != "array" {
throw new Exception("Action parameters must be an array", self::INVALID_PARAMS);
}
- let this->_returnedValue = call_user_func_array([handler, actionMethod], params);
+ let this->returnedValue = call_user_func_array([handler, actionMethod], params);
- if this->_finished === false {
+ if this->finished === false {
continue;
}
if method_exists(handler, "after") {
handler->after();
- if this->_finished === false {
+ if this->finished === false {
continue;
}
}
@@ -242,35 +279,40 @@ abstract class Dispatcher
* Forwards the execution flow to another module/controller/action.
*
* @param array forward
+ * @param boolean force
*/
- public function forward(array! forward)
+ public function forward(array! forward, boolean force = false)
{
var module, handler, action, params;
// Check if we need to forward to another module
if fetch module, forward["module"] {
- let this->_previousModule = this->_module,
- this->_module = module;
+ let this->previousModule = this->module,
+ this->module = module;
}
// Check if we need to forward to another handler
if fetch handler, forward["handler"] {
- let this->_previousHandler = this->_handler,
- this->_handler = handler;
+ let this->previousHandler = this->handler,
+ this->handler = handler;
}
// Check if we need to forward to another action
if fetch action, forward["action"] {
- let this->_previousAction = this->_action,
- this->_action = action;
+ let this->previousAction = this->action,
+ this->action = action;
}
// Check if we need to forward changing the current parameters
if fetch params, forward["params"] {
- let this->_params = params;
+ let this->params = params;
}
- let this->_finished = false,
- this->_forwarded = true;
+ let this->finished = false,
+ this->forwarded = true;
+
+ if force {
+ this->dispatch();
+ }
}
}
diff --git a/ice/dump.zep b/ice/dump.zep
index c66c01f7..02dfa618 100644
--- a/ice/dump.zep
+++ b/ice/dump.zep
@@ -30,9 +30,9 @@ namespace Ice;
class Dump
{
- protected _detailed = false { get, set };
- protected _methods = [];
- protected _styles = [];
+ protected detailed = false { get, set };
+ protected methods = [];
+ protected styles = [];
/**
* Dump constructor
@@ -46,7 +46,7 @@ class Dump
throw new Exception("The styles must be an array");
}
this->setStyles(styles);
- let this->_detailed = detailed;
+ let this->detailed = detailed;
}
@@ -76,7 +76,7 @@ class Dump
{
var style;
- if fetch style, this->_styles[type] {
+ if fetch style, this->styles[type] {
return style;
} else {
return "color:gray";
@@ -112,8 +112,8 @@ class Dump
"str": "color:teal"
];
- let this->_styles = array_merge(defaultStyles, styles);
- return this->_styles;
+ let this->styles = array_merge(defaultStyles, styles);
+ return this->styles;
}
/**
@@ -143,6 +143,7 @@ class Dump
protected function output(variable, name = null, tab = 1) -> string
{
var key, value, output, space, type, attr;
+
let space = " ",
output = "";
@@ -176,12 +177,17 @@ class Dump
}
let output .= " (\n";
- if !this->_detailed {
+ if variable instanceof Di {
+ // Skip debuging di
+ let output .= str_repeat(space, tab) . "[skipped]\n";
+ } elseif !this->detailed {
+ // Debug only public properties
for key, value in get_object_vars(variable) {
let output .= str_repeat(space, tab) . strtr("->:key (:type ) = ", [":style": this->getStyle("obj"), ":key": key, ":type": "public"]);
let output .= this->output(value, "", tab + 1) . "\n";
}
} else {
+ // Debug all properties
do {
let attr = each(variable);
@@ -194,7 +200,9 @@ class Dump
if !key {
continue;
}
- let key = explode(chr(ord("\x00")), key),
+
+ // Explode key by the "\x00" char
+ let key = explode(chr(0), key),
type = "public";
if isset key[1] {
@@ -204,20 +212,20 @@ class Dump
let type = "protected";
}
}
- let output .= str_repeat(space, tab) . strtr("->:key (:type ) = ", [":style": this->getStyle("obj"), ":key": end(key), ":type": type]);
- let output .= this->output(value, "", tab + 1) . "\n";
+ let output .= str_repeat(space, tab) . strtr("->:key (:type ) = ", [":style": this->getStyle("obj"), ":key": end(key), ":type": type]),
+ output .= this->output(value, "", tab + 1) . "\n";
} while attr;
}
- let attr = get_class_methods(variable);
- let output .= str_repeat(space, tab) . strtr(":class methods : (:count ) (\n", [":style": this->getStyle("obj"), ":class": className, ":count": count(attr)]);
+ let attr = get_class_methods(variable),
+ output .= str_repeat(space, tab) . strtr(":class methods : (:count ) (\n", [":style": this->getStyle("obj"), ":class": className, ":count": count(attr)]);
- if (in_array(className, this->_methods)) {
+ if in_array(className, this->methods) {
let output .= str_repeat(space, tab) . "[already listed]\n";
} else {
for value in attr {
- if !in_array(className, this->_methods) {
- let this->_methods[] = className;
+ if !in_array(className, this->methods) {
+ let this->methods[] = className;
}
if value == "__construct" {
let output .= str_repeat(space, tab + 1) . strtr("->:method (); [constructor ]\n", [":style": this->getStyle("obj"), ":method": value]);
@@ -293,6 +301,7 @@ class Dump
var key, value, output;
let output = "";
+
for key, value in func_get_args() {
let output .= this->one(value, "var " . key);
}
diff --git a/ice/exception.zep b/ice/exception.zep
index b61f53d9..5d70320c 100644
--- a/ice/exception.zep
+++ b/ice/exception.zep
@@ -37,7 +37,7 @@ class Exception extends \Exception
// Check if translation module is available.
if di->has("i18n") {
- let message = di->{"get"}("i18n")->translate(str, values);
+ let message = di->get("i18n", null, true)->translate(str, values);
} elseif (typeof values == "array") {
// Check if values is associative or sequential
if count(array_filter(array_keys(values), "is_string")) {
diff --git a/ice/filter.zep b/ice/filter.zep
index e4ddeb05..d4994a43 100644
--- a/ice/filter.zep
+++ b/ice/filter.zep
@@ -13,7 +13,7 @@ namespace Ice;
class Filter
{
- protected _filters;
+ protected filters;
/**
* Adds a user-defined filter.
@@ -27,7 +27,7 @@ class Filter
throw new Exception("Filter must be an object");
}
- let this->_filters[name] = body;
+ let this->filters[name] = body;
}
/**
@@ -47,7 +47,7 @@ class Filter
if typeof filters == "array" {
for filter in filters {
- let value = this->_sanitize(value, filter);
+ let value = this->doSanitize(value, filter);
}
}
@@ -61,12 +61,12 @@ class Filter
* @param string filter
* @return mixed
*/
- protected function _sanitize(string value, string! filter)
+ protected function doSanitize(string value, string! filter)
{
var custom;
// Try a user-defined filter first
- if fetch custom, this->_filters[filter] {
+ if fetch custom, this->filters[filter] {
// If the filter is a closure we call it in the PHP userland
if custom instanceof \Closure {
return call_user_func_array(custom, [value]);
@@ -78,11 +78,11 @@ class Filter
switch filter {
case "cssmin":
let custom = create_instance("Ice\\Filter\\Css"),
- this->_filters["cssmin"] = custom;
+ this->filters["cssmin"] = custom;
return custom->sanitize(value);
case "jsmin":
let custom = create_instance("Ice\\Filter\\Js"),
- this->_filters["jsmin"] = custom;
+ this->filters["jsmin"] = custom;
return custom->sanitize(value);
case "camelize":
@@ -104,9 +104,9 @@ class Filter
case "email":
return filter_var(value, FILTER_SANITIZE_EMAIL);
case "float":
- return filter_var(value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
+ return (double) filter_var(value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
case "int":
- return filter_var(value, FILTER_SANITIZE_NUMBER_INT);
+ return (int) filter_var(value, FILTER_SANITIZE_NUMBER_INT);
case "string":
return filter_var(value, FILTER_SANITIZE_STRING);
diff --git a/ice/filter/js.zep b/ice/filter/js.zep
index 46f120ff..eb1e32ec 100644
--- a/ice/filter/js.zep
+++ b/ice/filter/js.zep
@@ -1,6 +1,8 @@
namespace Ice\Filter;
+use Ice\Exception;
+
/**
* Minify js string.
*
@@ -14,6 +16,19 @@ namespace Ice\Filter;
class Js
{
+ const ORD_LF = 10;
+ const ORD_SPACE = 32;
+ const ACTION_KEEP_A = 1;
+ const ACTION_DELETE_A = 2;
+ const ACTION_DELETE_A_B = 3;
+ protected a = "";
+ protected b = "";
+ protected input = "";
+ protected inputIndex = 0;
+ protected inputLength = 0;
+ protected lookAhead = null;
+ protected output = "" { get };
+
/**
* Minify the js.
*
@@ -22,16 +37,296 @@ class Js
*/
public function sanitize(string js)
{
- string min = "";
- char c;
- int i;
- char next;
-
- for i, c in js {
- let next = js[i],
- min .= c;
+ let this->a = "",
+ this->b = "",
+ this->input = str_replace("\r\n", "\n", js),
+ this->inputLength = strlen(this->input),
+ this->inputIndex = 0,
+ this->lookAhead = null,
+ this->output = "";
+
+ return this->min();
+ }
+
+ /**
+ * Action -- do something! What to do is determined by the $command argument.
+ *
+ * action treats a string as a single character. Wow!
+ * action recognizes a regular expression if it is preceded by ( or , or =.
+ *
+ * @throws Exception If parser errors are found:
+ * - Unterminated string literal
+ * - Unterminated regular expression set in regex literal
+ * - Unterminated regular expression literal
+ *
+ * @param int $command One of class constants:
+ * ACTION_KEEP_A Output A. Copy B to A. Get the next B.
+ * ACTION_DELETE_A Copy B to A. Get the next B. (Delete A).
+ * ACTION_DELETE_A_B Get the next B. (Delete B).
+ */
+ protected function action(int command)
+ {
+ //switch command {
+ //case self::ACTION_KEEP_A: //1
+ if command == self::ACTION_KEEP_A {
+ let this->output = this->output . this->a;
+ }
+
+ //case self::ACTION_DELETE_A: //1, 2
+ if command == self::ACTION_KEEP_A || command == self::ACTION_DELETE_A {
+ let this->a = this->b;
+
+ if this->a === "'" || this->a === "\"" {
+ while 1 {
+ let this->output = this->output . this->a,
+ this->a = this->get();
+
+ if this->a === this->b {
+ break;
+ }
+
+ if ord(this->a) <= self::ORD_LF {
+ throw new Exception("Unterminated string literal.");
+ }
+
+ if this->a === "\\" {
+ let this->output = this->output . this->a,
+ this->a = this->get();
+ }
+ }
+ }
+ }
+
+ //case self::ACTION_DELETE_A_B: //1, 2, 3
+ if command == self::ACTION_KEEP_A || command == self::ACTION_DELETE_A || command == self::ACTION_DELETE_A_B {
+ let this->b = this->next();
+
+ if this->b === "/" && (
+ this->a === "(" || this->a === "," || this->a === "=" ||
+ this->a === ":" || this->a === "[" || this->a === "!" ||
+ this->a === "&" || this->a === "|" || this->a === "?" ||
+ this->a === "{" || this->a === "}" || this->a === ";" ||
+ this->a === "\n" ) {
+ let this->output = this->output . this->a . this->b;
+
+ while 1 {
+ let this->a = this->get();
+ if this->a === "[" {
+ /*
+ inside a regex [...] set, which MAY contain a "/" itself. Example: mootools Form.Validator near line 460:
+ return Form.Validator.getValidator("IsEmpty").test(element) || (/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]\.?){0,63}[a-z0-9!#$%&'*+/=?^_`{|}~-]@(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\])$/i).test(element.get("value"));
+ */
+ while 1 {
+ let this->output = this->output . this->a,
+ this->a = this->get();
+
+ if this->a === "]" {
+ break;
+ } elseif this->a === "\\" {
+ let this->output = this->output . this->a,
+ this->a = this->get();
+ } elseif ord(this->a) <= self::ORD_LF {
+ throw new Exception("Unterminated regular expression set in regex literal.");
+ }
+ }
+ } elseif this->a === "/" {
+ break;
+ } elseif this->a === "\\" {
+ let this->output = this->output . this->a,
+ this->a = this->get();
+ } elseif ord(this->a) <= self::ORD_LF {
+ throw new Exception("Unterminated regular expression literal.");
+ }
+
+ let this->output = this->output . this->a;
+ }
+
+ let this->b = this->next();
+ }
+ }
+ //}
+ }
+
+ /**
+ * Get next char. Convert ctrl char to space.
+ *
+ * @return string|null
+ */
+ protected function get()
+ {
+ var c, i;
+
+ let c = this->lookAhead,
+ this->lookAhead = null;
+
+ if c === null {
+ if this->inputIndex < this->inputLength {
+ let c = substr(this->input, this->inputIndex, 1),
+ i = this->inputIndex,
+ this->inputIndex = i + 1;
+ } else {
+ let c = null;
+ }
+ }
+
+ if c === "\r" {
+ return "\n";
+ }
+
+ if c === null || c === "\n" || ord(c) >= self::ORD_SPACE {
+ return c;
+ }
+
+ return " ";
+ }
+
+ /**
+ * Is $c a letter, digit, underscore, dollar sign, or non-ASCII character.
+ *
+ * @return bool
+ */
+ protected function isAlphaNum(c)
+ {
+ return ord(c) > 126 || c === "\\" || preg_match("/^[\\w\\$]$/", c) === 1;
+ }
+
+ /**
+ * Perform minification, return result
+ *
+ * @return string
+ */
+ protected function min()
+ {
+ if 0 == strncmp(this->peek(), "\xef", 1) {
+ this->get();
+ this->get();
+ this->get();
}
+
+ let this->a = "\n";
+ this->action(self::ACTION_DELETE_A_B);
+
+ while this->a !== null {
+ switch this->a {
+ case " ":
+ if this->isAlphaNum(this->b) {
+ this->action(self::ACTION_KEEP_A);
+ } else {
+ this->action(self::ACTION_DELETE_A);
+ }
+ break;
+ case "\n":
+ switch this->b {
+ case "{":
+ case "[":
+ case "(":
+ case "+":
+ case "-":
+ case "!":
+ case "~":
+ this->action(self::ACTION_KEEP_A);
+ break;
+ case " ":
+ this->action(self::ACTION_DELETE_A_B);
+ break;
+ default:
+ if this->isAlphaNum(this->b) {
+ this->action(self::ACTION_KEEP_A);
+ } else {
+ this->action(self::ACTION_DELETE_A);
+ }
+ }
+ break;
+ default:
+ switch this->b {
+ case " ":
+ if this->isAlphaNum(this->a) {
+ this->action(self::ACTION_KEEP_A);
+ break;
+ }
+ this->action(self::ACTION_DELETE_A_B);
+ break;
+ case "\n":
+ switch this->a {
+ case "}":
+ case "]":
+ case ")":
+ case "+":
+ case "-":
+ case "\"":
+ case "'":
+ this->action(self::ACTION_KEEP_A);
+ break;
+ default:
+ if this->isAlphaNum(this->a) {
+ this->action(self::ACTION_KEEP_A);
+ } else {
+ this->action(self::ACTION_DELETE_A_B);
+ }
+ }
+ break;
+ default:
+ this->action(self::ACTION_KEEP_A);
+ break;
+ }
+ }
+ }
- return min;
+ return this->output;
+ }
+
+ /**
+ * Get the next character, skipping over comments. peek() is used to see
+ * if a "/" is followed by a "/" or "*".
+ *
+ * @throws Exception On unterminated comment.
+ * @return string
+ */
+ protected function next()
+ {
+ var c;
+
+ let c = this->get();
+
+ if c === "/" {
+ switch this->peek() {
+ case "/":
+ while 1 {
+ let c = this->get();
+ if ord(c) <= self::ORD_LF {
+ return c;
+ }
+ }
+ case "*":
+ this->get();
+
+ while 1 {
+ switch this->get() {
+ case "*":
+ if this->peek() === "/" {
+ this->get();
+ return " ";
+ }
+ break;
+ case null:
+ throw new Exception("Unterminated comment.");
+ }
+ }
+ default:
+ return c;
+ }
+ }
+ return c;
+ }
+
+ /**
+ * Get next char. If is ctrl character, translate to a space or newline.
+ *
+ * @return string|null
+ */
+ protected function peek()
+ {
+ let this->lookAhead = this->get();
+ return this->lookAhead;
}
}
diff --git a/ice/flash.zep b/ice/flash.zep
index 6e79adb2..1219840a 100644
--- a/ice/flash.zep
+++ b/ice/flash.zep
@@ -13,9 +13,9 @@ namespace Ice;
class Flash
{
- protected _session;
- protected _tag;
- protected _options = [
+ protected session;
+ protected tag;
+ protected options = [
"session_key": "_flash",
"success": ["class": "alert alert-success"],
"info": ["class": "alert alert-info"],
@@ -34,11 +34,11 @@ class Flash
var di;
let di = Di::$fetch(),
- this->_session = di->{"getSession"}(),
- this->_tag = di->{"getTag"}();
+ this->session = di->get("session", null, true),
+ this->tag = di->get("tag", null, true);
if count(options) {
- let this->_options = options;
+ let this->options = options;
}
}
@@ -53,7 +53,7 @@ class Flash
{
var value;
- if fetch value, this->_options[key] {
+ if fetch value, this->options[key] {
return value;
}
return defaultValue;
@@ -70,7 +70,7 @@ class Flash
var key, type, message, messages, body;
let key = this->getOption("session_key"),
- messages = this->_session->get(key),
+ messages = this->session->get(key),
body = "";
if typeof messages == "array" {
@@ -80,7 +80,7 @@ class Flash
}
if remove {
- this->_session->remove(key);
+ this->session->remove(key);
}
return body;
@@ -98,7 +98,7 @@ class Flash
var params, body, close, message;
let params = this->getOption(type, []),
- close = this->_tag->a(["#", "×", "class": "close"]),
+ close = this->tag->a(["#", "×", "class": "close"]),
body = "";
if typeof messages != "array" {
@@ -107,7 +107,7 @@ class Flash
for message in messages {
if this->getOption("html") {
- let body .= this->_tag->tagHtml("div", params, ["content": close . message], ["content"], "content", true, true);
+ let body .= this->tag->tagHtml("div", params, ["content": close . message], ["content"], "content", true, true);
} else {
let body .= message . PHP_EOL;
}
@@ -128,7 +128,7 @@ class Flash
var key, messages;
let key = this->getOption("session_key"),
- messages = this->_session->get(key, []);
+ messages = this->session->get(key, []);
if !isset messages[type] {
let messages[type] = [];
@@ -136,7 +136,7 @@ class Flash
let messages[type][] = message;
- this->_session->set(key, messages);
+ this->session->set(key, messages);
}
/**
diff --git a/ice/http/request.zep b/ice/http/request.zep
index ebb589f9..9272f22f 100644
--- a/ice/http/request.zep
+++ b/ice/http/request.zep
@@ -16,20 +16,20 @@ use Ice\Di;
class Request extends Arr
{
- protected _files;
- protected _get;
- protected _post;
- protected _server;
+ protected files;
+ protected get;
+ protected post;
+ protected server;
/**
* Request constructor. Fetch data from globals variables: _REQUEST, _SERVER, _POST, _GET and _FILES.
*/
public function __construct()
{
- let this->_files = new Arr(_FILES),
- this->_get = new Arr(_GET),
- this->_post = new Arr(_POST),
- this->_server = new Arr(_SERVER);
+ let this->files = new Arr(_FILES),
+ this->get = new Arr(_GET),
+ this->post = new Arr(_POST),
+ this->server = new Arr(_SERVER);
parent::__construct(_REQUEST);
}
@@ -53,7 +53,7 @@ class Request extends Arr
*/
public function hasPost(string! name) -> boolean
{
- return this->_post->has(name);
+ return this->post->has(name);
}
/**
@@ -64,7 +64,7 @@ class Request extends Arr
*/
public function hasGet(string! name) -> boolean
{
- return this->_get->has(name);
+ return this->get->has(name);
}
/**
@@ -75,7 +75,7 @@ class Request extends Arr
*/
public function hasServer(string! name) -> boolean
{
- return this->_server->has(name);
+ return this->server->has(name);
}
/**
@@ -86,7 +86,7 @@ class Request extends Arr
*/
public function hasFile(string! name) -> boolean
{
- return this->_files->has(name);
+ return this->files->has(name);
}
/**
@@ -166,7 +166,7 @@ class Request extends Arr
*/
public function isAjax() -> boolean
{
- return this->_server->get("HTTP_X_REQUESTED_WITH") == "XMLHttpRequest";
+ return this->server->get("HTTP_X_REQUESTED_WITH") == "XMLHttpRequest";
}
/**
@@ -176,7 +176,7 @@ class Request extends Arr
*/
public function getMethod() -> string
{
- return this->_server->get("REQUEST_METHOD", "");
+ return this->server->get("REQUEST_METHOD", "");
}
/**
@@ -186,7 +186,7 @@ class Request extends Arr
*/
public function getUserAgent() -> string
{
- return this->_server->get("HTTP_USER_AGENT", "");
+ return this->server->get("HTTP_USER_AGENT", "");
}
/**
@@ -196,7 +196,7 @@ class Request extends Arr
*/
public function getHTTPReferer() -> string
{
- return this->_server->get("HTTP_REFERER", "");
+ return this->server->get("HTTP_REFERER", "");
}
/**
@@ -208,9 +208,9 @@ class Request extends Arr
{
var client, forward, remote, ip;
- let client = this->_server->get("HTTP_CLIENT_IP"),
- forward = this->_server->get("HTTP_X_FORWARDED_FOR"),
- remote = this->_server->get("REMOTE_ADDR");
+ let client = this->server->get("HTTP_CLIENT_IP"),
+ forward = this->server->get("HTTP_X_FORWARDED_FOR"),
+ remote = this->server->get("REMOTE_ADDR");
if filter_var(client, FILTER_VALIDATE_IP) {
let ip = client;
@@ -250,15 +250,15 @@ class Request extends Arr
if !key {
// Remove `_url` from GET
- this->_get->set("_url", null);
- this->_get->remove("_url");
+ this->get->set("_url", null);
+ this->get->remove("_url");
- return this->_get;
+ return this->get;
} else {
- let value = this->_get->get(key, defaultValue);
+ let value = this->get->get(key, defaultValue);
if filters {
- let filter = Di::$fetch()->{"getFilter"}(),
+ let filter = Di::$fetch()->get("filter", null, true),
value = filter->sanitize(value, filters);
}
@@ -296,12 +296,12 @@ class Request extends Arr
var value, filter;
if !key {
- return this->_post;
+ return this->post;
} else {
- let value = this->_post->get(key, defaultValue);
+ let value = this->post->get(key, defaultValue);
if filters {
- let filter = Di::$fetch()->{"getFilter"}(),
+ let filter = Di::$fetch()->get("filter", null, true),
value = filter->sanitize(value, filters);
}
@@ -322,7 +322,7 @@ class Request extends Arr
*/
public function getServer(string key = null, var defaultValue = null)
{
- return key ? this->_server->get(key, defaultValue) : this->_server;
+ return key ? this->server->get(key, defaultValue) : this->server;
}
/**
@@ -334,6 +334,6 @@ class Request extends Arr
*/
public function getFiles(string key = null, var defaultValue = null)
{
- return key ? this->_files->get(key, defaultValue) : this->_files;
+ return key ? this->files->get(key, defaultValue) : this->files;
}
}
diff --git a/ice/http/response.zep b/ice/http/response.zep
index f9365902..e06effef 100644
--- a/ice/http/response.zep
+++ b/ice/http/response.zep
@@ -19,12 +19,12 @@ use Ice\Http\Response\ResponseInterface;
class Response implements ResponseInterface
{
- protected _di;
- protected _protocolVersion = "HTTP/1.1" { get, set };
- protected _status = 200 { get, set };
- protected _headers;
- protected _body { get, set };
- protected _messages = [
+ protected di;
+ protected protocolVersion = "HTTP/1.1" { get, set };
+ protected status = 200 { get, set };
+ protected headers;
+ protected body { get, set };
+ protected messages = [
//Informational 1xx
100: "Continue",
101: "Switching Protocols",
@@ -100,13 +100,13 @@ class Response implements ResponseInterface
*/
public function __construct(string body = "", int status = 200)
{
- let this->_di = Di::$fetch();
+ let this->di = Di::$fetch();
- let this->_headers = new Headers(),
- this->_status = status,
- this->_body = body;
+ let this->headers = new Headers(),
+ this->status = status,
+ this->body = body;
- this->_headers->set("Content-Type", "text/html");
+ this->headers->set("Content-Type", "text/html");
}
/**
@@ -116,7 +116,7 @@ class Response implements ResponseInterface
*/
public function getHeaders() -> array
{
- return this->_headers->all();
+ return this->headers->all();
}
/**
@@ -127,7 +127,7 @@ class Response implements ResponseInterface
*/
public function hasHeader(string name) -> boolean
{
- return this->_headers->has(name);
+ return this->headers->has(name);
}
/**
@@ -138,7 +138,7 @@ class Response implements ResponseInterface
*/
public function getHeader(string name) -> string
{
- return this->_headers->get(name);
+ return this->headers->get(name);
}
/**
@@ -149,7 +149,7 @@ class Response implements ResponseInterface
*/
public function setHeader(string name, string value) -> void
{
- this->_headers->set(name, value);
+ this->headers->set(name, value);
}
/**
@@ -159,7 +159,7 @@ class Response implements ResponseInterface
*/
public function setHeaders(array headers) -> void
{
- this->_headers->replace(headers);
+ this->headers->replace(headers);
}
/**
@@ -169,7 +169,20 @@ class Response implements ResponseInterface
*/
public function removeHeader(string name) -> void
{
- this->_headers->remove(name);
+ this->headers->remove(name);
+ }
+
+ /**
+ * Set body content.
+ *
+ * @param string content
+ * @return object Response
+ */
+ public function setContent(string contet) -> object
+ {
+ let this->body = contet;
+
+ return this;
}
/**
@@ -185,9 +198,9 @@ class Response implements ResponseInterface
let sendBody = true;
- if in_array(this->_status, [204, 304]) {
- this->_headers->remove("Content-Type");
- this->_headers->remove("Content-Length");
+ if in_array(this->status, [204, 304]) {
+ this->headers->remove("Content-Type");
+ this->headers->remove("Content-Length");
let sendBody = false;
}
@@ -198,7 +211,7 @@ class Response implements ResponseInterface
// Truncate body if it should not be sent with response
if !sendBody {
- let this->_body = "";
+ let this->body = "";
}
return this;
@@ -213,12 +226,12 @@ class Response implements ResponseInterface
{
if !headers_sent() {
if strpos(PHP_SAPI, "cgi") === 0 {
- header(sprintf("Status: %d %s", this->_status, this->_messages[this->_status]));
+ header(sprintf("Status: %d %s", this->status, this->messages[this->status]));
} else {
- header(sprintf("%s %d %s", this->getProtocolVersion(), this->_status, this->_messages[this->_status]));
+ header(sprintf("%s %d %s", this->getProtocolVersion(), this->status, this->messages[this->status]));
}
- this->_headers->send();
+ this->headers->send();
}
return this;
@@ -230,6 +243,7 @@ class Response implements ResponseInterface
*
* @param string location The redirect destination
* @param int status The redirect HTTP status code
+ * @return object this
*/
public function redirect(string location = null, int status = 302, boolean external = false)
{
@@ -238,10 +252,12 @@ class Response implements ResponseInterface
this->setStatus(status);
if !external {
- let url = this->_di->{"getUrl"}(),
+ let url = this->di->get("url", null, true),
location = url->get(location);
}
- this->_headers->set("Location", location);
+ this->headers->set("Location", location);
+
+ return this;
}
/**
@@ -251,7 +267,7 @@ class Response implements ResponseInterface
*/
public function isEmpty() -> boolean
{
- return in_array(this->_status, [201, 204, 304]);
+ return in_array(this->status, [201, 204, 304]);
}
/**
@@ -261,7 +277,7 @@ class Response implements ResponseInterface
*/
public function isInformational() -> boolean
{
- return this->_status >= 100 && this->_status < 200;
+ return this->status >= 100 && this->status < 200;
}
/**
@@ -271,7 +287,7 @@ class Response implements ResponseInterface
*/
public function isOk() -> boolean
{
- return this->_status === 200;
+ return this->status === 200;
}
/**
@@ -281,7 +297,7 @@ class Response implements ResponseInterface
*/
public function isSuccessful() -> boolean
{
- return this->_status >= 200 && this->_status < 300;
+ return this->status >= 200 && this->status < 300;
}
/**
@@ -291,7 +307,7 @@ class Response implements ResponseInterface
*/
public function isRedirect() -> boolean
{
- return in_array(this->_status, [301, 302, 303, 307]);
+ return in_array(this->status, [301, 302, 303, 307]);
}
/**
@@ -301,7 +317,7 @@ class Response implements ResponseInterface
*/
public function isRedirection() -> boolean
{
- return this->_status >= 300 && this->_status < 400;
+ return this->status >= 300 && this->status < 400;
}
/**
@@ -311,7 +327,7 @@ class Response implements ResponseInterface
*/
public function isForbidden() -> boolean
{
- return this->_status === 403;
+ return this->status === 403;
}
/**
@@ -321,7 +337,7 @@ class Response implements ResponseInterface
*/
public function isNotFound() -> boolean
{
- return this->_status === 404;
+ return this->status === 404;
}
/**
@@ -331,7 +347,7 @@ class Response implements ResponseInterface
*/
public function isClientError() -> boolean
{
- return this->_status >= 400 && this->_status < 500;
+ return this->status >= 400 && this->status < 500;
}
/**
@@ -341,7 +357,7 @@ class Response implements ResponseInterface
*/
public function isServerError() -> boolean
{
- return this->_status >= 500 && this->_status < 600;
+ return this->status >= 500 && this->status < 600;
}
/**
@@ -354,7 +370,7 @@ class Response implements ResponseInterface
{
var message;
- fetch message, this->_messages[code];
+ fetch message, this->messages[code];
return message ? message : "";
}
@@ -366,6 +382,6 @@ class Response implements ResponseInterface
*/
public function __toString() -> string
{
- return this->_body;
+ return this->body;
}
}
diff --git a/ice/i18n.zep b/ice/i18n.zep
index 10ca8305..ce95f3a9 100644
--- a/ice/i18n.zep
+++ b/ice/i18n.zep
@@ -1,7 +1,16 @@
-// function _(string! str, array values = null, var context = null, string lang = null)
-// {
-// return I18n::$fetch()->translate(str, values, context, lang);
-// }
+/**
+ * Global alias of translate method.
+ */
+function _t(string! str, array values = null, var context = null, string lang = null)
+{
+ var i18n;
+
+ let i18n = I18n::$fetch();
+
+ if i18n {
+ return i18n->translate(str, values, context, lang);
+ }
+}
namespace Ice;
@@ -19,10 +28,10 @@ use Ice\I18n\Plural;
class I18n
{
- protected static _i18n;
- protected _cache = [];
- protected _rules = [];
- protected _options = [
+ protected static i18n;
+ protected cache = [];
+ protected rules = [];
+ protected options = [
"source": "en-gb",
"lang": "en-gb",
"dir": ""
@@ -35,8 +44,8 @@ class I18n
*/
public function __construct(array options = [])
{
- let this->_options = array_merge(this->_options, options),
- self::_i18n = this;
+ let this->options = array_merge(this->options, options),
+ self::i18n = this;
}
/**
@@ -46,7 +55,7 @@ class I18n
*/
public static function $fetch()
{
- return self::_i18n;
+ return self::i18n;
}
/**
@@ -59,10 +68,10 @@ class I18n
{
// Normalize the language
if lang {
- let this->_options["lang"] = strtolower(str_replace("_", "-", lang));
+ let this->options["lang"] = strtolower(str_replace("_", "-", lang));
}
- return this->_options["lang"];
+ return this->options["lang"];
}
/**
@@ -77,7 +86,7 @@ class I18n
var parts;
if !lang {
- let lang = this->_options["lang"];
+ let lang = this->options["lang"];
}
let parts = explode("-", strtolower(str_replace("_", "-", lang)));
@@ -104,7 +113,7 @@ class I18n
if !lang {
// Use the global target language
- let lang = (string) this->_options["lang"];
+ let lang = (string) this->options["lang"];
}
// Load the translation messages for this language
@@ -144,7 +153,7 @@ class I18n
var cache, parts, subdir, tail, tmp, found, path, messages;
// Load from the cache
- if fetch cache, this->_cache[lang] {
+ if fetch cache, this->cache[lang] {
return cache;
}
@@ -160,7 +169,7 @@ class I18n
}
for found in tail {
- let path = (string) this->_options["dir"] . found . ".php";
+ let path = (string) this->options["dir"] . found . ".php";
if file_exists(path) {
let messages = require path;
@@ -170,9 +179,9 @@ class I18n
}
}
- let this->_cache[lang] = messages;
+ let this->cache[lang] = messages;
- return this->_cache[lang];
+ return this->cache[lang];
}
/**
@@ -190,10 +199,10 @@ class I18n
let code = this->iso(lang);
- if !fetch rules, this->_rules[code] {
+ if !fetch rules, this->rules[code] {
// Get language code prefix
- let this->_rules[code] = this->pluralRules(code),
- rules = this->_rules[code];
+ let this->rules[code] = this->pluralRules(code),
+ rules = this->rules[code];
}
@@ -265,7 +274,7 @@ class I18n
public function translate(string! str, array values = null, var context = null, string lang = null) -> string
{
if !lang {
- let lang = (string) this->_options["lang"];
+ let lang = (string) this->options["lang"];
}
if is_numeric(context) {
diff --git a/ice/loader.zep b/ice/loader.zep
index 0f29087b..57a0d301 100644
--- a/ice/loader.zep
+++ b/ice/loader.zep
@@ -13,7 +13,7 @@ namespace Ice;
class Loader
{
- protected _prefixes = [];
+ protected prefixes = [];
/**
* Register loader with SPL autoloader stack.
@@ -44,15 +44,15 @@ class Loader
baseDir = rtrim(baseDir, DIRECTORY_SEPARATOR) . "/";
// initialize the namespace prefix array
- if !isset this->_prefixes[prefix] {
- let this->_prefixes[prefix] = [];
+ if !isset this->prefixes[prefix] {
+ let this->prefixes[prefix] = [];
}
// retain the base directory for the namespace prefix
if prepend {
- array_unshift(this->_prefixes[prefix], utf8_encode(baseDir));
+ array_unshift(this->prefixes[prefix], utf8_encode(baseDir));
} else {
- array_push(this->_prefixes[prefix], utf8_encode(baseDir));
+ array_push(this->prefixes[prefix], utf8_encode(baseDir));
}
return this;
}
@@ -108,12 +108,12 @@ class Loader
var baseDir, file;
// are there any base directories for this namespace prefix?
- if !isset this->_prefixes[prefix] {
+ if !isset this->prefixes[prefix] {
return false;
}
// look through base directories for this namespace prefix
- for baseDir in this->_prefixes[prefix] {
+ for baseDir in this->prefixes[prefix] {
// replace the namespace prefix with the base directory,
// replace namespace separators with directory separators
// in the relative class name, append with .php
diff --git a/ice/log/driver/file.zep b/ice/log/driver/file.zep
index fac8d102..0eaad581 100644
--- a/ice/log/driver/file.zep
+++ b/ice/log/driver/file.zep
@@ -16,7 +16,7 @@ use Ice\Exception;
class File extends Driver
{
- protected _file;
+ protected file;
/**
* Logger file constructor.
@@ -35,7 +35,7 @@ class File extends Driver
throw new Exception("Log file " . file . " is not writeable");
}
- let this->_file = file;
+ let this->file = file;
}
/**
@@ -52,7 +52,7 @@ class File extends Driver
let line = "[" . date("Y-m-d H:i:s") . "] " . strtoupper(level) . ": " . this->interpolate(message, context) . PHP_EOL;
- file_put_contents(this->_file, line, FILE_APPEND);
+ file_put_contents(this->file, line, FILE_APPEND);
}
/**
diff --git a/ice/mvc/app.zep b/ice/mvc/app.zep
index 308e75c8..1d4651b4 100644
--- a/ice/mvc/app.zep
+++ b/ice/mvc/app.zep
@@ -1,6 +1,7 @@
namespace Ice\Mvc;
+use Ice\Di;
use Ice\Di\Access;
use Ice\Http\Response\ResponseInterface;
@@ -16,8 +17,22 @@ use Ice\Http\Response\ResponseInterface;
class App extends Access
{
- protected _autoRender = true { get, set };
- protected _modules { get, set };
+ protected autoRender = true { get, set };
+ protected modules { get, set };
+
+ /**
+ * App constructor
+ *
+ * @param Di $di
+ */
+ public function __construct( di = null)
+ {
+ // Set the dependency injector
+ parent::__construct(di);
+
+ // Register the app itself as a service
+ this->di->set("app", this);
+ }
/**
* Handles a MVC request.
@@ -28,9 +43,9 @@ class App extends Access
*/
public function handle(method = null, uri = null) -> | boolean
{
- var argv, router, request, response, dispatcher, controller, view;
+ var argv, router, request, response, dispatcher, returned, controller, view;
- let request = this->_di->{"getRequest"}();
+ let request = this->di->get("request", null, true);
if method == null {
let method = request->getMethod();
}
@@ -49,49 +64,54 @@ class App extends Access
}
}
- let router = this->_di->{"getRouter"}(),
+ let router = this->di->get("router", null, true),
response = router->handle(method, uri),
- dispatcher = this->_di->{"getDispatcher"}();
+ dispatcher = this->di->get("dispatcher", null, true);
- this->_di->applyHook("app.after.router.handle", [response]);
+ this->di->applyHook("app.after.router.handle", [response]);
if !(typeof response == "object" && (response instanceof ResponseInterface)) {
- dispatcher->setModules(this->_modules);
+ dispatcher->setModules(this->modules);
dispatcher->setMethod(method);
dispatcher->setModule(response["module"]);
dispatcher->setHandler(response["handler"]);
dispatcher->setAction(response["action"]);
dispatcher->setParams(response["params"]);
- let response = dispatcher->dispatch();
+ let response = dispatcher->dispatch(),
+ returned = dispatcher->getReturnedValue();
- this->_di->applyHook("app.after.dispatcher.dispatch", [response]);
+ if typeof returned == "object" && (returned instanceof ResponseInterface) {
+ let response = returned;
+ }
- if !(typeof response == "object" && (response instanceof ResponseInterface)) {
+ this->di->applyHook("app.after.dispatcher.dispatch", [response]);
+ if !(typeof response == "object" && (response instanceof ResponseInterface)) {
let controller = response,
- response = this->_di->{"getResponse"}(),
+ response = this->di->get("response", null, true),
view = controller->view;
- if view->getContent() === null {
- if !view->getFile() {
- view->setSilent(true);
- view->setFile(dispatcher->getHandler() . "/" . dispatcher->getAction());
+ // Load views and set the response body if auto render
+ if this->autoRender {
+ if view->getContent() === null {
+ if !view->getFile() {
+ view->setSilent(true);
+ view->setFile(dispatcher->getHandler() . "/" . dispatcher->getAction());
+ }
+ if !view->count() {
+ view->replace(dispatcher->getParams());
+ }
+
+ view->setContent(view->render());
}
- if !view->count() {
- view->replace(dispatcher->getParams());
- }
-
- view->setContent(view->render());
- }
- if this->_autoRender {
response->setBody(view->layout(view->getMainView()));
}
}
}
- this->_di->applyHook("app.after.handle", [response]);
+ this->di->applyHook("app.after.handle", [response]);
return response->send();
}
diff --git a/ice/mvc/dispatcher.zep b/ice/mvc/dispatcher.zep
index b3f3eed3..28cf9fb9 100644
--- a/ice/mvc/dispatcher.zep
+++ b/ice/mvc/dispatcher.zep
@@ -17,8 +17,8 @@ use Ice\Mvc\Route\Collector;
class Dispatcher extends \Ice\Dispatcher
{
- protected _method { get, set };
- protected _handlerSuffix = "Controller";
+ protected method { get, set };
+ protected handlerSuffix = "Controller";
/**
* Get active method, first check whether a method with the HTTP method as prefix exist.
@@ -29,8 +29,8 @@ class Dispatcher extends \Ice\Dispatcher
{
var action;
- let action = strtolower(this->_method) . ucfirst(this->_action) . this->_actionSuffix;
- if method_exists(this->_activeHandler, action) {
+ let action = strtolower(this->method) . ucfirst(this->action) . this->actionSuffix;
+ if method_exists(this->activeHandler, action) {
return action;
}
diff --git a/ice/mvc/model.zep b/ice/mvc/model.zep
index 1b6f35e2..d6fdfbd5 100644
--- a/ice/mvc/model.zep
+++ b/ice/mvc/model.zep
@@ -19,17 +19,17 @@ use Ice\Validation;
abstract class Model extends Arr implements \Serializable
{
- protected _di { get };
- protected _db { get };
- protected _from { set };
- protected _primary { set, get };
- protected _filters = [] { set, get };
- protected _fields = [] { set, get };
- protected _validation { set, get };
- protected _relations = [] { get };
- protected _labels = [] { set };
- protected _rules = [];
- protected _messages = [] { get };
+ protected di { get };
+ protected db { get };
+ protected from { set };
+ protected primary { set, get };
+ protected filters = [] { set, get };
+ protected fields = [] { set, get };
+ protected validation { set, get };
+ protected relations = [] { get };
+ protected labels = [] { set };
+ protected rules = [];
+ protected messages = [] { get, set };
const BELONGS_TO = 1;
const HAS_ONE = 2;
@@ -46,19 +46,19 @@ abstract class Model extends Arr implements \Serializable
var di;
let di = Di::$fetch(),
- this->_di = di,
- this->_db = di->{"getDb"}();
+ this->di = di,
+ this->db = di->get("db", null, true);
- let data = array_merge(array_fill_keys(this->_fields, null), data);
+ let data = array_merge(array_fill_keys(this->fields, null), data);
parent::__construct(data);
- if !this->_from {
- let this->_from = uncamelize(get_class_ns(this));
+ if !this->from {
+ let this->from = uncamelize(get_class_ns(this));
}
- if !this->_primary {
- let this->_primary = this->_db->getId();
+ if !this->primary {
+ let this->primary = this->db->getId();
}
if method_exists(this, "onConstruct") {
@@ -66,7 +66,9 @@ abstract class Model extends Arr implements \Serializable
}
if filters {
- this->loadOne(filters);
+ if !this->loadOne(filters) {
+ throw new Exception("Not Found");
+ }
}
if method_exists(this, "initialize") {
@@ -74,16 +76,38 @@ abstract class Model extends Arr implements \Serializable
}
}
+ /**
+ * Get the id.
+ *
+ * @return mixed
+ */
+ public function getId()
+ {
+ return this->get(this->getIdKey());
+ }
+
+ /**
+ * Get the id key depending on db driver.
+ *
+ * @return string
+ */
+ public function getIdKey() -> string
+ {
+ return this->db->getId();
+ }
+
/**
* Load one result to the current object.
*
* @param mixed filters
+ * @param array options
+ * @return this|false
*/
- public function loadOne(var filters)
+ public function loadOne(var filters, array options = [])
{
var result;
- let result = this->_db->findOne(this->_from, filters);
+ let result = this->db->findOne(this->from, filters, options);
if result {
this->replace(result->all());
@@ -97,13 +121,14 @@ abstract class Model extends Arr implements \Serializable
* Load results to the current object.
*
* @param mixed filters
- * @return Arr
+ * @param array options
+ * @return object Arr
*/
public function load(var filters, array options = [])
{
var result, instances, data;
- let result = this->_db->find(this->_from, filters, options),
+ let result = this->db->find(this->from, filters, options),
instances = [];
if result->count() {
@@ -127,20 +152,18 @@ abstract class Model extends Arr implements \Serializable
*
*
* @param array filters
- * @return Model|false
+ * @param array options
+ * @return this|false
*/
- public static function findOne(var filters = null)
+ public static function findOne(var filters = null, array options = [])
{
- var result, model;
+ var result, model, instance;
let model = get_called_class(),
- result = create_instance_params(model, [filters]);
+ instance = create_instance(model),
+ result = instance->loadOne(filters, options);
- if !result->count() {
- return false;
- } else {
- return result;
- }
+ return result;
}
/**
@@ -152,7 +175,8 @@ abstract class Model extends Arr implements \Serializable
*
*
* @param array filters
- * @return Arr
+ * @param array options
+ * @return object Arr
*/
public static function find(var filters = null, array options = [])
{
@@ -168,13 +192,14 @@ abstract class Model extends Arr implements \Serializable
/**
* Prepare fields for validation on create/update.
*
- * @param mixed fields
+ * @param mixed fields Fields to save or valid fields
+ * @param booleat primary Keept primary keys
* @return array
*/
- protected function fields(var fields = [])
+ protected function fields(var fields = [], boolean primary = true)
{
// Check if model has defined valid fields
- if !count(this->_fields) {
+ if !count(this->fields) {
// No defined model's fields
// Check if fields param has any elements
if !count(fields) {
@@ -196,22 +221,23 @@ abstract class Model extends Arr implements \Serializable
// Check if fields param has any elements
if !count(fields) {
// Get all valid model's data as fields
- let fields = array_intersect_key(this->all(), array_flip(this->_fields));
+ let fields = array_intersect_key(this->all(), array_flip(this->fields));
} else {
// Get only fields from method parameter
// Check if fields param is associative or sequential
if count(array_filter(array_keys(fields), "is_string")) {
// Merge model data with fields values, get only valid model's fields
- let fields = array_intersect_key(array_merge(this->all(), fields), array_flip(this->_fields));
+ let fields = array_intersect_key(array_merge(this->all(), fields), array_flip(this->fields));
} else {
// Use fields as only valid keys, get only valid model's fields
- let fields = array_intersect_key(this->all(), array_flip(fields), array_flip(this->_fields));
+ let fields = array_intersect_key(this->all(), array_flip(fields), array_flip(this->fields));
}
}
}
- if typeof this->_primary == "string" {
- unset fields[this->_primary];
+ // Remove primary keys
+ if typeof this->primary == "string" && !primary {
+ unset fields[this->primary];
}
return fields;
@@ -233,50 +259,52 @@ abstract class Model extends Arr implements \Serializable
*/
public function create(var fields = [], extra = null)
{
- var status, valid, extraValid, messages, extraMessages;
+ var status;
- let fields = this->fields(fields),
- extraValid = false,
- extraMessages = [],
- valid = false,
- messages = [];
-
- this->setData(fields);
+ this->setData(this->fields(fields, false));
if extra {
- let extraValid = extra->validate(),
- extraMessages = extra->getMessages()->all();
+ extra->validate();
+
+ let this->messages = extra->getMessages()->all();
}
- this->_di->applyHook("model.before.validate", [this]);
+ this->di->applyHook("model.before.validate", [this]);
- if count(this->_rules) {
- if !(typeof this->_validation == "object" && (this->_validation instanceof Validation)) {
- let this->_validation = new Validation();
+ if count(this->rules) {
+ if !(typeof this->validation == "object" && (this->validation instanceof Validation)) {
+ let this->validation = new Validation();
}
- this->_validation->rules(this->_rules);
- this->_validation->setFilters(this->_filters);
- this->_validation->setLabels(this->_labels);
+ this->validation->rules(this->rules);
+ this->validation->setFilters(this->filters);
+ this->validation->setLabels(this->labels);
+ this->validation->validate(this->getData());
+
+ // Replace values by validation values (with applied filters)
+ this->replace(this->validation->getValues());
- let valid = this->_validation->validate(this->getData()),
- messages = this->_validation->getMessages()->all();
+ if !this->validation->valid() {
+ let this->messages = array_merge(this->messages, this->validation->getMessages()->all());
+ }
}
- if count(this->_rules) && !valid || extra && !extraValid {
- let this->_messages = array_merge(extraMessages, messages);
+ this->di->applyHook("model.after.validate", [this]);
+ if count(this->messages) {
return false;
}
- this->_di->applyHook("model.after.validate", [this]);
+ this->di->applyHook("model.before.create", [this]);
- let status = this->_db->insert(this->_from, this->getData());
+ let status = this->db->insert(this->from, this->getData());
if status {
- this->set(this->_db->getId(), this->_db->getLastInsertId());
+ this->set(this->db->getId(), this->db->getLastInsertId());
}
+ this->di->applyHook("model.after.create", [this]);
+
return status;
}
@@ -295,42 +323,59 @@ abstract class Model extends Arr implements \Serializable
*/
public function update(var fields = [], extra = null)
{
- var status, primary, key, extraValid, extraMessages;
+ var data, status, primary, key;
- let fields = this->fields(fields),
- extraValid = false,
- extraMessages = [],
+ let data = this->getData(),
primary = [];
- if extra {
- let extraValid = extra->validate(),
- extraMessages = extra->getMessages()->all();
+ if typeof this->primary == "array" {
+ for key in this->primary {
+ let primary[key] = this->get(key);
+ }
+ } else {
+ let primary = [this->primary: this->get(this->primary)];
}
- this->_di->applyHook("model.before.validate", [this]);
+ this->setData(this->fields(fields));
- if extra && !extraValid {
- let this->_messages = extraMessages;
+ if extra {
+ extra->validate();
- return false;
+ let this->messages = extra->getMessages()->all();
}
- this->_di->applyHook("model.after.validate", [this]);
+ this->di->applyHook("model.before.validate", [this]);
- if typeof this->_primary == "array" {
- for key in this->_primary {
- let primary[key] = this->get(key);
+ if typeof this->validation == "object" && (this->validation instanceof Validation) {
+ this->validation->validate(this->getData());
+
+ // Replace values by validation values (with applied filters)
+ this->replace(this->validation->getValues());
+
+ if !this->validation->valid() {
+ let this->messages = array_merge(this->messages, this->validation->getMessages()->all());
}
- } else {
- let primary = [this->_primary: this->get(this->_primary)];
}
- let status = this->_db->update(this->_from, primary, fields);
+ this->di->applyHook("model.after.validate", [this]);
- if status {
- this->replace(fields);
+ if count(this->messages) {
+ // Rollback changes and restore old data
+ this->setData(data);
+ return false;
+ }
+
+ this->di->applyHook("model.before.update", [this]);
+
+ let status = this->db->update(this->from, primary, this->fields(this->getData(), false));
+
+ if !status {
+ // Rollback changes and restore old data
+ this->setData(data);
}
+ this->di->applyHook("model.after.update", [this]);
+
return status;
}
@@ -385,16 +430,16 @@ abstract class Model extends Arr implements \Serializable
if !filters {
let filters = [];
- if typeof this->_primary == "array" {
- for key in this->_primary {
+ if typeof this->primary == "array" {
+ for key in this->primary {
let filters[key] = this->get(key);
}
} else {
- let filters = [this->_primary: this->get(this->_primary)];
+ let filters = [this->primary: this->get(this->primary)];
}
}
- let status = this->_db->remove(this->_from, filters);
+ let status = this->db->remove(this->from, filters);
return status;
}
@@ -412,8 +457,8 @@ abstract class Model extends Arr implements \Serializable
if !filters {
let filters = [];
- if typeof this->_primary == "array" {
- for key in this->_primary {
+ if typeof this->primary == "array" {
+ for key in this->primary {
if this->has(key) && this->get(key) {
let filters[key] = this->get(key);
} else {
@@ -421,8 +466,8 @@ abstract class Model extends Arr implements \Serializable
}
}
} else {
- if this->has(this->_primary) && this->get(this->_primary) {
- let filters = [this->_primary: this->get(this->_primary)];
+ if this->has(this->primary) && this->get(this->primary) {
+ let filters = [this->primary: this->get(this->primary)];
} else {
return false;
}
@@ -439,7 +484,7 @@ abstract class Model extends Arr implements \Serializable
*/
public function getError()
{
- return this->_db->getError();
+ return this->db->getError();
}
/**
@@ -473,7 +518,7 @@ abstract class Model extends Arr implements \Serializable
let alias = referenceModel;
}
- let this->_relations[alias] = [
+ let this->relations[alias] = [
"type": self::BELONGS_TO,
"field": field,
"referenceModel": referenceModel,
@@ -508,7 +553,7 @@ abstract class Model extends Arr implements \Serializable
let alias = referenceModel;
}
- let this->_relations[alias] = [
+ let this->relations[alias] = [
"type": self::HAS_ONE,
"field": field,
"referenceModel": referenceModel,
@@ -550,7 +595,7 @@ abstract class Model extends Arr implements \Serializable
let alias = referenceModel;
}
- let this->_relations[alias] = [
+ let this->relations[alias] = [
"type": self::HAS_MANY,
"field": field,
"referenceModel": referenceModel,
@@ -564,12 +609,13 @@ abstract class Model extends Arr implements \Serializable
*
* @param string alias
* @param array filters
+ * @param array options
*/
- public function getRelated(string alias, array filters = [])
+ public function getRelated(string alias, array filters = [], array options = [])
{
var relation, field, referenceModel, referencedField, from, result;
- if !fetch relation, this->_relations[alias] {
+ if !fetch relation, this->relations[alias] {
throw new Exception(sprintf("Alias '%s' not found", alias));
}
@@ -593,12 +639,52 @@ abstract class Model extends Arr implements \Serializable
case self::HAS_MANY:
let filters = array_merge(filters, [referencedField: this->{field}]);
- let result = {referenceModel}::find(filters);
+ let result = {referenceModel}::find(filters, options);
return result;
}
}
+ /**
+ * Get rules for validation.
+ *
+ *
+ * // Get rules for one field
+ * $this->getRules('password');
+ *
+ * // Get rules for multiple fields
+ * $this->getRules(['fullName', 'about']);
+ *
+ * // Get all rules
+ * $this->getRules();
+ *
+ *
+ * @param mixed fields
+ * @return mixed
+ */
+ public function getRules(fields = null)
+ {
+ var rules, field;
+
+ if fields {
+ if typeof fields == "array" {
+ let rules = [];
+
+ for field in fields {
+ if isset this->rules[field] {
+ let rules[field] = this->rules[field];
+ }
+ }
+
+ return rules;
+ } elseif typeof fields == "string" && isset this->rules[fields] {
+ return this->rules[fields];
+ }
+ }
+
+ return this->rules;
+ }
+
/**
* Set rules for validation.
*
@@ -608,9 +694,9 @@ abstract class Model extends Arr implements \Serializable
public function setRules(array! rules = [], boolean merge = true)
{
if merge {
- let this->_rules = array_merge(this->_rules, rules);
+ let this->rules = array_merge(this->rules, rules);
} else {
- let this->_rules = rules;
+ let this->rules = rules;
}
}
@@ -621,7 +707,7 @@ abstract class Model extends Arr implements \Serializable
*/
public function serialize() -> string
{
- return json_encode(this->_data);
+ return base64_encode(serialize(this->data));
}
/**
@@ -630,7 +716,7 @@ abstract class Model extends Arr implements \Serializable
public function unserialize(string! data)
{
this->__construct();
- let this->_data = json_decode(data, true);
+ let this->data = unserialize(base64_decode(data));
}
/**
@@ -638,11 +724,12 @@ abstract class Model extends Arr implements \Serializable
*/
public function __call(string method, arguments = null)
{
- var filters;
+ var filters, options;
if starts_with(method, "get") {
fetch filters, arguments[0];
- return this->getRelated(ucfirst(substr(method, 3)), filters);
+ fetch options, arguments[1];
+ return this->getRelated(ucfirst(substr(method, 3)), filters, options);
}
// The method doesn't exist throw an exception
diff --git a/ice/mvc/route.zep b/ice/mvc/route.zep
index cbd2652a..595785da 100644
--- a/ice/mvc/route.zep
+++ b/ice/mvc/route.zep
@@ -9,7 +9,7 @@ namespace Ice\Mvc;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
- * @uses FastRoute http:/github.com/nikic/FastRoute
+ * @uses FastRoute http:/github.com/nikic/FastRoute/commit/02b8aabe519672f250e261e24282dc1937f2637b
*/
class Route
{
diff --git a/ice/mvc/route/collector.zep b/ice/mvc/route/collector.zep
index d6b54405..a3a3abf5 100644
--- a/ice/mvc/route/collector.zep
+++ b/ice/mvc/route/collector.zep
@@ -43,9 +43,9 @@ class Collector
*/
public function addRoute(var httpMethod, string route, handler = null)
{
- var routeData, method;
+ var routeDatas, routeData, method;
- let routeData = this->routeParser->parse(route);
+ let routeDatas = this->routeParser->parse(route);
if typeof httpMethod == "string" {
let method = httpMethod,
@@ -53,7 +53,9 @@ class Collector
}
for method in httpMethod {
- this->dataGenerator->addRoute(method, routeData, handler);
+ for routeData in routeDatas {
+ this->dataGenerator->addRoute(method, routeData, handler);
+ }
}
}
diff --git a/ice/mvc/route/datagenerator/regex.zep b/ice/mvc/route/datagenerator/regex.zep
index 28079c33..b1638fcb 100644
--- a/ice/mvc/route/datagenerator/regex.zep
+++ b/ice/mvc/route/datagenerator/regex.zep
@@ -8,8 +8,8 @@ use Ice\Mvc\Route;
abstract class Regex implements DataGeneratorInterface
{
- protected _staticRoutes = [];
- protected _methodToRegexToRoutesMap = [];
+ protected staticRoutes = [];
+ protected methodToRegexToRoutesMap = [];
protected abstract function getApproxChunkSize();
protected abstract function processChunk(regexToRoutesMap);
@@ -25,11 +25,11 @@ abstract class Regex implements DataGeneratorInterface
public function getData()
{
- if empty this->_methodToRegexToRoutesMap {
- return [this->_staticRoutes, []];
+ if empty this->methodToRegexToRoutesMap {
+ return [this->staticRoutes, []];
}
- return [this->_staticRoutes, this->generateVariableRouteData()];
+ return [this->staticRoutes, this->generateVariableRouteData()];
}
protected function generateVariableRouteData()
@@ -38,7 +38,7 @@ abstract class Regex implements DataGeneratorInterface
let data = [];
- for method, regexToRoutesMap in this->_methodToRegexToRoutesMap {
+ for method, regexToRoutesMap in this->methodToRegexToRoutesMap {
let chunkSize = this->computeChunkSize(count(regexToRoutesMap)),
chunks = array_chunk(regexToRoutesMap, chunkSize, true),
data[method] = array_map([this, "processChunk"], chunks);
@@ -70,14 +70,14 @@ abstract class Regex implements DataGeneratorInterface
let routeStr = routeData[0];
- if isset this->_staticRoutes[routeStr] && isset this->_staticRoutes[routeStr][httpMethod] {
+ if isset this->staticRoutes[httpMethod] && isset this->staticRoutes[httpMethod][routeStr] {
throw new Exception(sprintf("Cannot register two routes matching '%s' for method '%s'",
routeStr, httpMethod
));
}
- if isset this->_methodToRegexToRoutesMap[httpMethod] {
- for route in this->_methodToRegexToRoutesMap[httpMethod] {
+ if isset this->methodToRegexToRoutesMap[httpMethod] {
+ for route in this->methodToRegexToRoutesMap[httpMethod] {
if route->matches(routeStr) {
throw new Exception(sprintf(
"Static route '%s' is shadowed by previously defined variable route '%s' for method '%s'",
@@ -87,7 +87,7 @@ abstract class Regex implements DataGeneratorInterface
}
}
- let this->_staticRoutes[routeStr][httpMethod] = handler;
+ let this->staticRoutes[httpMethod][routeStr] = handler;
}
protected function addVariableRoute(httpMethod, routeData, handler)
@@ -97,14 +97,14 @@ abstract class Regex implements DataGeneratorInterface
let regex = this->buildRegexForRoute(routeData)[0],
variables = this->buildRegexForRoute(routeData)[1];
- if isset this->_methodToRegexToRoutesMap[httpMethod] && isset this->_methodToRegexToRoutesMap[httpMethod][regex] {
+ if isset this->methodToRegexToRoutesMap[httpMethod] && isset this->methodToRegexToRoutesMap[httpMethod][regex] {
throw new Exception(sprintf(
"Cannot register two routes matching '%s' for method '%s'",
regex, httpMethod
));
}
- let this->_methodToRegexToRoutesMap[httpMethod][regex] = new Route(
+ let this->methodToRegexToRoutesMap[httpMethod][regex] = new Route(
httpMethod, handler, regex, variables
);
}
diff --git a/ice/mvc/route/dispatcher/groupcount.zep b/ice/mvc/route/dispatcher/groupcount.zep
index b3216a0a..3a9d283d 100644
--- a/ice/mvc/route/dispatcher/groupcount.zep
+++ b/ice/mvc/route/dispatcher/groupcount.zep
@@ -7,14 +7,14 @@ use Ice\Mvc\Router;
class GroupCount extends Regex
{
- protected _staticRouteMap { set };
- protected _variableRouteData { set };
+ protected staticRouteMap { set };
+ protected variableRouteData { set };
public function __construct(array data = [])
{
if count(data) {
- let this->_staticRouteMap = data[0],
- this->_variableRouteData = data[1];
+ let this->staticRouteMap = data[0],
+ this->variableRouteData = data[1];
}
}
diff --git a/ice/mvc/route/dispatcher/regex.zep b/ice/mvc/route/dispatcher/regex.zep
index 7f1ce299..908d9994 100644
--- a/ice/mvc/route/dispatcher/regex.zep
+++ b/ice/mvc/route/dispatcher/regex.zep
@@ -7,26 +7,30 @@ use Ice\Mvc\Router;
abstract class Regex implements DispatcherInterface
{
- protected _staticRouteMap { set };
- protected _variableRouteData { set };
+ protected staticRouteMap { set };
+ protected variableRouteData { set };
public function setData(array! data = [])
{
- let this->_staticRouteMap = data[0],
- this->_variableRouteData = data[1];
+ let this->staticRouteMap = data[0],
+ this->variableRouteData = data[1];
}
protected abstract function dispatchVariableRoute(routeData, uri);
public function dispatch(httpMethod, uri)
{
- var varRouteData, result, allowedMethods, method, routeData;
-
- if isset this->_staticRouteMap[uri] {
- return this->dispatchStaticRoute(httpMethod, uri);
+ var handler, varRouteData, result, allowedMethods, uriMap, method, routeData;
+
+ if isset this->staticRouteMap[httpMethod] && isset this->staticRouteMap[httpMethod][uri] {
+ let handler = this->staticRouteMap[httpMethod][uri];
+ return [Router::FOUND, handler, []];
+ } elseif httpMethod === "HEAD" && isset this->staticRouteMap["GET"][uri] {
+ let handler = this->staticRouteMap["GET"][uri];
+ return [Router::FOUND, handler, []];
}
- let varRouteData = this->_variableRouteData;
+ let varRouteData = this->variableRouteData;
if isset varRouteData[httpMethod] {
let result = this->dispatchVariableRoute(varRouteData[httpMethod], uri);
@@ -42,10 +46,15 @@ abstract class Regex implements DispatcherInterface
}
}
- // Find allowed methods for this URI by matching against all other
- // HTTP methods as well
+ // Find allowed methods for this URI by matching against all other HTTP methods as well
let allowedMethods = [];
+ for method, uriMap in this->staticRouteMap {
+ if method !== httpMethod && isset uriMap[uri] {
+ let allowedMethods[] = method;
+ }
+ }
+
for method, routeData in varRouteData {
if method === httpMethod {
continue;
@@ -64,19 +73,4 @@ abstract class Regex implements DispatcherInterface
return [Router::NOT_FOUND];
}
}
-
- protected function dispatchStaticRoute(httpMethod, uri)
- {
- var routes;
-
- let routes = this->_staticRouteMap[uri];
-
- if isset routes[httpMethod] {
- return [Router::FOUND, routes[httpMethod], []];
- } elseif httpMethod === "HEAD" && isset routes["GET"] {
- return [Router::FOUND, routes["GET"], []];
- } else {
- return [Router::METHOD_NOT_ALLOWED, array_keys(routes)];
- }
- }
}
\ No newline at end of file
diff --git a/ice/mvc/route/parser/parserinterface.zep b/ice/mvc/route/parser/parserinterface.zep
index 99f14c67..371be927 100644
--- a/ice/mvc/route/parser/parserinterface.zep
+++ b/ice/mvc/route/parser/parserinterface.zep
@@ -5,18 +5,32 @@ interface ParserInterface
{
/**
- * Returns an array of the following form:
+ * Parses a route string into multiple route data arrays.
*
- *[
- * "/fixedRoutePart/",
- * ["varName", "[^/]+"],
- * "/moreFixed/",
- * ["varName2", [0-9]+"],
- *]
+ * The expected output is defined using an example:
*
- * @param string $route Route to parse
- *
- * @return array Parsed route data
+ * For the route string "/fixedRoutePart/{varName}[/moreFixed/{varName2:\d+}]", if {varName} is interpreted as
+ * a placeholder and [...] is interpreted as an optional route part, the expected result is:
+ *
+ * [
+ * // first route: without optional part
+ * [
+ * "/fixedRoutePart/",
+ * ["varName", "[^/]+"],
+ * ],
+ * // second route: with optional part
+ * [
+ * "/fixedRoutePart/",
+ * ["varName", "[^/]+"],
+ * "/moreFixed/",
+ * ["varName2", [0-9]+"],
+ * ],
+ * ]
+ *
+ * Here one route string was converted into two route data arrays.
+ *
+ * @param string $route Route string to parse
+ * @return mixed[][] Array of route data arrays
*/
public function parse(route);
}
\ No newline at end of file
diff --git a/ice/mvc/route/parser/std.zep b/ice/mvc/route/parser/std.zep
index e3e515b4..e439f0ee 100644
--- a/ice/mvc/route/parser/std.zep
+++ b/ice/mvc/route/parser/std.zep
@@ -1,31 +1,70 @@
namespace Ice\Mvc\Route\Parser;
+use Ice\Exception;
use Ice\Mvc\Route\Parser\ParserInterface;
/**
- * Parses routes of the following form:
+ * Parses route strings of the following form:
*
- * "/user/{name}/{id:[0-9]+}"
+ * "/user/{name}[/{id:[0-9]+}]"
*/
class Std implements ParserInterface
{
- const VARIABLE_REGEX = "~\\{ \\s* ([a-zA-Z][a-zA-Z0-9_]*) \\s* (?: : \\s* ([^{}]*(?:\\{(?-1)\\}[^{}]*)*) )? \\}~x";
+ const VARIABLE_REGEX = "\\{ \\s* ([a-zA-Z][a-zA-Z0-9_]*) \\s* (?: : \\s* ([^{}]*(?:\\{(?-1)\\}[^{}]*)*) )? \\}";
const DEFAULT_DISPATCH_REGEX = "[^/]+";
public function parse(route)
{
- var matches, routeData, value;
- int offset = 0;
+ var routeWithoutClosingOptionals, numOptionals, segments, currentRoute, routeDatas, n, segment;
+
+ let routeWithoutClosingOptionals = rtrim(route, ']'),
+ numOptionals = strlen(route) - strlen(routeWithoutClosingOptionals);
+
+ // Split on [ while skipping placeholders
+ let segments = preg_split("~" . self::VARIABLE_REGEX . "(*SKIP)(*F) | \\[~x", routeWithoutClosingOptionals);
+
+ if numOptionals !== count(segments) - 1 {
+ // If there are any ] in the middle of the route, throw a more specific error message
+ if preg_match("~" . self::VARIABLE_REGEX . "(*SKIP)(*F) | \\]~x", routeWithoutClosingOptionals) {
+ throw new Exception("Optional segments can only occur at the end of a route");
+ }
+
+ throw new Exception("Number of opening '[' and closing ']' does not match");
+ }
+
+ let currentRoute = "",
+ routeDatas = [];
+
+ for n, segment in segments {
+ if segment === "" && n !== 0 {
+ throw new Exception("Empty optional part");
+ }
+
+ let currentRoute .= segment,
+ routeDatas[] = this->parsePlaceholders(currentRoute);
+ }
+
+ return routeDatas;
+ }
+
+ /**
+ * Parses a route string that does not contain optional segments.
+ */
+ private function parsePlaceholders(route)
+ {
+ var matches, routeData, value, offset;
let matches = [];
- if !preg_match_all(self::VARIABLE_REGEX, route, matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER) {
+ if !preg_match_all("~" . self::VARIABLE_REGEX . "~x", route, matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER) {
return [route];
}
- let routeData = [];
- for value in matches {
+ let offset = 0,
+ routeData = [];
+
+ for value in matches {
if value[0][1] > offset {
let routeData[] = substr(route, offset, value[0][1] - offset);
}
@@ -34,11 +73,10 @@ class Std implements ParserInterface
value[1][0],
isset(value[2]) ? trim(value[2][0]) : self::DEFAULT_DISPATCH_REGEX
];
-
let offset = value[0][1] + strlen(value[0][0]);
}
- if (offset != strlen(route)) {
+ if offset != strlen(route) {
let routeData[] = substr(route, offset);
}
diff --git a/ice/mvc/router.zep b/ice/mvc/router.zep
index 26cc7ee6..929062f9 100644
--- a/ice/mvc/router.zep
+++ b/ice/mvc/router.zep
@@ -20,23 +20,23 @@ use Ice\Mvc\Route\Dispatcher\DispatcherInterface;
class Router
{
- protected _di;
- protected _defaultModule = "default" { get, set };
- protected _defaultHandler = "index" { get, set };
- protected _defaultAction = "index" { get, set };
-
- protected _method { get };
- protected _module{ get };
- protected _handler { get };
- protected _action { get };
- protected _params = [] { get };
-
- protected _ready = false;
- protected _silent = false { set };
- protected _options { get, set };
- protected _routes { get, set };
- protected _collector { get, set };
- protected _dispatcher { get, set };
+ protected di;
+ protected defaultModule = "default" { get, set };
+ protected defaultHandler = "index" { get, set };
+ protected defaultAction = "index" { get, set };
+
+ protected method { get };
+ protected module{ get };
+ protected handler { get };
+ protected action { get };
+ protected params = [] { get };
+
+ protected ready = false;
+ protected silent = false { set };
+ protected options = [] { get, set };
+ protected routes { get, set };
+ protected collector { get, set };
+ protected dispatcher { get, set };
const NOT_FOUND = 0;
const FOUND = 1;
@@ -47,7 +47,7 @@ class Router
*/
public function __construct()
{
- let this->_di = Di::$fetch();
+ let this->di = Di::$fetch();
}
/**
@@ -60,63 +60,56 @@ class Router
var module, handler, action;
if fetch module, defaults["module"] {
- let this->_defaultModule = module;
+ let this->defaultModule = module;
}
if fetch handler, defaults["handler"] {
- let this->_defaultHandler = handler;
+ let this->defaultHandler = handler;
}
if fetch action, defaults["action"] {
- let this->_defaultAction = action;
+ let this->defaultAction = action;
}
}
/**
* Prepare the FastRoute.
- *
- * @param object routeDefinitionCallback
- * @param array options
*/
- public function fastRoute(routeDefinitionCallback = null, array options = [])
+ public function fastRoute()
{
- var dispatcher, data, collector, parser, generator, route, handler;
+ var options, dispatcher, data, collector, parser, generator, route, handler;
let options = array_merge([
"routeParser": "Ice\\Mvc\\Route\\Parser\\Std",
"dataGenerator": "Ice\\Mvc\\Route\\DataGenerator\\GroupCount",
"dispatcher":"Ice\\Mvc\\Route\\Dispatcher\\GroupCount",
"cache": false
- ], options);
-
- let this->_options = options;
+ ], this->options);
+ let this->options = options,
+ collector = this->collector;
- let collector = this->_collector;
if typeof collector != "object" || typeof collector == "object" && !(collector instanceof Collector) {
fetch parser, options["routeParser"];
fetch generator, options["dataGenerator"];
- let this->_collector = new Collector(new {parser}(), new {generator}());
- }
-
- if typeof routeDefinitionCallback == "callable" {
- {routeDefinitionCallback}(this->_collector);
+ let this->collector = new Collector(new {parser}(), new {generator}());
}
- if !this->_routes {
+ if !this->routes {
throw new Exception("There are no routes.");
} else {
- for route in this->_routes {
+ for route in this->routes {
fetch handler, route[2];
- this->_collector->addRoute(route[0], route[1], handler);
+ this->collector->addRoute(route[0], route[1], handler);
}
}
- let dispatcher = this->_dispatcher;
+ let dispatcher = this->dispatcher;
+
if typeof dispatcher != "object" || typeof dispatcher == "object" && !(dispatcher instanceof DispatcherInterface) {
let dispatcher = options["dispatcher"],
- this->_dispatcher = new {dispatcher}();
+ this->dispatcher = new {dispatcher}();
}
if options["cache"] {
@@ -127,15 +120,17 @@ class Router
if file_exists(options["cacheFile"]) {
let data = require options["cacheFile"];
} else {
+ let data = this->collector->getData();
+
file_put_contents(options["cacheFile"], "_collector->getData();
+ let data = this->collector->getData();
}
- this->_dispatcher->setData(data);
+ this->dispatcher->setData(data);
- let this->_ready = true;
+ let this->ready = true;
}
/**
@@ -149,21 +144,21 @@ class Router
var module, handler, action, params, holders, data, route, response;
let
- handler = this->_defaultHandler,
- action = this->_defaultAction,
+ handler = this->defaultHandler,
+ action = this->defaultAction,
params = [];
- if !this->_ready {
+ if !this->ready {
this->fastRoute();
}
- let route = this->_dispatcher->dispatch(method, uri);
+ let route = this->dispatcher->dispatch(method, uri);
switch route[0] {
case self::NOT_FOUND:
- if this->_silent {
+ if this->silent {
// 404 Not Found
- let response = this->_di->{"getResponse"}();
+ let response = this->di->get("response", null, true);
response->setStatus(404);
response->setBody(response->getMessage(404));
@@ -171,9 +166,9 @@ class Router
}
throw new Exception("The requested route could not be found", self::NOT_FOUND);
case self::METHOD_NOT_ALLOWED:
- if this->_silent {
+ if this->silent {
// 405 Method Not Allowed
- let response = this->_di->{"getResponse"}();
+ let response = this->di->get("response", null, true);
response->setStatus(405);
response->setBody(response->getMessage(405));
@@ -189,7 +184,7 @@ class Router
let module = str_replace("/", "", module);
unset data["module"];
} else {
- let module = this->_defaultModule;
+ let module = this->defaultModule;
}
}
@@ -198,7 +193,7 @@ class Router
let handler = str_replace("/", "", handler);
unset data["controller"];
} else {
- let handler = this->_defaultHandler;
+ let handler = this->defaultHandler;
}
}
@@ -207,7 +202,7 @@ class Router
let action = str_replace("/", "", action);
unset data["action"];
} else {
- let action = this->_defaultAction;
+ let action = this->defaultAction;
}
}
@@ -215,11 +210,11 @@ class Router
break;
}
- let this->_method = method,
- this->_module = module,
- this->_handler = handler,
- this->_action = action,
- this->_params = params;
+ let this->method = method,
+ this->module = module,
+ this->handler = handler,
+ this->action = action,
+ this->params = params;
return ["module": module, "handler": handler, "action": action, "params": params];
}
diff --git a/ice/mvc/service.zep b/ice/mvc/service.zep
new file mode 100644
index 00000000..deeb9256
--- /dev/null
+++ b/ice/mvc/service.zep
@@ -0,0 +1,48 @@
+
+namespace Ice\Mvc;
+
+use Ice\Di\Access;
+use Ice\Exception;
+
+/**
+ * Service is intermediary between Model and Controller.
+ *
+ * @package Ice/Mvc
+ * @category Component
+ * @author Ice Team
+ * @copyright (c) 2014-2015 Ice Team
+ * @license http://iceframework.org/license
+ */
+abstract class Service extends Access
+{
+
+ private model { set, get };
+
+ /**
+ * Controller constructor. Run onConstruct() if method exist.
+ */
+ public final function __construct()
+ {
+ parent::__construct();
+
+ if method_exists(this, "onConstruct") {
+ this->{"onConstruct"}();
+ }
+ }
+
+ /**
+ * Magic method to call model's method.
+ *
+ * @param string method
+ * @param mixed arguments
+ * @return mixed
+ */
+ public function __call(string! method, arguments = null)
+ {
+ if typeof this->model == "object" && (this->model instanceof Model) {
+ return call_user_func_array([this->model, method], arguments);
+ } else {
+ throw new Exception("The `model` property must be instance of Model");
+ }
+ }
+}
diff --git a/ice/mvc/url.zep b/ice/mvc/url.zep
index a828bd1f..5ff8e2d9 100644
--- a/ice/mvc/url.zep
+++ b/ice/mvc/url.zep
@@ -15,8 +15,8 @@ use Ice\Di;
class Url
{
- protected _baseUri = "/" { get, set };
- protected _staticUri = "/" { get, set };
+ protected baseUri = "/" { get, set };
+ protected staticUri = "/" { get, set };
/**
* Generates a URL for a static resource.
@@ -41,7 +41,7 @@ class Url
{
var baseUri, matched, queryString;
- if !local {
+ if !local && !starts_with(uri, "mailto:") {
if strstr(uri, "://") {
let matched = preg_match("/^[^:\\/?#]++:/", uri);
if matched {
diff --git a/ice/mvc/view.zep b/ice/mvc/view.zep
index d434cf78..8740488e 100644
--- a/ice/mvc/view.zep
+++ b/ice/mvc/view.zep
@@ -18,14 +18,14 @@ use Ice\Mvc\View\ViewInterface;
class View extends Arr implements ViewInterface
{
- protected _engines { set };
- protected _content { set, get };
- protected _mainView = "index" { set, get };
- protected _layoutsDir = "layouts/" { set, get };
- protected _partialsDir = "partials/" { set, get };
- protected _viewsDir { set, get };
- protected _file { set, get };
- protected _silent = false { set };
+ protected engines { set };
+ protected content { set, get };
+ protected mainView = "index" { set, get };
+ protected layoutsDir = "layouts/" { set, get };
+ protected partialsDir = "partials/" { set, get };
+ protected viewsDir { set, get };
+ protected file { set, get };
+ protected silent = false { set };
/**
* View constructor. Set the file and vars.
@@ -36,7 +36,7 @@ class View extends Arr implements ViewInterface
public function __construct(file = null, array data = [])
{
if file != null {
- let this->_file = file;
+ let this->file = file;
}
parent::__construct(data);
}
@@ -48,23 +48,23 @@ class View extends Arr implements ViewInterface
{
var ext, engine;
- if !this->_engines {
- let this->_engines[".phtml"] = new Php(this);
+ if !this->engines {
+ let this->engines[".phtml"] = new Php(this);
}
- for ext, engine in this->_engines {
+ for ext, engine in this->engines {
if typeof engine == "object" {
if engine instanceof \Closure {
- let this->_engines[ext] = call_user_func_array(engine, [this]);
+ let this->engines[ext] = call_user_func_array(engine, [this]);
}
} else {
if typeof engine == "string" {
- let this->_engines[ext] = create_instance_params(engine, [this]);
+ let this->engines[ext] = create_instance_params(engine, [this]);
} else {
throw new Exception(sprintf("Invalid template engine registration for '%s' extension", ext));
}
}
}
- return this->_engines;
+ return this->engines;
}
/**
@@ -82,17 +82,17 @@ class View extends Arr implements ViewInterface
content = null;
if file !== null {
- let this->_file = file;
+ let this->file = file;
}
- if empty this->_file {
+ if empty this->file {
throw new Exception("You must set the file to use within your view before rendering");
}
let engines = this->getEngines();
for ext, engine in engines {
- let path = this->_viewsDir . this->_file . ext;
+ let path = this->viewsDir . this->file . ext;
if file_exists(path) {
let exists = true;
this->replace(data);
@@ -101,7 +101,7 @@ class View extends Arr implements ViewInterface
}
}
- if !this->_silent && !exists {
+ if !this->silent && !exists {
throw new Exception(sprintf("The requested view %s could not be found", path));
}
return content;
@@ -128,7 +128,7 @@ class View extends Arr implements ViewInterface
*/
public function partial(string! file, array data = [])
{
- return this->render(this->_partialsDir . file, data);
+ return this->render(this->partialsDir . file, data);
}
/**
@@ -141,9 +141,9 @@ class View extends Arr implements ViewInterface
public function layout(var file = null, array data = [])
{
if !file {
- let file = this->_mainView;
+ let file = this->mainView;
}
- return this->render(this->_layoutsDir . file, data);
+ return this->render(this->layoutsDir . file, data);
}
/**
diff --git a/ice/mvc/view/engine.zep b/ice/mvc/view/engine.zep
index 0d2dab0f..c1721d36 100644
--- a/ice/mvc/view/engine.zep
+++ b/ice/mvc/view/engine.zep
@@ -18,15 +18,15 @@ use Ice\Mvc\View\Engine\EngineInterface;
abstract class Engine extends Access implements EngineInterface
{
- protected _view;
- protected _options { set };
+ protected view;
+ protected options { set };
/**
* Engine constructor. Set the view and di object.
*/
public function __construct( view, di = null)
{
- let this->_view = view;
+ let this->view = view;
parent::__construct(di);
}
@@ -37,7 +37,7 @@ abstract class Engine extends Access implements EngineInterface
*/
public function getContent() -> string
{
- return this->_view->getContent();
+ return this->view->getContent();
}
/**
@@ -48,7 +48,7 @@ abstract class Engine extends Access implements EngineInterface
*/
public function load(string! path, array data = []) -> string
{
- return this->_view->load(path, data);
+ return this->view->load(path, data);
}
/**
@@ -59,7 +59,7 @@ abstract class Engine extends Access implements EngineInterface
*/
public function partial(string! path, array data = []) -> string
{
- return this->_view->partial(path, data);
+ return this->view->partial(path, data);
}
/**
diff --git a/ice/mvc/view/engine/sleet.zep b/ice/mvc/view/engine/sleet.zep
index 5937891f..2084113b 100644
--- a/ice/mvc/view/engine/sleet.zep
+++ b/ice/mvc/view/engine/sleet.zep
@@ -17,7 +17,7 @@ use Ice\Mvc\View\Engine\Sleet\Compiler;
*/
class Sleet extends Engine
{
- protected _compiler { get };
+ protected compiler { get };
/**
* Compile the .sleet file.
@@ -29,9 +29,9 @@ class Sleet extends Engine
{
var compileDir, compile, trim, dir, file, compiledPath, old, compiled;
- fetch trim, this->_options["trimPath"];
- fetch compileDir, this->_options["compileDir"];
- fetch compile, this->_options["compile"];
+ fetch trim, this->options["trimPath"];
+ fetch compileDir, this->options["compileDir"];
+ fetch compile, this->options["compile"];
let dir = rtrim(compileDir, DIRECTORY_SEPARATOR) . str_replace(trim, "", realpath(dirname(path))),
file = basename(path, ".sleet"),
@@ -58,8 +58,8 @@ class Sleet extends Engine
}
if compile {
- let this->_compiler = new Compiler(this),
- compiled = this->_compiler->compile(path);
+ let this->compiler = new Compiler(this),
+ compiled = this->compiler->compile(path);
// Check if file was changed
if typeof compile == "string" {
diff --git a/ice/mvc/view/engine/sleet/compiler.zep b/ice/mvc/view/engine/sleet/compiler.zep
index 31b57df4..9f8cdd3a 100644
--- a/ice/mvc/view/engine/sleet/compiler.zep
+++ b/ice/mvc/view/engine/sleet/compiler.zep
@@ -13,10 +13,10 @@ namespace Ice\Mvc\View\Engine\Sleet;
class Compiler
{
- protected _view;
- protected _content;
- protected _parsed;
- protected _parser { get };
+ protected view;
+ protected content;
+ protected parsed;
+ protected parser { get };
const NEVER = 0;
const NOT_EXIST = 1;
@@ -30,8 +30,8 @@ class Compiler
*/
public function __construct(view = null)
{
- let this->_view = view,
- this->_parser = new Parser();
+ let this->view = view,
+ this->parser = new Parser();
}
/**
@@ -45,10 +45,10 @@ class Compiler
var content;
let content = file_get_contents(path),
- this->_content = content,
- this->_parsed = this->_parser->text(content);
+ this->content = content,
+ this->parsed = this->parser->text(content);
- return this->_parsed;
+ return this->parsed;
}
/**
@@ -56,6 +56,6 @@ class Compiler
*/
public function __toString()
{
- return this->_parsed;
+ return this->parsed;
}
}
diff --git a/ice/mvc/view/engine/sleet/parser.zep b/ice/mvc/view/engine/sleet/parser.zep
index 88f116e1..18fc26f9 100644
--- a/ice/mvc/view/engine/sleet/parser.zep
+++ b/ice/mvc/view/engine/sleet/parser.zep
@@ -15,7 +15,7 @@ use Ice\Exception;
class Parser
{
- protected _functions = [
+ protected functions = [
"content": "$this->getContent",
"partial": "$this->partial",
"load": "$this->load",
@@ -23,11 +23,11 @@ class Parser
"version": "Ice\\Version::get"
];
- protected _filters = [
+ protected filters = [
"capitalize": "ucfirst"
];
- protected _env = [];
+ protected env = [];
const NORMAL = 0;
const SHORTIF = 1;
@@ -54,8 +54,8 @@ class Parser
}
}
- let this->_functions = array_merge(this->_functions, functions),
- this->_env[] = Parser::NORMAL;
+ let this->functions = array_merge(this->functions, functions),
+ this->env[] = Parser::NORMAL;
}
/**
@@ -234,7 +234,7 @@ class Parser
*/
private function parseControl(control, expression) -> string
{
- return "_parse(expression) . "): ?>";
+ return "doParse(expression) . "): ?>";
}
/**
@@ -245,7 +245,7 @@ class Parser
*/
private function parseEcho($expression) -> string
{
- return "_parse(expression) . " ?>";
+ return "doParse(expression) . " ?>";
}
/**
@@ -256,7 +256,7 @@ class Parser
*/
private function parseSet($expression) -> string
{
- return "_parse(expression) . "; ?>";
+ return "doParse(expression) . "; ?>";
}
/**
@@ -267,7 +267,7 @@ class Parser
*/
private function parseUse($expression) -> string
{
- return "_parse(expression) . "; ?>";
+ return "doParse(expression) . "; ?>";
}
/**
@@ -276,7 +276,7 @@ class Parser
* @param array tokens
* @return string
*/
- private function _parse(tokens) -> string
+ private function doParse(tokens) -> string
{
var i, parsed, prev, next, token, filter, seek, filters;
@@ -291,13 +291,13 @@ class Parser
if next == "|" {
let seek = i->key() + 2,
filter = i->offsetGet(seek),
- filter = isset this->_filters[filter[1]] ? this->_filters[filter[1]] : filter[1],
+ filter = isset this->filters[filter[1]] ? this->filters[filter[1]] : filter[1],
filters = ["camelize", "uncamelize", "human", "lower", "upper", "alnum", "alpha", "email", "float", "int", "string", "strip_repeats", "e", "escape", "strip_special", "unescape", "unstrip_special"];
if in_array(filter, filters) {
- let parsed .= "$this->filter->sanitize(" . this->_token(token, prev, next) . ", '" . filter . "'";
+ let parsed .= "$this->filter->sanitize(" . this->token(token, prev, next) . ", '" . filter . "'";
} else {
- let parsed .= filter . "(" . this->_token(token, prev, next);
+ let parsed .= filter . "(" . this->token(token, prev, next);
}
let next = i->offsetExists(seek + 1) ? i->offsetGet(seek + 1) : null;
@@ -314,7 +314,7 @@ class Parser
continue;
}
- let parsed .= this->_token(token, prev, next),
+ let parsed .= this->token(token, prev, next),
prev = token;
i->next();
@@ -330,7 +330,7 @@ class Parser
* @param mixed next
* @return mixed
*/
- private function _token(token, prev = null, next = null)
+ private function token(token, prev = null, next = null)
{
string str;
@@ -352,7 +352,7 @@ class Parser
let str = (string) token[1];
if next == "(" && (prev != "." || typeof prev == "array" && prev[0] != T_DOUBLE_COLON) {
- return isset this->_functions[str] ? this->_functions[str] : str;
+ return isset this->functions[str] ? this->functions[str] : str;
}
switch str {
case "in":
@@ -396,22 +396,22 @@ class Parser
case ".":
return "->";
case ":":
- switch end(this->_env) {
+ switch end(this->env) {
case Parser::SHORTIF:
- array_pop(this->_env);
+ array_pop(this->env);
return " : ";
default:
return " => ";
}
case "?":
- let this->_env[] = Parser::SHORTIF;
+ let this->env[] = Parser::SHORTIF;
return " ? ";
case "[":
- let this->_env[] = Parser::INARRAY;
+ let this->env[] = Parser::INARRAY;
return token;
case "]":
- if end(this->_env) == Parser::INARRAY {
- array_pop(this->_env);
+ if end(this->env) == Parser::INARRAY {
+ array_pop(this->env);
}
return token;
default:
diff --git a/ice/pagination.zep b/ice/pagination.zep
index e43086c3..26a14af1 100644
--- a/ice/pagination.zep
+++ b/ice/pagination.zep
@@ -14,8 +14,8 @@ namespace Ice;
class Pagination extends Arr
{
- protected _di { get };
- protected _tag { get };
+ protected di { get };
+ protected tag { get };
/**
* Pagination constructor. Fetch di and tag.
@@ -29,8 +29,8 @@ class Pagination extends Arr
parent::__construct(options);
let di = Di::$fetch(),
- this->_di = di,
- this->_tag = di->{"getTag"}();
+ this->di = di,
+ this->tag = di->get("tag", null, true);
}
/**
@@ -58,7 +58,7 @@ class Pagination extends Arr
let limit = (int) this->get("limit", 10),
page = (int) this->get("page", 1),
total = count(items),
- pages = (int) ceil(total / intval(limit));
+ pages = (int) ceil(total / intval(limit ? limit : 1));
// Make sure page is >= 1
if page <= 0 {
@@ -93,6 +93,68 @@ class Pagination extends Arr
return this;
}
+ /**
+ * Prepare list button.
+ *
+ * @param mixed page Name or page number
+ * @param string url URL with pagination
+ * @param boolean active If active create link else span
+ * @param string symbol HTML symbol to add
+ * @return string HTML
+ */
+ protected function prepareButton(var page, string url = null, boolean active = false, var symbol = null)
+ {
+ var query, i18n, title;
+ boolean pages = false;
+
+ switch page {
+ case "first":
+ let symbol = "«";
+ break;
+ case "previous":
+ let symbol = "‹";
+ break;
+ case "next":
+ let symbol = "›";
+ break;
+ case "last":
+ let symbol = "»";
+ break;
+ default:
+ let symbol = !symbol ? page : symbol,
+ pages = true;
+ break;
+ }
+
+ if !active {
+ return "" . symbol . " ";
+ }
+
+ let query = this->di->get("request", null, true)->getQuery(),
+ i18n = this->di->get("i18n");
+
+ if pages {
+ let title = i18n ? i18n->translate("page: %d", [page]) : null;
+ } else {
+ let title = i18n ? i18n->translate(page) : null,
+ page = this->get(page);
+ }
+
+ if this->has("query") && !this->get("query") {
+ // Add /1 to the url
+ let url .= (url ? "/" : "") . page . this->get("hash");
+ } else {
+ // Don't add ?page=1 for first page
+ if page > 1 {
+ query->set("page", page);
+ } else {
+ query->remove("page");
+ }
+ }
+
+ return "" . this->tag->a([url, symbol, title, "query": query->all()]) . " ";
+ }
+
/**
* Prepare minimal pagination.
* Previous 1 [2] 3 4 5 6 Next
@@ -103,49 +165,25 @@ class Pagination extends Arr
*/
public function minimal(string url = null, array parameters = [])
{
- var html, query, i18n, title;
+ var html;
int i;
// Prepare list
- let html = this->_tag->tagHtml("ul", parameters, ["class": "pagination"]),
- query = this->_di->{"getRequest"}()->getQuery(),
- i18n = this->_di->get("i18n");
+ let html = this->tag->tagHtml("ul", parameters, ["class": "pagination"]);
// Prepare previous
- if this->get("current") > this->get("previous") {
- query->set("page", this->get("previous"));
-
- let title = i18n ? i18n->translate("previous") : null,
- html .= "" . this->_tag->a([url, "‹", title, "query": query->all(), "rel": "prev"]) . " ";
- } else {
- let html .= "‹ ";
- }
+ let html .= this->prepareButton("previous", url, this->get("current") > this->get("previous"));
// Prepare pages
for i in range(1, this->get("pages")) {
- if i !== this->get("current") {
- query->set("page", i);
-
- let title = i18n ? i18n->translate("page: %d", [i]) : null,
- html .= "" . this->_tag->a([url, i, title, "query": query->all()]) . " ";
- } else {
- let title = i18n ? i18n->translate("current") : null,
- html .= "" . i . " ";
- }
+ let html .= this->prepareButton(i, url, i !== this->get("current"));
}
// Prepare next
- if this->get("current") < this->get("next") {
- query->set("page", this->get("next"));
-
- let title = i18n ? i18n->translate("next") : null,
- html .= "" . this->_tag->a([url, "›", title, "query": query->all(), "rel": "next"]) . " ";
- } else {
- let html .= "› ";
- }
+ let html .= this->prepareButton("next", url, this->get("current") < this->get("next"));
// Close list
- let html .= this->_tag->endTag("ul");
+ let html .= this->tag->endTag("ul");
return html;
}
@@ -160,69 +198,31 @@ class Pagination extends Arr
*/
public function basic(string url = null, array parameters = [])
{
- var html, query, i18n, title;
+ var html;
int i;
// Prepare list
- let html = this->_tag->tagHtml("ul", parameters, ["class": "pagination"]),
- query = this->_di->{"getRequest"}()->getQuery(),
- i18n = this->_di->get("i18n");
+ let html = this->tag->tagHtml("ul", parameters, ["class": "pagination"]);
// Prepare first
- if this->get("current") != this->get("first") {
- query->remove("page");
-
- let title = i18n ? i18n->translate("first") : null,
- html .= "" . this->_tag->a([url, "«", title, "query": query->all(), "rel": "first"]) . " ";
- } else {
- let html .= "« ";
- }
+ let html .= this->prepareButton("first", url, this->get("current") != this->get("first"));
// Prepare previous
- if this->get("current") > this->get("previous") {
- query->set("page", this->get("previous"));
-
- let title = i18n ? i18n->translate("previous") : null,
- html .= "" . this->_tag->a([url, "‹", title, "query": query->all(), "rel": "prev"]) . " ";
- } else {
- let html .= "‹ ";
- }
+ let html .= this->prepareButton("previous", url, this->get("current") > this->get("previous"));
// Prepare pages
for i in range(1, this->get("pages")) {
- if i !== this->get("current") {
- query->set("page", i);
-
- let title = i18n ? i18n->translate("page: %d", [i]) : null,
- html .= "" . this->_tag->a([url, i, title, "query": query->all()]) . " ";
- } else {
- let title = i18n ? i18n->translate("current") : null,
- html .= "" . i . " ";
- }
+ let html .= this->prepareButton(i, url, i !== this->get("current"));
}
// Prepare next
- if this->get("current") < this->get("next") {
- query->set("page", this->get("next"));
-
- let title = i18n ? i18n->translate("next") : null,
- html .= "" . this->_tag->a([url, "›", title, "query": query->all(), "rel": "next"]) . " ";
- } else {
- let html .= "› ";
- }
+ let html .= this->prepareButton("next", url, this->get("current") < this->get("next"));
// Prepare last
- if this->get("current") != this->get("last") {
- query->set("page", this->get("last"));
-
- let title = i18n ? i18n->translate("last") : null,
- html .= "" . this->_tag->a([url, "»", title, "query": query->all(), "rel": "last"]) . " ";
- } else {
- let html .= "» ";
- }
+ let html .= this->prepareButton("last", url, this->get("current") != this->get("last"));
// Close list
- let html .= this->_tag->endTag("ul");
+ let html .= this->tag->endTag("ul");
return html;
}
@@ -240,7 +240,7 @@ class Pagination extends Arr
*/
public function floating(string url = null, array parameters = [], int countOut = 0, int countIn = 2)
{
- var html, query, i18n, title, links, number, content;
+ var html, links, page, content;
boolean useMiddle, useN3, useN6;
var n2, n4, n5, n7, n8;
int n1, n3, n6, i;
@@ -295,65 +295,27 @@ class Pagination extends Arr
}
// Prepare list
- let html = this->_tag->tagHtml("ul", parameters, ["class": "pagination"]),
- query = this->_di->{"getRequest"}()->getQuery(),
- i18n = this->_di->get("i18n");
+ let html = this->tag->tagHtml("ul", parameters, ["class": "pagination"]);
// Prepare first
- if this->get("current") != this->get("first") {
- query->remove("page");
-
- let title = i18n ? i18n->translate("first") : null,
- html .= "" . this->_tag->a([url, "«", title, "query": query->all(), "rel": "first"]) . " ";
- } else {
- let html .= "« ";
- }
+ let html .= this->prepareButton("first", url, this->get("current") != this->get("first"));
// Prepare previous
- if this->get("current") > this->get("previous") {
- query->set("page", this->get("previous"));
-
- let title = i18n ? i18n->translate("previous") : null,
- html .= "" . this->_tag->a([url, "‹", title, "query": query->all(), "rel": "prev"]) . " ";
- } else {
- let html .= "‹ ";
- }
+ let html .= this->prepareButton("previous", url, this->get("current") > this->get("previous"));
// Prepare pages
- for number, content in links {
- if number !== this->get("current") {
- query->set("page", number);
-
- let title = i18n ? i18n->translate("page: %d", [number]) : null,
- html .= "" . this->_tag->a([url, content, title, "query": query->all(), "class": content == "…" ? "text-muted" : ""]) . " ";
- } else {
- let title = i18n ? i18n->translate("current") : null,
- html .= "" . content . " ";
- }
+ for page, content in links {
+ let html .= this->prepareButton(page, url, page !== this->get("current"), content);
}
// Prepare next
- if this->get("current") < this->get("next") {
- query->set("page", this->get("next"));
-
- let title = i18n ? i18n->translate("next") : null,
- html .= "" . this->_tag->a([url, "›", title, "query": query->all(), "rel": "next"]) . " ";
- } else {
- let html .= "› ";
- }
+ let html .= this->prepareButton("next", url, this->get("current") < this->get("next"));
// Prepare last
- if this->get("current") != this->get("last") {
- query->set("page", this->get("last"));
-
- let title = i18n ? i18n->translate("last") : null,
- html .= "" . this->_tag->a([url, "»", title, "query": query->all(), "rel": "last"]) . " ";
- } else {
- let html .= "» ";
- }
+ let html .= this->prepareButton("last", url, this->get("current") != this->get("last"));
// Close list
- let html .= this->_tag->endTag("ul");
+ let html .= this->tag->endTag("ul");
return html;
}
diff --git a/ice/session.zep b/ice/session.zep
index 130ebde2..f4ed82f9 100644
--- a/ice/session.zep
+++ b/ice/session.zep
@@ -13,7 +13,7 @@ namespace Ice;
class Session extends Arr
{
- protected _started = false;
+ protected started = false;
/**
* Session constructor. Start the session.
@@ -22,7 +22,7 @@ class Session extends Arr
{
this->start();
- //let this->_data = &_SESSION;
+ //let this->data = &_SESSION;
}
/**
@@ -34,7 +34,7 @@ class Session extends Arr
{
if !headers_sent() {
session_start();
- let this->_started = true;
+ let this->started = true;
return true;
}
return false;
@@ -47,7 +47,7 @@ class Session extends Arr
*/
public function isStarted() -> boolean
{
- return this->_started;
+ return this->started;
}
/**
@@ -77,7 +77,7 @@ class Session extends Arr
*/
public function destroy() -> boolean
{
- let this->_started = false;
+ let this->started = false;
return session_destroy();
}
@@ -93,7 +93,7 @@ class Session extends Arr
/**
* Retrieve a single key from the session.
*/
- public function get(string key, var defaultValue = null)
+ public function get(string key, var defaultValue = null, boolean required = false)
{
var value;
diff --git a/ice/tag.zep b/ice/tag.zep
index c4ab56e8..794fbedd 100644
--- a/ice/tag.zep
+++ b/ice/tag.zep
@@ -26,19 +26,20 @@ class Tag
const XHTML20 = 10;
const XHTML5 = 11;
- protected _di { get };
- protected _values { get };
- protected _docType = 5 { set };
- protected _title = null { set, get };
- protected _titleSeparator = " - " { set, get };
- protected _escape = true { set };
+ protected di { get };
+ protected values { get };
+ protected docType = 5 { set };
+ protected title = null { set, get };
+ protected titleSeparator = " - " { set, get };
+ protected meta = [] { get };
+ protected escape = true { set };
/**
* Tag constructor. Fetch Di and set it as a property.
*/
public function __construct()
{
- let this->_di = Di::$fetch();
+ let this->di = Di::$fetch();
}
/**
@@ -50,7 +51,7 @@ class Tag
*/
public function appendTitle(string title, string separator = null) -> void
{
- let this->_title = this->_title . (separator ? separator : this->_titleSeparator) . title;
+ let this->title = this->title . (separator ? separator : this->titleSeparator) . title;
}
/**
@@ -62,12 +63,33 @@ class Tag
*/
public function prependTitle(string title, string separator = null) -> void
{
- let this->_title = title . (separator ? separator : this->_titleSeparator) . this->_title;
+ let this->title = title . (separator ? separator : this->titleSeparator) . this->title;
+ }
+
+ /**
+ * Add meta tag to the container.
+ *
+ * @param array parameters
+ * @return object this
+ */
+ public function addMeta(array parameters) -> object
+ {
+ let this->meta[] = this->meta(parameters);
+
+ return this;
}
/**
* Builds a HTML INPUT[type="text"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->textField(['some', 'some_value']);
+ *
+ * // Sleet
+ * {{ text_field(['some', 'some_value', 'id' => 'some1', 'class' => 'field', 'style' => 'width: 100%']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -79,6 +101,14 @@ class Tag
/**
* Builds a HTML INPUT[type="password"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->passwordField(['pass', 'class': 'form-control']);
+ *
+ * // Sleet
+ * {{ password_field(['pass', 'placeholder': 'My secret password']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -90,6 +120,14 @@ class Tag
/**
* Builds a HTML INPUT[type="hidden"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->hiddenField(['secret', 'some value']);
+ *
+ * // Sleet
+ * {{ hidden_field(['secret', 'hidden value', 'id': 'my_id']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -101,6 +139,11 @@ class Tag
/**
* Builds a HTML INPUT[type="file"] tag.
*
+ *
+ * // Sleet
+ * {{ file_field(['some']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -112,6 +155,14 @@ class Tag
/**
* Builds a HTML INPUT[type="submit"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->submitButton(['some', 'Submit']);
+ *
+ * // Sleet
+ * {{ submit_button(['some', 'value' => 'Submit', 'id' => 'some1', 'class' => 'btn']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -123,6 +174,14 @@ class Tag
/**
* Builds a HTML BUTTON tag.
*
+ *
+ * // Phtml content
+ * $this->tag->button(['some', 'content']);
+ *
+ * // Sleet + Submit
+ * {{ button(['some', '+ ' . 'Submit', 'type' => 'button', 'id' => 'some1']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -143,6 +202,14 @@ class Tag
/**
* Builds a HTML INPUT[type="checkbox"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->checkField(['agree', 'yes']);
+ *
+ * // Sleet
+ * {{ check_field(['remember', 'on', 'checked': 'checked']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -151,6 +218,25 @@ class Tag
return this->input("checkbox", parameters);
}
+ /**
+ * Builds a HTML INPUT[type="radio"] tag.
+ *
+ *
+ * // Phtml
+ * $this->tag->radioField(['sex', 'male']);
+ *
+ * // Sleet
+ * {{ radio_field(['sex', 'female', 'checked': 'checked']) }}
+ *
+ *
+ * @param array parameters
+ * @return string
+ */
+ public function radioField(array parameters) -> string
+ {
+ return this->input("radio", parameters);
+ }
+
/**
* Builds generic INPUT tags.
*
@@ -175,6 +261,20 @@ class Tag
/**
* Builds a HTML FORM tag.
*
+ *
+ * // Phtml
+ *
* @param array parameters
* @return string
*/
@@ -198,8 +298,8 @@ class Tag
// Send to current URL if action is false
if action !== false {
- if this->_di->has("url") {
- let parameters["action"] = this->_di->get("url")->get(action);
+ if this->di->has("url") {
+ let parameters["action"] = this->di->get("url")->get(action);
}
}
}
@@ -210,6 +310,14 @@ class Tag
/**
* Builds a HTML TEXTAREA tag.
*
+ *
+ * // Phtml
+ * $this->tag->textArea(['description', 'content']);
+ *
+ * // Sleet
+ * {{ text_area(['some', 'placeholder' => 'Say something']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -237,6 +345,14 @@ class Tag
/**
* Builds HTML IMG tags.
*
+ *
+ * // Phtml
+ * $this->tag->img(['img/logo.png', 'Logo']);
+ *
+ * // Sleet
+ * {{ image(['http://example.com/img/logo.png', 'Logo', 'local' => false]) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -258,8 +374,8 @@ class Tag
fetch src, parameters[defaultParams["src"]];
}
- if this->_di->has("url") {
- let parameters["src"] = this->_di->get("url")->getStatic(src);
+ if this->di->has("url") {
+ let parameters["src"] = this->di->get("url")->getStatic(src);
}
}
@@ -273,9 +389,18 @@ class Tag
{
return this->a(parameters);
}
+
/**
* Builds a HTML A tag using framework conventions.
*
+ *
+ * // Phtml Add
+ * $this->tag->a(['post/add', 'Add', 'Add a post']);
+ *
+ * // Sleet Google
+ * {{ link_to(['http://google.com', 'Google', 'local' => false]) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -299,8 +424,8 @@ class Tag
fetch query, parameters["query"];
- if this->_di->has("url") {
- let parameters["href"] = this->_di->get("url")->get(href, query, local);
+ if this->di->has("url") {
+ let parameters["href"] = this->di->get("url")->get(href, query, local);
}
return this->tagHtml("a", parameters, defaultParams, ["text", "local", "query"], "text", true);
@@ -309,6 +434,14 @@ class Tag
/**
* Builds a LINK[rel="stylesheet"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->link(['css/app.css']);
+ *
+ * // Sleet
+ * {{ link(['http://example.com/favicon.ico', 'type' => 'image/x-icon', 'rel' => 'icon', 'local' => false]) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -331,8 +464,8 @@ class Tag
fetch href, parameters[defaultParams["href"]];
}
- if this->_di->has("url") {
- let parameters["href"] = this->_di->get("url")->getStatic(href);
+ if this->di->has("url") {
+ let parameters["href"] = this->di->get("url")->getStatic(href);
}
}
@@ -342,6 +475,14 @@ class Tag
/**
* Builds a SCRIPT[type="javascript"] tag.
*
+ *
+ * // Phtml
+ * $this->tag->script(['js/plugins.js']);
+ *
+ * // Sleet
+ * {{ script(['content' => 'alert("OK");']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -363,8 +504,8 @@ class Tag
fetch src, parameters[defaultParams["src"]];
}
- if src && this->_di->has("url") {
- let parameters["src"] = this->_di->get("url")->getStatic(src);
+ if src && this->di->has("url") {
+ let parameters["src"] = this->di->get("url")->getStatic(src);
}
}
@@ -374,6 +515,11 @@ class Tag
/**
* Builds a STYLE tag.
*
+ *
+ * // Sleet
+ * {{ style(['body { color: #444 }']) }}
+ *
+ *
* @param array parameters
* @return string
*/
@@ -389,15 +535,46 @@ class Tag
return this->tagHtml("style", parameters, defaultParams, ["content"], "content", true, true);
}
+ /**
+ * Builds a META tag.
+ *
+ *
+ * // Phtml
+ * $this->tag->meta(['ice, framework', 'keywords']);
+ *
+ * // Sleet
+ * {{ meta(['Your description', 'property': 'og:description']) }}
+ *
+ *
+ * @param array parameters
+ * @return string
+ */
+ public function meta(array parameters) -> string
+ {
+ var defaultParams;
+
+ let defaultParams = [
+ "content": 0,
+ "name": 1
+ ];
+
+ return this->tagHtml("meta", parameters, defaultParams, [], null, false, true, true);
+ }
+
/**
* Builds a SELECT tag.
*
+ *
+ * $countries = [1 => 'England', 2 => 'Poland'];
+ * $this->tag->select('country', $countries);
+ *
+ *
* @param array parameters
* @return string
*/
public function select(array parameters)
{
- var defaultParams, name, options, option, selected, tmp, value, text, group, _value, _text, _options;
+ var defaultParams, name, options, option, selected, tmp, value, text, group, subvalue, subtext, suboptions;
let defaultParams = [
"id": 0,
@@ -441,27 +618,27 @@ class Tag
let group = ["label": value];
// Create a new list of options
- let _options = [];
+ let suboptions = [];
- for _value, _text in text {
+ for subvalue, subtext in text {
// Force value to be string
- let _value = (string) _value;
+ let subvalue = (string) subvalue;
// Create a new attribute set for this option
- let option = ["value": _value];
+ let option = ["value": subvalue];
- if in_array(_value, selected) {
+ if in_array(subvalue, selected) {
// This option is selected
let option["selected"] = "selected";
}
// Change the option to the HTML string
- let option["content"] = _text,
- _options[] = this->tagHtml("option", option, [], ["content"], "content", true);
+ let option["content"] = subtext,
+ suboptions[] = this->tagHtml("option", option, [], ["content"], "content", true);
}
// Compile the options into a string
- let group["content"] = PHP_EOL . implode(PHP_EOL, _options) . PHP_EOL,
+ let group["content"] = PHP_EOL . implode(PHP_EOL, suboptions) . PHP_EOL,
options[value] = this->tagHtml("optgroup", group, [], ["content"], "content", true);
} else {
// Force value to be string
@@ -550,6 +727,11 @@ class Tag
/**
* Builds a HTML close tag.
*
+ *
+ * // Sleet
+ * {{ end_tag('form') }}
+ *
+ *
* @param string name
* @param boolean eol
* @return string
@@ -592,15 +774,15 @@ class Tag
for key, value in attrs {
if typeof key == "string" && value !== null && value !== false && !in_array(key, skip) {
- if this->_escape && this->_di->has("filter") {
- let value = this->_di->get("filter")->sanitize(value, "escape");
+ if this->escape && this->di->has("filter") {
+ let value = this->di->get("filter")->sanitize(value, "escape");
}
let code .= " " . key . "=\"" . value. "\"";
}
}
if single {
- let code .= this->_docType > self::HTML5 ? " />" : ">";
+ let code .= this->docType > self::HTML5 ? " />" : ">";
} else {
let code .= ">";
}
@@ -621,7 +803,7 @@ class Tag
return true;
} else {
// Check if there is a predefined value for it
- if isset this->_values[name] {
+ if isset this->values[name] {
return true;
}
}
@@ -643,7 +825,7 @@ class Tag
throw new Exception("Only scalar values can be assigned to UI components");
}
}
- let this->_values[id] = value;
+ let this->values[id] = value;
}
/**
@@ -662,14 +844,14 @@ class Tag
}
if merge {
- let current = this->_values;
+ let current = this->values;
if typeof current == "array" {
- let this->_values = array_merge(current, values);
+ let this->values = array_merge(current, values);
} else {
- let this->_values = values;
+ let this->values = values;
}
} else {
- let this->_values = values;
+ let this->values = values;
}
}
@@ -687,7 +869,7 @@ class Tag
// Check if there is a predefined value for it
if !fetch value, _POST[name] {
// Check if there is a post value for the item
- if !fetch value, this->_values[name] {
+ if !fetch value, this->values[name] {
return null;
}
}
@@ -698,6 +880,12 @@ class Tag
/**
* Converts texts into URL-friendly titles.
*
+ *
+ * $title = "Mess'd up --text-- just (to) stress /test/ ?our! `little` \\clean\\ url fun.ction!?-->";
+ * // 'messd-up-text-just-to-stress-test-our-little-clean-url-function'
+ * $friendly = $this->tag->friendlyTitle($title);
+ *
+ *
* @param string text
* @param string separator
* @param boolean lowercase
@@ -752,8 +940,7 @@ class Tag
*/
public function getDocType() -> string
{
-
- switch this->_docType {
+ switch this->docType {
case self::HTML32: return "" . PHP_EOL;
case self::HTML401_STRICT: return "" . PHP_EOL;
case self::HTML401_TRANSITIONAL: return "" . PHP_EOL;
diff --git a/ice/validation.zep b/ice/validation.zep
index 26f4995b..0b6d8d1b 100644
--- a/ice/validation.zep
+++ b/ice/validation.zep
@@ -13,22 +13,39 @@ use Ice\Validation\Validator;
* @license http://iceframework.org/license
* @uses Ice\Filter (if service is available)
* @uses Ice\I18n (if service is available)
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'fullName' => 'required',
+ * 'email' => 'required|email',
+ * 'repeatEmail' => 'same:email',
+ * 'about' => 'required|length:10,5000',
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Validation
{
- protected _di { get };
- protected _data = [];
- protected _rules = [] { set };
- protected _validators = [];
- protected _filters = [] { set };
- protected _labels = [] { set };
- protected _messages = [];
- protected _valid = true;
- protected _aliases = [] { set };
- protected _translate = true { set, get };
- protected _humanLabels = false { set };
- protected _defaultMessages = [
+ protected di { get };
+ protected data = [];
+ protected rules = [] { set, get };
+ protected validators = [];
+ protected filters = [] { set };
+ protected labels = [] { set };
+ protected messages = [];
+ protected valid = true;
+ protected aliases = [] { set };
+ protected translate = true { set, get };
+ protected humanLabels = false { set };
+ protected defaultMessages = [
"alnum": "Field :field must contain only letters and numbers",
"alpha": "Field :field must contain only letters",
"between": "Field :field must be within the range of :min to :max",
@@ -61,8 +78,8 @@ class Validation
*/
public function __construct(array data = [])
{
- let this->_di = Di::$fetch(),
- this->_data = data;
+ let this->di = Di::$fetch(),
+ this->data = data;
}
/**
@@ -77,7 +94,7 @@ class Validation
{
var rule;
- if !fetch rule, this->_aliases[alias] {
+ if !fetch rule, this->aliases[alias] {
let rule = "Ice\\Validation\\Validator\\" . camelize(alias);
if !class_exists(rule) {
@@ -85,12 +102,25 @@ class Validation
}
}
- let this->_rules[field][] = create_instance_params(rule, [options]);
+ let this->rules[field][] = create_instance_params(rule, [options]);
}
/**
* Add one rule.
*
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rule('email', 'required|email');
+ * $validation->rule('content', [
+ * 'length' => [
+ * 'max' => 1000,
+ * 'messageMin' => 'Too long!',
+ * 'label' => 'Desctiption'
+ * ]
+ * ]);
+ *
+ *
* @param string field
* @param mixed validators
* @param mixed options
@@ -102,7 +132,7 @@ class Validation
switch typeof validators {
case "object":
- let this->_rules[field][] = validators;
+ let this->rules[field][] = validators;
break;
case "array":
for validator, options in validators {
@@ -138,6 +168,21 @@ class Validation
/**
* Add multiple rules at once.
*
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => 'required|length:4,24|notIn:admin,user,root|unique:users',
+ * 'password' => 'required|length:5,32',
+ * 'repeatPassword' => 'same:password',
+ * 'email' => 'email',
+ * 'status' => 'required|digit|in:0,1,2',
+ * 'website' => 'url',
+ * 'title' => 'length:,100',
+ * 'age' => 'required|between:18,21',
+ * ]);
+ *
+ *
* @param array validators
* @return void
*/
@@ -161,24 +206,24 @@ class Validation
var field, rules, rule;
if count(data) {
- let this->_data = data;
+ let this->data = data;
}
// Validate the rules
- for field, rules in this->_rules {
+ for field, rules in this->rules {
for rule in rules {
if rule->validate(this, field) === false {
- let this->_valid = false;
+ let this->valid = false;
}
}
}
// Double check
- if count(this->_messages) {
- let this->_valid = false;
+ if count(this->messages) {
+ let this->valid = false;
}
- return this->_valid;
+ return this->valid;
}
/**
@@ -188,7 +233,7 @@ class Validation
*/
public function valid() -> boolean
{
- return this->_valid;
+ return this->valid;
}
/**
@@ -199,7 +244,7 @@ class Validation
*/
public function hasValue(string! field) -> boolean
{
- return isset this->_data[field];
+ return isset this->data[field];
}
/**
@@ -213,16 +258,63 @@ class Validation
{
var value, filters;
- fetch value, this->_data[field];
+ fetch value, this->data[field];
// Filter the value
- if filtered && this->_di->has("filter") && fetch filters, this->_filters[field] {
- let value = this->_di->get("filter")->sanitize(value, filters);
+ if filtered && this->di->has("filter") && fetch filters, this->filters[field] {
+ let value = this->di->get("filter")->sanitize(value, filters);
}
return value;
}
+ /**
+ * Get the values by fields.
+ * Values are automatically filtered out if filters have been setted.
+ *
+ *
+ * // Get value for one field
+ * $validation->getValues('password');
+ *
+ * // Get values for multiple fields
+ * $validation->getValues(['fullName', 'about']);
+ *
+ * // Get all values
+ * $validation->getValues();
+ *
+ *
+ * @param mixed fields The data keys
+ * @param boolean filtered Get the filtered value or original
+ * @return mixed
+ */
+ public function getValues(var fields = null, boolean filtered = true)
+ {
+ var data, field;
+
+ let data = [];
+
+ if fields === null {
+ for field, _ in this->data {
+ let data[field] = this->getValue(field, filtered);
+ }
+ } else {
+ switch typeof fields {
+ case "array":
+ for field in fields {
+ if isset this->data[field] {
+ let data[field] = this->getValue(field, filtered);
+ }
+ }
+ break;
+ case "string":
+ let data = this->getValue(fields, filtered);
+ break;
+ }
+ }
+
+ return data;
+ }
+
/**
* Get the label of a field.
* Humanize a label if humanLabels attribute and filter service is available
@@ -234,10 +326,10 @@ class Validation
{
var label;
- if !fetch label, this->_labels[field] {
+ if !fetch label, this->labels[field] {
// Humanize the field
- if this->_humanLabels && this->_di->has("filter") {
- let label = this->_di->get("filter")->sanitize(field, "human");
+ if this->humanLabels && this->di->has("filter") {
+ let label = this->di->get("filter")->sanitize(field, "human");
} else {
let label = field;
}
@@ -254,7 +346,7 @@ class Validation
*/
public function setDefaultMessages(array messages = []) -> void
{
- let this->_defaultMessages = array_merge(this->_defaultMessages, messages);
+ let this->defaultMessages = array_merge(this->defaultMessages, messages);
}
/**
@@ -267,8 +359,8 @@ class Validation
{
var message;
- if !fetch message, this->_defaultMessages[type] {
- let message = this->_defaultMessages["default"];
+ if !fetch message, this->defaultMessages[type] {
+ let message = this->defaultMessages["default"];
}
return message;
@@ -283,7 +375,7 @@ class Validation
*/
public function addMessage(string! field, string message) -> void
{
- let this->_messages[field][] = message;
+ let this->messages[field][] = message;
}
/**
@@ -293,6 +385,6 @@ class Validation
*/
public function getMessages() ->
{
- return new Arr(this->_messages);
+ return new Arr(this->messages);
}
}
diff --git a/ice/validation/validator.zep b/ice/validation/validator.zep
index ef2c7c51..7e20e649 100644
--- a/ice/validation/validator.zep
+++ b/ice/validation/validator.zep
@@ -15,7 +15,7 @@ use Ice\Validation;
abstract class Validator
{
- protected _options = [];
+ protected options = [];
const ALL = 0;
const NUMERIC = 1;
@@ -28,7 +28,7 @@ abstract class Validator
*/
public function __construct(array options = [])
{
- let this->_options = options;
+ let this->options = options;
}
/**
@@ -47,7 +47,7 @@ abstract class Validator
*/
public function has(var key) -> boolean
{
- return isset this->_options[key];
+ return isset this->options[key];
}
/**
@@ -61,7 +61,7 @@ abstract class Validator
{
var value;
- if fetch value, this->_options[key] {
+ if fetch value, this->options[key] {
return value;
}
@@ -77,7 +77,7 @@ abstract class Validator
*/
public function set(var key, var value)
{
- let this->_options[key] = value;
+ let this->options[key] = value;
}
/**
@@ -90,7 +90,7 @@ abstract class Validator
{
var key, value;
- for key, value in this->_options {
+ for key, value in this->options {
switch keys {
case self::NUMERIC:
if typeof key == "integer" {
diff --git a/ice/validation/validator/alnum.zep b/ice/validation/validator/alnum.zep
index d9ba595b..d1e4506a 100644
--- a/ice/validation/validator/alnum.zep
+++ b/ice/validation/validator/alnum.zep
@@ -12,6 +12,25 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => 'alnum',
+ * 'prefix' => [
+ * 'alnum' => [
+ * 'message' => 'Field :field must be alphanumeric'
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Alnum extends Validator
{
diff --git a/ice/validation/validator/alpha.zep b/ice/validation/validator/alpha.zep
index 43819290..b68754cf 100644
--- a/ice/validation/validator/alpha.zep
+++ b/ice/validation/validator/alpha.zep
@@ -12,6 +12,25 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => 'alpha',
+ * 'prefix' => [
+ * 'alpha' => [
+ * 'message' => 'Field :field must be alpha'
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Alpha extends Validator
{
diff --git a/ice/validation/validator/between.zep b/ice/validation/validator/between.zep
index 1ee9cad5..2fc66f0b 100644
--- a/ice/validation/validator/between.zep
+++ b/ice/validation/validator/between.zep
@@ -12,12 +12,33 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'age' => 'between:18,21',
+ * 'height' => [
+ * 'between' => [
+ * 'min' => 180,
+ * 'max' => 190,
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Between extends Validator
{
/**
* Validate the validator
+ * Options: label, min, max, message
*
* @param Validation validation
* @param string field
diff --git a/ice/validation/validator/digit.zep b/ice/validation/validator/digit.zep
index be1f34ab..c7a6e577 100644
--- a/ice/validation/validator/digit.zep
+++ b/ice/validation/validator/digit.zep
@@ -12,6 +12,20 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'sort' => 'digit'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Digit extends Validator
{
diff --git a/ice/validation/validator/email.zep b/ice/validation/validator/email.zep
index 90125254..0b090d2a 100644
--- a/ice/validation/validator/email.zep
+++ b/ice/validation/validator/email.zep
@@ -12,6 +12,20 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'e_mail' => 'email'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Email extends Validator
{
diff --git a/ice/validation/validator/file.zep b/ice/validation/validator/file.zep
index 9d2dd023..85a1d2ad 100644
--- a/ice/validation/validator/file.zep
+++ b/ice/validation/validator/file.zep
@@ -13,12 +13,35 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'picture' => [
+ * 'file' => [
+ * 'maxSize' => '6M',
+ * 'allowedTypes' => ['image/jpeg', 'image/png'],
+ * 'minResolution' => '400x300,
+ * 'maxResolution' => '1600x1200',
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_FILES);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class File extends Validator
{
/**
* Validate the validator
+ * Options: label, messageIniSize, allowEmpty, messageEmpty, messageValid, maxSize, messageSize, allowedTypes, messageType
+ * minResolution, maxResolution, messageMinResolution, messageMaxResolution
*
* @param Validation validation
* @param string field
diff --git a/ice/validation/validator/in.zep b/ice/validation/validator/in.zep
index b5b87c16..e963691b 100644
--- a/ice/validation/validator/in.zep
+++ b/ice/validation/validator/in.zep
@@ -13,12 +13,27 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'status' => 'in:1,2,3,4'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class $In extends Validator
{
/**
* Validate the validator
+ * Options: label, values, message
*
* @param Validation validation
* @param string field
diff --git a/ice/validation/validator/length.zep b/ice/validation/validator/length.zep
index 74bdede5..062266e7 100644
--- a/ice/validation/validator/length.zep
+++ b/ice/validation/validator/length.zep
@@ -12,12 +12,34 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'title' => 'length:10,100',
+ * 'content' => [
+ * 'length' => [
+ * 'max' => 1000,
+ * 'messageMin' => 'Too long!',
+ * 'label' => 'Desctiption'
+ * ]
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Length extends Validator
{
/**
* Validate the validator
+ * Options: label, min, max, messageMin, messageMax
*
* @param Validation validation
* @param string field
diff --git a/ice/validation/validator/notin.zep b/ice/validation/validator/notin.zep
index 1ead3050..76b01c53 100644
--- a/ice/validation/validator/notin.zep
+++ b/ice/validation/validator/notin.zep
@@ -13,12 +13,34 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'status' => 'notIn:unactive,removed',
+ * 'username' => [
+ * 'notIn' => [
+ * 'values' => ['about', 'admin', 'user', 'root'],
+ * 'message' => 'Field :field is reserved',
+ * 'label' => 'Nick'
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class NotIn extends Validator
{
/**
* Validate the validator
+ * Options: label, values, message
*
* @param Validation validation
* @param string field
diff --git a/ice/validation/validator/regex.zep b/ice/validation/validator/regex.zep
index 5248a92d..ee80f9ca 100644
--- a/ice/validation/validator/regex.zep
+++ b/ice/validation/validator/regex.zep
@@ -12,12 +12,31 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => [
+ * 'regex' => [
+ * 'pattern' => '/[a-zA-Z][a-zA-Z0-9_-]{3,}/'
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Regex extends Validator
{
/**
* Validate the validator
+ * Options: label, pattern, message
*
* @param Validation validation
* @param string field
diff --git a/ice/validation/validator/required.zep b/ice/validation/validator/required.zep
index 4f8119d4..ae733a44 100644
--- a/ice/validation/validator/required.zep
+++ b/ice/validation/validator/required.zep
@@ -12,6 +12,20 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'username' => 'required'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Required extends Validator
{
diff --git a/ice/validation/validator/same.zep b/ice/validation/validator/same.zep
index b39d0f3e..c61d86fa 100644
--- a/ice/validation/validator/same.zep
+++ b/ice/validation/validator/same.zep
@@ -12,6 +12,21 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'email' => 'required|email',
+ * 'repeatEmail' => 'same:email'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Same extends Validator
{
diff --git a/ice/validation/validator/unique.zep b/ice/validation/validator/unique.zep
index cb5a3f79..f45a74be 100644
--- a/ice/validation/validator/unique.zep
+++ b/ice/validation/validator/unique.zep
@@ -13,12 +13,32 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'userName' => [
+ * 'unique' => [
+ * 'from' => 'users',
+ * 'custom' => 'username'
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Unique extends Validator
{
/**
* Validate the validator
+ * Options: label, from, custom, except, message
*
* @param Validation validation
* @param string field
@@ -26,7 +46,7 @@ class Unique extends Validator
*/
public function validate( validation, string! field) -> boolean
{
- var value, label, message, i18n, replace, di, db, from, custom, except, result, id;
+ var value, label, message, i18n, replace, di, db, from, custom, except, tmp, caseInsensitive, result, id;
let value = validation->getValue(field);
@@ -35,7 +55,7 @@ class Unique extends Validator
}
let di = Di::$fetch(),
- db = di->{"getDb"}();
+ db = di->get("db", null, true);
if this->has(0) {
let from = this->get(0);
@@ -60,9 +80,27 @@ class Unique extends Validator
let except = this->get("except");
}
+ // Case insensitive
+ if this->has(3) {
+ let caseInsensitive = this->get(3);
+ } else {
+ let caseInsensitive = this->get("caseInsensitive");
+ }
+
+ if caseInsensitive {
+ let tmp = value;
+
+ if db->getType() == "NOSQL" {
+ let value = new \MongoRegex("/^" . tmp . "$/i");
+ } else {
+ // TODO: LOWER column name
+ let value = strtolower(tmp);
+ }
+ }
+
if except {
- let id = ["!=": except],
- result = db->findOne(from, [custom: value, "id": id]);
+ let id = ["!=": db->getIdValue(except)],
+ result = db->findOne(from, [custom: value, db->getId(): id]);
} else {
let result = db->findOne(from, [custom: value]);
}
diff --git a/ice/validation/validator/url.zep b/ice/validation/validator/url.zep
index 1bd7f32b..029dda4d 100644
--- a/ice/validation/validator/url.zep
+++ b/ice/validation/validator/url.zep
@@ -12,6 +12,20 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'website' => 'url'
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Url extends Validator
{
diff --git a/ice/validation/validator/with.zep b/ice/validation/validator/with.zep
index ae673838..919a1596 100644
--- a/ice/validation/validator/with.zep
+++ b/ice/validation/validator/with.zep
@@ -13,12 +13,31 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'repeatPassword' => [
+ * 'with' => [
+ * 'fields' => ['password'],
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class With extends Validator
{
/**
* Validate the validator
+ * Options: label, fields, message
*
* @param Validation validation
* @param string field
diff --git a/ice/validation/validator/without.zep b/ice/validation/validator/without.zep
index a9ca17b6..ab8aab9c 100644
--- a/ice/validation/validator/without.zep
+++ b/ice/validation/validator/without.zep
@@ -13,12 +13,31 @@ use Ice\Validation\Validator;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ *
+ *
+ * $validation = new Ice\Validation();
+ *
+ * $validation->rules([
+ * 'password' => [
+ * 'without' => [
+ * 'fields' => ['newPassword'],
+ * ],
+ * ]
+ * ]);
+ *
+ * $valid = $validation->validate($_POST);
+ *
+ * if (!$valid) {
+ * $messages = $validation->getMessages();
+ * }
+ *
*/
class Without extends Validator
{
/**
* Validate the validator
+ * Options: label, fields, message
*
* @param Validation validation
* @param string field
diff --git a/ice/version.zep b/ice/version.zep
index 76767367..7c51feb8 100644
--- a/ice/version.zep
+++ b/ice/version.zep
@@ -9,6 +9,7 @@ namespace Ice;
* @author Ice Team
* @copyright (c) 2014-2015 Ice Team
* @license http://iceframework.org/license
+ * @see http://semver.org (Semantic Versioning 2.0.0)
*/
class Version
{
@@ -18,74 +19,84 @@ class Version
const BETA = 2;
const RC = 3;
const STABLE = 4;
+ // Don't forget to update config.json and run zephir fullclean
+ const MAJOR = 1;
+ const MINOR = 0;
+ const PATCH = 35;
+ const STAGE = self::STABLE;
+ const BUILD = 1;
/**
- * Get array version of the framework.
+ * Get version array.
*
* @return array
*/
public static function current() -> array
{
- // Don't forget to update config.json and run zephir fullclean
return [
- "major": 1,
- "minor": 0,
- "patch": 6,
- "stage": Version::STABLE,
- "build": 1
+ "major": self::MAJOR,
+ "minor": self::MINOR,
+ "patch": self::PATCH,
+ "stage": self::STAGE,
+ "build": self::BUILD
];
}
/**
- * Get version of the framework.
+ * Get version string.
*
* 1.0.0-dev
- * 1.0.0-alpha3
- * 1.0.0-beta2
- * 1.0.0-rc5
+ * 1.0.0-alpha.3
+ * 1.0.0-beta.2
+ * 1.0.0-rc.5
* 1.0.0
*
* @return string
*/
public static function get() -> string
{
- var current, suffix;
+ var suffix;
- let current = self::current();
-
- switch current["stage"] {
- case Version::DEV:
+ switch self::STAGE {
+ case self::DEV:
let suffix = "-dev";
break;
- case Version::ALPHA:
- let suffix = "-alpha" . current["build"];
+ case self::ALPHA:
+ let suffix = "-alpha." . self::BUILD;
break;
- case Version::BETA:
- let suffix = "-beta" . current["build"];
+ case self::BETA:
+ let suffix = "-beta." . self::BUILD;
break;
- case Version::RC:
- let suffix = "-RC" . current["build"];
+ case self::RC:
+ let suffix = "-rc." . self::BUILD;
break;
- case Version::STABLE:
+ case self::STABLE:
let suffix = "";
break;
}
- return current["major"] . "." . current["minor"] . "." . current["patch"] . suffix;
+ return self::MAJOR . "." . self::MINOR . "." . self::PATCH . suffix;
}
/**
- * Get version id of the framework.
- * [major][minor(2 digits)][patch (2 digits)][stage][build], eg. id for 1.4.2-rc5 is 1040235
+ * Get version id.
*
- * @return string
+ * [major][minor(2 digits)][patch (2 digits)][stage][build]
+ * eg. id for 1.4.12-rc.5 is 1041235
+ *
+ * @return int
*/
- public static function id() -> string
+ public static function id() -> int
{
- var current;
+ var id;
- let current = self::current();
+ let id =
+ self::MAJOR .
+ sprintf("%02s", self::MINOR) .
+ sprintf("%02s", self::PATCH) .
+ self::STAGE .
+ self::BUILD;
- return current["major"] . sprintf("%02s", current["minor"]) . sprintf("%02s", current["patch"]) . current["stage"] . current["build"];
+ return (int) id;
}
}
diff --git a/tests/ci/install_zephir.sh b/tests/ci/install_zephir.sh
new file mode 100755
index 00000000..467d1e34
--- /dev/null
+++ b/tests/ci/install_zephir.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+cd vendor/phalcon/zephir
+cd parser
+rm -f *.o *.lo
+
+#Compile lemon
+if [ ! -f lemon ]; then
+ gcc -w lemon.c -o lemon
+fi
+
+TEST=`re2c -v`
+if [ $? != 2 ]; then
+ echo "error: re2c is not installed"
+ exit 2
+fi
+
+re2c -o scanner.c scanner.re && ./lemon -s parser.lemon && cat base.c >> parser.c
+if [ ! -f parser.c ]; then
+ echo "error: re2c is not installed"
+ exit 2
+fi
+
+sed s/"\#line"/"\/\/"/g scanner.c > xx && mv -f xx scanner.c
+sed s/"#line"/"\/\/"/g parser.c > xx && mv -f xx parser.c
+gcc -Wl,-rpath $TRAVIS_BUILD_DIR/build/lib \
+ -I/usr/local/include \
+ -L/usr/local/lib \
+ -L/opt/local/lib \
+ -I$TRAVIS_BUILD_DIR/build/include \
+ -L$TRAVIS_BUILD_DIR/build/lib \
+ -g3 -O0 -w parser.c scanner.c -ljson-c -o ../bin/zephir-parser
+
+cd ..
+
+ZEPHIRDIR="$( cd "$( dirname . )" && pwd )"
+sed "s#%ZEPHIRDIR%#$ZEPHIRDIR#g" bin/zephir > bin/zephir-cmd
+chmod 755 bin/zephir-cmd
+
+if [ ! -d ~/bin ]; then
+ mkdir ~/bin
+fi
+
+cp bin/zephir-cmd ~/bin/zephir
+rm bin/zephir-cmd