diff --git a/.travis.yml b/.travis.yml index 122f96de..38c435e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,24 +10,32 @@ matrix: allow_failures: - php: 7.0 +sudo: false + before_install: - composer install --prefer-source --no-scripts before_script: - git submodule --quiet update --init --recursive - - (cd vendor/phalcon/zephir; ./unit-tests/ci/before_install.sh; ./install) + - (cd vendor/phalcon/zephir; ./unit-tests/ci/before_install.sh) + - (./tests/ci/install_zephir.sh) - (./vendor/bin/zephir fullclean; ./vendor/bin/zephir generate) - - (cd ext; export CFLAGS="-g3 -O1 -fno-delete-null-pointer-checks -Wall -fvisibility=hidden -DZEPHIR_RELEASE=1"; phpize && ./configure --enable-ice && make -j2 && sudo make install && phpenv config-add ../tests/ci/ice.ini) + - (cd ext; export CFLAGS="-g3 -O1 -fno-delete-null-pointer-checks -Wall -fvisibility=hidden -DZEPHIR_RELEASE=1"; phpize && ./configure --enable-ice && make -j2 && make install && phpenv config-add ../tests/ci/ice.ini) - ulimit -c unlimited || true - phpenv config-rm xdebug.ini script: - - valgrind --read-var-info=yes --error-exitcode=1 --fullpath-after= --track-origins=yes --leak-check=full ./vendor/bin/phpunit --configuration tests/phpunit.xml --testsuite=all + - ./vendor/bin/phpunit --configuration tests/phpunit.xml --testsuite=all after_failure: - - sudo apt-get -qq install gdb - gdb -quiet -command=tests/ci/gdb --args $(phpenv which php) vendor/bin/phpunit --debug --colors --configuration tests/phpunit.xml --testsuite=all notifications: email: - - info@iceframework.org \ No newline at end of file + - info@iceframework.org + +addons: + apt: + packages: + - gdb + - re2c \ No newline at end of file diff --git a/README.md b/README.md index 25e689de..8d7854c7 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ There are two ways to compile Ice framework*: #### Compile from `/ext`: Clone and install from GitHub: ```sh -git clone https://github.com/ice/framework.git +git clone --depth=1 https://github.com/ice/framework.git cd framework/ext/ sudo ./install ``` @@ -124,4 +124,4 @@ sudo yum install php-devel pcre-devel gcc make re2c Ice is open-sourced software licensed under the New BSD License. See the LICENSE file for more information. *** -Copyright (c) 2014-2015 Ice Team. \ No newline at end of file +Copyright (c) 2014-2015 Ice Team. diff --git a/composer.json b/composer.json index 9ab0cde8..da767608 100644 --- a/composer.json +++ b/composer.json @@ -14,11 +14,11 @@ "php": ">=5.4" }, "require-dev": { - "phpunit/phpunit": "~4.5.0", - "phalcon/zephir": "dev-master" + "phpunit/phpunit": ">=4.7.5", + "phalcon/zephir": "dev-master#8a9585bd88b0da27f424ccb8a0528d67b5dd9e08" }, "scripts": { "post-install-cmd": ["./install"], "post-update-cmd": ["./install"] } -} \ No newline at end of file +} diff --git a/config.json b/config.json index 6e7c0b61..1c70d7ff 100644 --- a/config.json +++ b/config.json @@ -3,7 +3,7 @@ "name": "ice", "description": "Simple and fast PHP framework delivered as C-extension.
Copyright (c) 2014-2015 Ice Team.", "author": "Ice Team", - "version": "1.0.6", + "version": "1.0.35", "verbose": false, "info": [ { diff --git a/ext/clean b/ext/clean index ecb9ef5f..ae279a04 100755 --- a/ext/clean +++ b/ext/clean @@ -4,5 +4,8 @@ done for i in `find . -name "*.lo"`; do rm -f $i done +for i in `find . -name "*.gch"`; do + rm -f $i +done make clean phpize --clean diff --git a/ext/config.m4 b/ext/config.m4 index 7e4547cc..35ff0fd1 100644 --- a/ext/config.m4 +++ b/ext/config.m4 @@ -9,10 +9,32 @@ if test "$PHP_ICE" = "yes"; then fi AC_DEFINE(HAVE_ICE, 1, [Whether you have Ice]) - ice_sources="ice.c kernel/main.c kernel/memory.c kernel/exception.c kernel/hash.c kernel/debug.c kernel/backtrace.c kernel/object.c kernel/array.c kernel/extended/array.c kernel/string.c kernel/fcall.c kernel/require.c kernel/file.c kernel/operators.c kernel/concat.c kernel/variables.c kernel/filter.c kernel/iterator.c kernel/time.c kernel/exit.c ice/arr.zep.c - ice/auth.zep.c + ice_sources="ice.c kernel/main.c kernel/memory.c kernel/exception.c kernel/hash.c kernel/debug.c kernel/backtrace.c kernel/object.c kernel/array.c kernel/extended/array.c kernel/string.c kernel/fcall.c kernel/extended/fcall.c kernel/require.c kernel/file.c kernel/operators.c kernel/math.c kernel/concat.c kernel/variables.c kernel/filter.c kernel/iterator.c kernel/time.c kernel/exit.c ice/validation/validator.zep.c + ice/arr.zep.c + ice/i18n/plural/pluralinterface.zep.c + ice/di/access.zep.c + ice/mvc/model.zep.c + ice/auth/social/socialinterface.zep.c + ice/auth/social/adapter.zep.c + ice/mvc/view/engine/engineinterface.zep.c ice/auth/driver.zep.c ice/auth/driver/driverinterface.zep.c + ice/config.zep.c + ice/db/dbinterface.zep.c + ice/dispatcher.zep.c + ice/log/loggerinterface.zep.c + ice/mvc/route/datagenerator/datageneratorinterface.zep.c + ice/mvc/route/dispatcher/dispatcherinterface.zep.c + ice/mvc/view/engine.zep.c + ice/http/response/headersinterface.zep.c + ice/http/response/responseinterface.zep.c + ice/log/driver.zep.c + ice/mvc/route/datagenerator/regex.zep.c + ice/mvc/route/dispatcher/regex.zep.c + ice/mvc/route/parser/parserinterface.zep.c + ice/mvc/view/viewinterface.zep.c + ice/assets.zep.c + ice/auth.zep.c ice/auth/driver/file.zep.c ice/auth/driver/model.zep.c ice/auth/driver/model/roles.zep.c @@ -21,26 +43,21 @@ if test "$PHP_ICE" = "yes"; then ice/auth/driver/model/users/social.zep.c ice/auth/driver/model/users/tokens.zep.c ice/auth/social.zep.c - ice/auth/social/adapter.zep.c ice/auth/social/facebook.zep.c ice/auth/social/google.zep.c - ice/auth/social/socialinterface.zep.c ice/auth/social/twitter.zep.c ice/cli/console.zep.c ice/cli/dispatcher.zep.c ice/cli/router.zep.c ice/cli/task.zep.c - ice/config.zep.c ice/config/ini.zep.c + ice/config/json.zep.c ice/cookies.zep.c ice/crypt.zep.c ice/db.zep.c - ice/db/dbinterface.zep.c ice/db/driver/mongo.zep.c ice/db/driver/pdo.zep.c ice/di.zep.c - ice/di/access.zep.c - ice/dispatcher.zep.c ice/dump.zep.c ice/exception.zep.c ice/filter.zep.c @@ -51,8 +68,6 @@ if test "$PHP_ICE" = "yes"; then ice/http/request/requestinterface.zep.c ice/http/response.zep.c ice/http/response/headers.zep.c - ice/http/response/headersinterface.zep.c - ice/http/response/responseinterface.zep.c ice/i18n.zep.c ice/i18n/plural/arabic.zep.c ice/i18n/plural/balkan.zep.c @@ -60,47 +75,35 @@ if test "$PHP_ICE" = "yes"; then ice/i18n/plural/french.zep.c ice/i18n/plural/none.zep.c ice/i18n/plural/one.zep.c - ice/i18n/plural/pluralinterface.zep.c ice/i18n/plural/polish.zep.c ice/i18n/plural/romanian.zep.c ice/i18n/plural/two.zep.c ice/i18n/plural/zero.zep.c ice/loader.zep.c ice/log.zep.c - ice/log/driver.zep.c ice/log/driver/file.zep.c - ice/log/loggerinterface.zep.c ice/mvc/app.zep.c ice/mvc/controller.zep.c ice/mvc/dispatcher.zep.c - ice/mvc/model.zep.c ice/mvc/moduleinterface.zep.c ice/mvc/route.zep.c ice/mvc/route/collector.zep.c - ice/mvc/route/datagenerator/datageneratorinterface.zep.c ice/mvc/route/datagenerator/groupcount.zep.c - ice/mvc/route/datagenerator/regex.zep.c - ice/mvc/route/dispatcher/dispatcherinterface.zep.c ice/mvc/route/dispatcher/groupcount.zep.c - ice/mvc/route/dispatcher/regex.zep.c - ice/mvc/route/parser/parserinterface.zep.c ice/mvc/route/parser/std.zep.c ice/mvc/router.zep.c + ice/mvc/service.zep.c ice/mvc/url.zep.c ice/mvc/view.zep.c - ice/mvc/view/engine.zep.c - ice/mvc/view/engine/engineinterface.zep.c ice/mvc/view/engine/php.zep.c ice/mvc/view/engine/sleet.zep.c ice/mvc/view/engine/sleet/compiler.zep.c ice/mvc/view/engine/sleet/parser.zep.c - ice/mvc/view/viewinterface.zep.c ice/pagination.zep.c ice/session.zep.c ice/tag.zep.c ice/text.zep.c ice/validation.zep.c - ice/validation/validator.zep.c ice/validation/validator/alnum.zep.c ice/validation/validator/alpha.zep.c ice/validation/validator/between.zep.c diff --git a/ext/config.w32 b/ext/config.w32 index dbf89c06..361cdf30 100644 --- a/ext/config.w32 +++ b/ext/config.w32 @@ -2,37 +2,43 @@ ARG_ENABLE("ice", "enable ice", "no"); if (PHP_ICE != "no") { EXTENSION("ice", "ice.c", null, "-I"+configure_module_dirname); - ADD_SOURCES(configure_module_dirname + "/kernel", "main.c memory.c exception.c hash.c debug.c backtrace.c object.c array.c string.c fcall.c require.c file.c operators.c concat.c variables.c filter.c iterator.c exit.c time.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/kernel/extended", "array.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/kernel", "main.c memory.c exception.c hash.c debug.c backtrace.c object.c array.c string.c fcall.c require.c file.c operators.c math.c concat.c variables.c filter.c iterator.c exit.c time.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/kernel/extended", "array.c fcall.c", "ice"); + /* PCRE is always included on WIN32 */ + AC_DEFINE("ZEPHIR_USE_PHP_PCRE", 1, "Whether PHP pcre extension is present at compile time"); + if (PHP_JSON != "no") { + ADD_EXTENSION_DEP("ice", "json"); + AC_DEFINE("ZEPHIR_USE_PHP_JSON", 1, "Whether PHP json extension is present at compile time"); + } - ADD_SOURCES(configure_module_dirname + "/ice", "arr.zep.c auth.zep.c config.zep.c cookies.zep.c crypt.zep.c db.zep.c di.zep.c dispatcher.zep.c dump.zep.c exception.zep.c filter.zep.c flash.zep.c i18n.zep.c loader.zep.c log.zep.c pagination.zep.c session.zep.c tag.zep.c text.zep.c validation.zep.c version.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/validation", "validator.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice", "arr.zep.c config.zep.c dispatcher.zep.c assets.zep.c auth.zep.c cookies.zep.c crypt.zep.c db.zep.c di.zep.c dump.zep.c exception.zep.c filter.zep.c flash.zep.c i18n.zep.c loader.zep.c log.zep.c pagination.zep.c session.zep.c tag.zep.c text.zep.c validation.zep.c version.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/i18n/plural", "pluralinterface.zep.c arabic.zep.c balkan.zep.c czech.zep.c french.zep.c none.zep.c one.zep.c polish.zep.c romanian.zep.c two.zep.c zero.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/di", "access.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/mvc", "model.zep.c app.zep.c controller.zep.c dispatcher.zep.c moduleinterface.zep.c route.zep.c router.zep.c service.zep.c url.zep.c view.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/auth/social", "socialinterface.zep.c adapter.zep.c facebook.zep.c google.zep.c twitter.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/mvc/view/engine", "engineinterface.zep.c php.zep.c sleet.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/auth", "driver.zep.c social.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/auth/driver", "driverinterface.zep.c file.zep.c model.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/db", "dbinterface.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/log", "loggerinterface.zep.c driver.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/mvc/route/datagenerator", "datageneratorinterface.zep.c regex.zep.c groupcount.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/mvc/route/dispatcher", "dispatcherinterface.zep.c regex.zep.c groupcount.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/mvc/view", "engine.zep.c viewinterface.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/http/response", "headersinterface.zep.c responseinterface.zep.c headers.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/mvc/route/parser", "parserinterface.zep.c std.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/auth/driver/model", "roles.zep.c users.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/auth/driver/model/roles", "users.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/auth/driver/model/users", "social.zep.c tokens.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/auth/social", "adapter.zep.c facebook.zep.c google.zep.c socialinterface.zep.c twitter.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/cli", "console.zep.c dispatcher.zep.c router.zep.c task.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/config", "ini.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/db", "dbinterface.zep.c", "ice"); + ADD_SOURCES(configure_module_dirname + "/ice/config", "ini.zep.c json.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/db/driver", "mongo.zep.c pdo.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/di", "access.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/filter", "css.zep.c js.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/http", "request.zep.c response.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/http/request", "requestinterface.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/http/response", "headers.zep.c headersinterface.zep.c responseinterface.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/i18n/plural", "arabic.zep.c balkan.zep.c czech.zep.c french.zep.c none.zep.c one.zep.c pluralinterface.zep.c polish.zep.c romanian.zep.c two.zep.c zero.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/log", "driver.zep.c loggerinterface.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/log/driver", "file.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/mvc", "app.zep.c controller.zep.c dispatcher.zep.c model.zep.c moduleinterface.zep.c route.zep.c router.zep.c url.zep.c view.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/mvc/route", "collector.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/mvc/route/datagenerator", "datageneratorinterface.zep.c groupcount.zep.c regex.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/mvc/route/dispatcher", "dispatcherinterface.zep.c groupcount.zep.c regex.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/mvc/route/parser", "parserinterface.zep.c std.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/mvc/view", "engine.zep.c viewinterface.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/mvc/view/engine", "engineinterface.zep.c php.zep.c sleet.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/mvc/view/engine/sleet", "compiler.zep.c parser.zep.c", "ice"); - ADD_SOURCES(configure_module_dirname + "/ice/validation", "validator.zep.c", "ice"); ADD_SOURCES(configure_module_dirname + "/ice/validation/validator", "alnum.zep.c alpha.zep.c between.zep.c digit.zep.c email.zep.c file.zep.c in.zep.c length.zep.c notin.zep.c regex.zep.c required.zep.c same.zep.c unique.zep.c url.zep.c with.zep.c without.zep.c", "ice"); ADD_FLAG("CFLAGS_ICE", "/D ZEPHIR_RELEASE"); } diff --git a/ext/ice.c b/ext/ice.c index d761b235..439e5b8c 100644 --- a/ext/ice.c +++ b/ext/ice.c @@ -20,6 +20,7 @@ #include #include +#include "kernel/globals.h" #include "kernel/main.h" #include "kernel/fcall.h" #include "kernel/memory.h" @@ -46,12 +47,13 @@ zend_class_entry *ice_di_access_ce; zend_class_entry *ice_mvc_model_ce; zend_class_entry *ice_auth_social_adapter_ce; zend_class_entry *ice_auth_driver_ce; +zend_class_entry *ice_config_ce; zend_class_entry *ice_dispatcher_ce; zend_class_entry *ice_mvc_view_engine_ce; -zend_class_entry *ice_config_ce; zend_class_entry *ice_log_driver_ce; zend_class_entry *ice_mvc_route_datagenerator_regex_ce; zend_class_entry *ice_mvc_route_dispatcher_regex_ce; +zend_class_entry *ice_assets_ce; zend_class_entry *ice_auth_ce; zend_class_entry *ice_auth_driver_file_ce; zend_class_entry *ice_auth_driver_model_ce; @@ -69,6 +71,7 @@ zend_class_entry *ice_cli_dispatcher_ce; zend_class_entry *ice_cli_router_ce; zend_class_entry *ice_cli_task_ce; zend_class_entry *ice_config_ini_ce; +zend_class_entry *ice_config_json_ce; zend_class_entry *ice_cookies_ce; zend_class_entry *ice_crypt_ce; zend_class_entry *ice_db_ce; @@ -107,6 +110,7 @@ zend_class_entry *ice_mvc_route_datagenerator_groupcount_ce; zend_class_entry *ice_mvc_route_dispatcher_groupcount_ce; zend_class_entry *ice_mvc_route_parser_std_ce; zend_class_entry *ice_mvc_router_ce; +zend_class_entry *ice_mvc_service_ce; zend_class_entry *ice_mvc_url_ce; zend_class_entry *ice_mvc_view_ce; zend_class_entry *ice_mvc_view_engine_php_ce; @@ -138,6 +142,10 @@ zend_class_entry *ice_version_ce; ZEND_DECLARE_MODULE_GLOBALS(ice) +PHP_INI_BEGIN() + +PHP_INI_END() + static PHP_MINIT_FUNCTION(ice) { #if PHP_VERSION_ID < 50500 @@ -155,7 +163,7 @@ static PHP_MINIT_FUNCTION(ice) setlocale(LC_ALL, "C"); #endif - + REGISTER_INI_ENTRIES(); ZEPHIR_INIT(Ice_I18n_Plural_PluralInterface); ZEPHIR_INIT(Ice_Auth_Social_SocialInterface); ZEPHIR_INIT(Ice_Mvc_View_Engine_EngineInterface); @@ -176,12 +184,13 @@ static PHP_MINIT_FUNCTION(ice) ZEPHIR_INIT(Ice_Mvc_Model); ZEPHIR_INIT(Ice_Auth_Social_Adapter); ZEPHIR_INIT(Ice_Auth_Driver); + ZEPHIR_INIT(Ice_Config); ZEPHIR_INIT(Ice_Dispatcher); ZEPHIR_INIT(Ice_Mvc_View_Engine); - ZEPHIR_INIT(Ice_Config); ZEPHIR_INIT(Ice_Log_Driver); ZEPHIR_INIT(Ice_Mvc_Route_DataGenerator_Regex); ZEPHIR_INIT(Ice_Mvc_Route_Dispatcher_Regex); + ZEPHIR_INIT(Ice_Assets); ZEPHIR_INIT(Ice_Auth); ZEPHIR_INIT(Ice_Auth_Driver_File); ZEPHIR_INIT(Ice_Auth_Driver_Model); @@ -199,6 +208,7 @@ static PHP_MINIT_FUNCTION(ice) ZEPHIR_INIT(Ice_Cli_Router); ZEPHIR_INIT(Ice_Cli_Task); ZEPHIR_INIT(Ice_Config_Ini); + ZEPHIR_INIT(Ice_Config_Json); ZEPHIR_INIT(Ice_Cookies); ZEPHIR_INIT(Ice_Crypt); ZEPHIR_INIT(Ice_Db); @@ -237,6 +247,7 @@ static PHP_MINIT_FUNCTION(ice) ZEPHIR_INIT(Ice_Mvc_Route_Dispatcher_GroupCount); ZEPHIR_INIT(Ice_Mvc_Route_Parser_Std); ZEPHIR_INIT(Ice_Mvc_Router); + ZEPHIR_INIT(Ice_Mvc_Service); ZEPHIR_INIT(Ice_Mvc_Url); ZEPHIR_INIT(Ice_Mvc_View); ZEPHIR_INIT(Ice_Mvc_View_Engine_Php); @@ -278,7 +289,7 @@ static PHP_MSHUTDOWN_FUNCTION(ice) { zephir_deinitialize_memory(TSRMLS_C); - + UNREGISTER_INI_ENTRIES(); return SUCCESS; } #endif @@ -286,21 +297,24 @@ static PHP_MSHUTDOWN_FUNCTION(ice) /** * Initialize globals on each request or each thread started */ -static void php_zephir_init_globals(zend_ice_globals *zephir_globals TSRMLS_DC) +static void php_zephir_init_globals(zend_ice_globals *ice_globals TSRMLS_DC) { - zephir_globals->initialized = 0; + ice_globals->initialized = 0; /* Memory options */ - zephir_globals->active_memory = NULL; + ice_globals->active_memory = NULL; /* Virtual Symbol Tables */ - zephir_globals->active_symbol_table = NULL; + ice_globals->active_symbol_table = NULL; /* Cache Enabled */ - zephir_globals->cache_enabled = 1; + ice_globals->cache_enabled = 1; /* Recursive Lock */ - zephir_globals->recursive_lock = 0; + ice_globals->recursive_lock = 0; + + /* Static cache */ + memset(ice_globals->scache, '\0', sizeof(zephir_fcall_cache_entry*) * ZEPHIR_MAX_CACHE_SLOTS); } @@ -308,12 +322,13 @@ static void php_zephir_init_globals(zend_ice_globals *zephir_globals TSRMLS_DC) static PHP_RINIT_FUNCTION(ice) { - zend_ice_globals *zephir_globals_ptr = ZEPHIR_VGLOBAL; + zend_ice_globals *ice_globals_ptr = ZEPHIR_VGLOBAL; - php_zephir_init_globals(zephir_globals_ptr TSRMLS_CC); + php_zephir_init_globals(ice_globals_ptr TSRMLS_CC); //zephir_init_interned_strings(TSRMLS_C); - zephir_initialize_memory(zephir_globals_ptr TSRMLS_CC); + zephir_initialize_memory(ice_globals_ptr TSRMLS_CC); + return SUCCESS; } @@ -337,9 +352,9 @@ static PHP_MINFO_FUNCTION(ice) php_info_print_table_header(2, PHP_ICE_NAME, "enabled"); php_info_print_table_row(2, "Author", PHP_ICE_AUTHOR); php_info_print_table_row(2, "Version", PHP_ICE_VERSION); + php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ ); php_info_print_table_row(2, "Powered by Zephir", "Version " PHP_ICE_ZEPVERSION); php_info_print_table_end(); - php_info_print_table_start(); php_info_print_table_row(2, "Website", "http://www.iceframework.org"); php_info_print_table_row(2, "Email", "info@iceframework.org"); @@ -348,6 +363,7 @@ static PHP_MINFO_FUNCTION(ice) php_info_print_table_row(2, "GitHub", "ice"); php_info_print_table_end(); + DISPLAY_INI_ENTRIES(); } static PHP_GINIT_FUNCTION(ice) @@ -360,8 +376,17 @@ static PHP_GSHUTDOWN_FUNCTION(ice) } +PHP_FUNCTION(g_ice__t); +ZEND_BEGIN_ARG_INFO_EX(arginfo_g_ice__t, 0, 0, 1) + ZEND_ARG_INFO(0, str) + ZEND_ARG_ARRAY_INFO(0, values, 1) + ZEND_ARG_INFO(0, context) + ZEND_ARG_INFO(0, lang) +ZEND_END_ARG_INFO() + zend_function_entry php_ice_functions[] = { +ZEND_NAMED_FE(_t, ZEND_FN(g_ice__t), arginfo_g_ice__t) ZEND_FE_END }; diff --git a/ext/ice.h b/ext/ice.h index 3879633a..4cdee4c9 100644 --- a/ext/ice.h +++ b/ext/ice.h @@ -4,10 +4,32 @@ #ifndef ZEPHIR_CLASS_ENTRIES_H #define ZEPHIR_CLASS_ENTRIES_H +#include "ice/validation/validator.zep.h" #include "ice/arr.zep.h" -#include "ice/auth.zep.h" +#include "ice/i18n/plural/pluralinterface.zep.h" +#include "ice/di/access.zep.h" +#include "ice/mvc/model.zep.h" +#include "ice/auth/social/socialinterface.zep.h" +#include "ice/auth/social/adapter.zep.h" +#include "ice/mvc/view/engine/engineinterface.zep.h" #include "ice/auth/driver.zep.h" #include "ice/auth/driver/driverinterface.zep.h" +#include "ice/config.zep.h" +#include "ice/db/dbinterface.zep.h" +#include "ice/dispatcher.zep.h" +#include "ice/log/loggerinterface.zep.h" +#include "ice/mvc/route/datagenerator/datageneratorinterface.zep.h" +#include "ice/mvc/route/dispatcher/dispatcherinterface.zep.h" +#include "ice/mvc/view/engine.zep.h" +#include "ice/http/response/headersinterface.zep.h" +#include "ice/http/response/responseinterface.zep.h" +#include "ice/log/driver.zep.h" +#include "ice/mvc/route/datagenerator/regex.zep.h" +#include "ice/mvc/route/dispatcher/regex.zep.h" +#include "ice/mvc/route/parser/parserinterface.zep.h" +#include "ice/mvc/view/viewinterface.zep.h" +#include "ice/assets.zep.h" +#include "ice/auth.zep.h" #include "ice/auth/driver/file.zep.h" #include "ice/auth/driver/model.zep.h" #include "ice/auth/driver/model/roles.zep.h" @@ -16,26 +38,21 @@ #include "ice/auth/driver/model/users/social.zep.h" #include "ice/auth/driver/model/users/tokens.zep.h" #include "ice/auth/social.zep.h" -#include "ice/auth/social/adapter.zep.h" #include "ice/auth/social/facebook.zep.h" #include "ice/auth/social/google.zep.h" -#include "ice/auth/social/socialinterface.zep.h" #include "ice/auth/social/twitter.zep.h" #include "ice/cli/console.zep.h" #include "ice/cli/dispatcher.zep.h" #include "ice/cli/router.zep.h" #include "ice/cli/task.zep.h" -#include "ice/config.zep.h" #include "ice/config/ini.zep.h" +#include "ice/config/json.zep.h" #include "ice/cookies.zep.h" #include "ice/crypt.zep.h" #include "ice/db.zep.h" -#include "ice/db/dbinterface.zep.h" #include "ice/db/driver/mongo.zep.h" #include "ice/db/driver/pdo.zep.h" #include "ice/di.zep.h" -#include "ice/di/access.zep.h" -#include "ice/dispatcher.zep.h" #include "ice/dump.zep.h" #include "ice/exception.zep.h" #include "ice/filter.zep.h" @@ -46,8 +63,6 @@ #include "ice/http/request/requestinterface.zep.h" #include "ice/http/response.zep.h" #include "ice/http/response/headers.zep.h" -#include "ice/http/response/headersinterface.zep.h" -#include "ice/http/response/responseinterface.zep.h" #include "ice/i18n.zep.h" #include "ice/i18n/plural/arabic.zep.h" #include "ice/i18n/plural/balkan.zep.h" @@ -55,47 +70,35 @@ #include "ice/i18n/plural/french.zep.h" #include "ice/i18n/plural/none.zep.h" #include "ice/i18n/plural/one.zep.h" -#include "ice/i18n/plural/pluralinterface.zep.h" #include "ice/i18n/plural/polish.zep.h" #include "ice/i18n/plural/romanian.zep.h" #include "ice/i18n/plural/two.zep.h" #include "ice/i18n/plural/zero.zep.h" #include "ice/loader.zep.h" #include "ice/log.zep.h" -#include "ice/log/driver.zep.h" #include "ice/log/driver/file.zep.h" -#include "ice/log/loggerinterface.zep.h" #include "ice/mvc/app.zep.h" #include "ice/mvc/controller.zep.h" #include "ice/mvc/dispatcher.zep.h" -#include "ice/mvc/model.zep.h" #include "ice/mvc/moduleinterface.zep.h" #include "ice/mvc/route.zep.h" #include "ice/mvc/route/collector.zep.h" -#include "ice/mvc/route/datagenerator/datageneratorinterface.zep.h" #include "ice/mvc/route/datagenerator/groupcount.zep.h" -#include "ice/mvc/route/datagenerator/regex.zep.h" -#include "ice/mvc/route/dispatcher/dispatcherinterface.zep.h" #include "ice/mvc/route/dispatcher/groupcount.zep.h" -#include "ice/mvc/route/dispatcher/regex.zep.h" -#include "ice/mvc/route/parser/parserinterface.zep.h" #include "ice/mvc/route/parser/std.zep.h" #include "ice/mvc/router.zep.h" +#include "ice/mvc/service.zep.h" #include "ice/mvc/url.zep.h" #include "ice/mvc/view.zep.h" -#include "ice/mvc/view/engine.zep.h" -#include "ice/mvc/view/engine/engineinterface.zep.h" #include "ice/mvc/view/engine/php.zep.h" #include "ice/mvc/view/engine/sleet.zep.h" #include "ice/mvc/view/engine/sleet/compiler.zep.h" #include "ice/mvc/view/engine/sleet/parser.zep.h" -#include "ice/mvc/view/viewinterface.zep.h" #include "ice/pagination.zep.h" #include "ice/session.zep.h" #include "ice/tag.zep.h" #include "ice/text.zep.h" #include "ice/validation.zep.h" -#include "ice/validation/validator.zep.h" #include "ice/validation/validator/alnum.zep.h" #include "ice/validation/validator/alpha.zep.h" #include "ice/validation/validator/between.zep.h" diff --git a/ext/ice/arr.zep.c b/ext/ice/arr.zep.c index 12bd7406..aea763d9 100644 --- a/ext/ice/arr.zep.c +++ b/ext/ice/arr.zep.c @@ -12,22 +12,35 @@ #include #include "kernel/main.h" +#include "ext/spl/spl_iterators.h" #include "kernel/object.h" #include "kernel/memory.h" #include "kernel/operators.h" #include "kernel/array.h" -#include "kernel/hash.h" #include "kernel/fcall.h" -#include "ext/spl/spl_exceptions.h" #include "kernel/exception.h" +#include "kernel/hash.h" +#include "ext/spl/spl_exceptions.h" #include "kernel/string.h" #include "kernel/concat.h" + +/** + * Access class as array and the same time as object. + * + * @package Ice/Arr + * @category Helper + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Arr) { ZEPHIR_REGISTER_CLASS(Ice, Arr, ice, arr, ice_arr_method_entry, 0); - zend_declare_property_null(ice_arr_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_arr_ce, SL("data"), ZEND_ACC_PROTECTED TSRMLS_CC); + + ice_arr_ce->create_object = zephir_init_properties_Ice_Arr; zend_class_implements(ice_arr_ce TSRMLS_CC, 1, zend_ce_arrayaccess); zend_class_implements(ice_arr_ce TSRMLS_CC, 1, spl_ce_Countable); @@ -39,7 +52,7 @@ ZEPHIR_INIT_CLASS(Ice_Arr) { PHP_METHOD(Ice_Arr, getData) { - RETURN_MEMBER(this_ptr, "_data"); + RETURN_MEMBER(this_ptr, "data"); } @@ -50,7 +63,7 @@ PHP_METHOD(Ice_Arr, getData) { */ PHP_METHOD(Ice_Arr, __construct) { - zval *data_param = NULL, *_0; + zval *data_param = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); @@ -64,10 +77,7 @@ PHP_METHOD(Ice_Arr, __construct) { } - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_data"), _0 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("data"), data TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -89,7 +99,7 @@ PHP_METHOD(Ice_Arr, has) { zephir_get_strval(key, key_param); - _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, key)); } @@ -100,24 +110,51 @@ PHP_METHOD(Ice_Arr, has) { * * @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 */ PHP_METHOD(Ice_Arr, get) { - zval *key_param = NULL, *defaultValue = NULL, *value, *_0; + int ZEPHIR_LAST_CALL_STATUS; + zend_bool required, _0; + zval *key_param = NULL, *defaultValue = NULL, *required_param = NULL, *value = NULL, *_1 = NULL, *_2, _3, *_4 = NULL, *_5; zval *key = NULL; ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); + 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); + } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); - if (zephir_array_isset_fetch(&value, _0, key, 1 TSRMLS_CC)) { + _0 = required; + if (_0) { + ZEPHIR_CALL_METHOD(&_1, this_ptr, "has", NULL, 0, key); + zephir_check_call_status(); + _0 = !zephir_is_true(_1); + } + if (_0) { + ZEPHIR_INIT_VAR(_2); + object_init_ex(_2, ice_exception_ce); + ZEPHIR_SINIT_VAR(_3); + ZVAL_STRING(&_3, "The '%s' key is required", 0); + ZEPHIR_CALL_FUNCTION(&_4, "sprintf", NULL, 1, &_3, key); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 2, _4); + zephir_check_call_status(); + zephir_throw_exception_debug(_2, "ice/arr.zep", 55 TSRMLS_CC); + ZEPHIR_MM_RESTORE(); + return; + } + _5 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC); + if (zephir_array_isset_fetch(&value, _5, key, 1 TSRMLS_CC)) { RETURN_CTOR(value); } RETVAL_ZVAL(defaultValue, 1, 0); @@ -143,7 +180,7 @@ PHP_METHOD(Ice_Arr, set) { zephir_get_strval(key, key_param); - zephir_update_property_array(this_ptr, SL("_data"), key, value TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("data"), key, value TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -169,15 +206,14 @@ PHP_METHOD(Ice_Arr, replace) { data = data_param; - - zephir_is_iterable(data, &_1, &_0, 0, 0, "ice/arr.zep", 85); + zephir_is_iterable(data, &_1, &_0, 0, 0, "ice/arr.zep", 90); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HMKEY(key, _1, _0); ZEPHIR_GET_HVALUE(value, _2); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", &_3, key, value); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", &_3, 0, key, value); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); @@ -195,7 +231,7 @@ PHP_METHOD(Ice_Arr, all) { ZEPHIR_MM_GROW(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getdata", NULL); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getdata", NULL, 0); zephir_check_call_status(); RETURN_MM(); @@ -220,11 +256,10 @@ PHP_METHOD(Ice_Arr, setData) { array_init(data); } else { data = data_param; - } - zephir_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("data"), data TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -239,7 +274,7 @@ PHP_METHOD(Ice_Arr, keys) { zval *_0; - _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_keys(return_value, _0 TSRMLS_CC); return; @@ -262,7 +297,7 @@ PHP_METHOD(Ice_Arr, remove) { zephir_get_strval(key, key_param); - _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_unset(&_0, key, PH_SEPARATE); ZEPHIR_MM_RESTORE(); @@ -281,7 +316,7 @@ PHP_METHOD(Ice_Arr, clear) { ZEPHIR_INIT_VAR(_0); array_init(_0); - zephir_update_property_this(this_ptr, SL("_data"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("data"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -296,7 +331,7 @@ PHP_METHOD(Ice_Arr, count) { zval *_0; - _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_LONG(zephir_fast_count_int(_0 TSRMLS_CC)); } @@ -314,8 +349,8 @@ PHP_METHOD(Ice_Arr, getIterator) { ZEPHIR_MM_GROW(); object_init_ex(return_value, zephir_get_internal_ce(SS("arrayiterator") TSRMLS_CC)); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _0); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 3, _0); zephir_check_call_status(); RETURN_MM(); @@ -341,13 +376,12 @@ PHP_METHOD(Ice_Arr, getIterator) { */ PHP_METHOD(Ice_Arr, getPath) { - HashTable *_10; - HashPosition _9; - zephir_fcall_cache_entry *_6 = NULL, *_12 = NULL, *_13 = NULL; - int ZEPHIR_LAST_CALL_STATUS, _7; - zephir_nts_static zephir_fcall_cache_entry *_4 = NULL; - zval *delimiter = NULL, *_2, *_3; - zval *path = NULL, *defaultValue = NULL, *delimiter_param = NULL, *data = NULL, *keys = NULL, *key = NULL, *_0, *_1 = NULL, *_5 = NULL, *_8 = NULL, *values = NULL, *value = NULL, *arr = NULL, **_11; + HashTable *_11; + HashPosition _10; + int ZEPHIR_LAST_CALL_STATUS, _8; + zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_13 = NULL, *_14 = NULL; + zval *delimiter = NULL, *_3, *_4; + zval *path = NULL, *defaultValue = NULL, *delimiter_param = NULL, *data = NULL, *keys = NULL, *key = NULL, *_0, *_1, *_2 = NULL, *_6 = NULL, *_9 = NULL, *values = NULL, *value = NULL, *arr = NULL, **_12; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &path, &defaultValue, &delimiter_param); @@ -364,72 +398,72 @@ PHP_METHOD(Ice_Arr, getPath) { } - ZEPHIR_OBS_VAR(data); - zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(data, _0); if (Z_TYPE_P(path) == IS_ARRAY) { ZEPHIR_CPY_WRT(keys, path); } else { if (zephir_array_key_exists(data, path TSRMLS_CC)) { - zephir_array_fetch(&_0, data, path, PH_NOISY | PH_READONLY, "ice/arr.zep", 189 TSRMLS_CC); - RETURN_CTOR(_0); + zephir_array_fetch(&_1, data, path, PH_NOISY | PH_READONLY, "ice/arr.zep", 194 TSRMLS_CC); + RETURN_CTOR(_1); } - ZEPHIR_INIT_VAR(_1); ZEPHIR_INIT_VAR(_2); - ZEPHIR_CONCAT_SVS(_2, "{", delimiter, "} "); - zephir_fast_trim(_1, path, _2, ZEPHIR_TRIM_LEFT TSRMLS_CC); - ZEPHIR_CPY_WRT(path, _1); - ZEPHIR_INIT_NVAR(_1); ZEPHIR_INIT_VAR(_3); - ZEPHIR_CONCAT_SVS(_3, "{", delimiter, "} *"); - zephir_fast_trim(_1, path, _3, ZEPHIR_TRIM_RIGHT TSRMLS_CC); - ZEPHIR_CPY_WRT(path, _1); + ZEPHIR_CONCAT_SVS(_3, "{", delimiter, "} "); + zephir_fast_trim(_2, path, _3, ZEPHIR_TRIM_LEFT TSRMLS_CC); + ZEPHIR_CPY_WRT(path, _2); + ZEPHIR_INIT_NVAR(_2); + ZEPHIR_INIT_VAR(_4); + ZEPHIR_CONCAT_SVS(_4, "{", delimiter, "} *"); + zephir_fast_trim(_2, path, _4, ZEPHIR_TRIM_RIGHT TSRMLS_CC); + ZEPHIR_CPY_WRT(path, _2); ZEPHIR_INIT_NVAR(keys); zephir_fast_explode(keys, delimiter, path, LONG_MAX TSRMLS_CC); } do { - Z_SET_ISREF_P(keys); - ZEPHIR_CALL_FUNCTION(&key, "array_shift", &_4, keys); - Z_UNSET_ISREF_P(keys); + ZEPHIR_MAKE_REF(keys); + ZEPHIR_CALL_FUNCTION(&key, "array_shift", &_5, 4, keys); + ZEPHIR_UNREF(keys); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_5, "ctype_digit", &_6, key); + ZEPHIR_CALL_FUNCTION(&_6, "ctype_digit", &_7, 5, key); zephir_check_call_status(); - if (zephir_is_true(_5)) { - _7 = zephir_get_intval(key); + if (zephir_is_true(_6)) { + _8 = zephir_get_intval(key); ZEPHIR_INIT_NVAR(key); - ZVAL_LONG(key, _7); + ZVAL_LONG(key, _8); } if (zephir_array_isset(data, key)) { if (zephir_is_true(keys)) { - ZEPHIR_OBS_NVAR(_8); - zephir_array_fetch(&_8, data, key, PH_NOISY, "ice/arr.zep", 210 TSRMLS_CC); - if (Z_TYPE_P(_8) == IS_ARRAY) { - zephir_array_fetch(&_0, data, key, PH_NOISY | PH_READONLY, "ice/arr.zep", 212 TSRMLS_CC); - ZEPHIR_CPY_WRT(data, _0); + ZEPHIR_OBS_NVAR(_9); + zephir_array_fetch(&_9, data, key, PH_NOISY, "ice/arr.zep", 215 TSRMLS_CC); + if (Z_TYPE_P(_9) == IS_ARRAY) { + zephir_array_fetch(&_1, data, key, PH_NOISY | PH_READONLY, "ice/arr.zep", 217 TSRMLS_CC); + ZEPHIR_CPY_WRT(data, _1); } else { break; } } else { - zephir_array_fetch(&_0, data, key, PH_NOISY | PH_READONLY, "ice/arr.zep", 219 TSRMLS_CC); - RETURN_CTOR(_0); + zephir_array_fetch(&_1, data, key, PH_NOISY | PH_READONLY, "ice/arr.zep", 224 TSRMLS_CC); + RETURN_CTOR(_1); } } else if (ZEPHIR_IS_STRING_IDENTICAL(key, "*")) { ZEPHIR_INIT_NVAR(values); array_init(values); - zephir_is_iterable(data, &_10, &_9, 0, 0, "ice/arr.zep", 236); + zephir_is_iterable(data, &_11, &_10, 0, 0, "ice/arr.zep", 241); for ( - ; zephir_hash_get_current_data_ex(_10, (void**) &_11, &_9) == SUCCESS - ; zephir_hash_move_forward_ex(_10, &_9) + ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS + ; zephir_hash_move_forward_ex(_11, &_10) ) { - ZEPHIR_GET_HVALUE(arr, _11); + ZEPHIR_GET_HVALUE(arr, _12); if (Z_TYPE_P(arr) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(_1); - object_init_ex(_1, ice_arr_ce); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_12, arr); + ZEPHIR_INIT_NVAR(_2); + object_init_ex(_2, ice_arr_ce); + ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_13, 6, arr); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, _1, "getpath", &_13, keys); + ZEPHIR_CALL_METHOD(&value, _2, "getpath", &_14, 7, keys); zephir_check_call_status(); if (zephir_is_true(value)) { - zephir_array_append(&values, value, PH_SEPARATE, "ice/arr.zep", 232); + zephir_array_append(&values, value, PH_SEPARATE, "ice/arr.zep", 237); } } } @@ -457,14 +491,14 @@ PHP_METHOD(Ice_Arr, toArray) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; - zval *key = NULL, *value = NULL, *tmp, *_0, **_3, *_4 = NULL; + zval *key = NULL, *value = NULL, *tmp = NULL, *_0, **_3, *_4 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(tmp); array_init(tmp); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); - zephir_is_iterable(_0, &_2, &_1, 0, 0, "ice/arr.zep", 274); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC); + zephir_is_iterable(_0, &_2, &_1, 0, 0, "ice/arr.zep", 279); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) @@ -473,7 +507,7 @@ PHP_METHOD(Ice_Arr, toArray) { ZEPHIR_GET_HVALUE(value, _3); if (Z_TYPE_P(value) == IS_OBJECT) { if ((zephir_method_exists_ex(value, SS("toarray") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&_4, value, "toarray", NULL); + ZEPHIR_CALL_METHOD(&_4, value, "toarray", NULL, 0); zephir_check_call_status(); zephir_array_update_zval(&tmp, key, &_4, PH_COPY | PH_SEPARATE); } else { @@ -506,7 +540,7 @@ PHP_METHOD(Ice_Arr, offsetExists) { zephir_get_strval(offset, offset_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, offset); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, offset); zephir_check_call_status(); RETURN_MM(); @@ -531,7 +565,7 @@ PHP_METHOD(Ice_Arr, offsetGet) { zephir_get_strval(offset, offset_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, offset); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, offset); zephir_check_call_status(); RETURN_MM(); @@ -557,7 +591,7 @@ PHP_METHOD(Ice_Arr, offsetSet) { zephir_get_strval(offset, offset_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, offset, value); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, offset, value); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -582,7 +616,7 @@ PHP_METHOD(Ice_Arr, offsetUnset) { zephir_get_strval(offset, offset_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, offset); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0, offset); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -603,7 +637,7 @@ PHP_METHOD(Ice_Arr, __isset) { zephir_get_strval(key, key_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, key); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, key); zephir_check_call_status(); RETURN_MM(); @@ -628,7 +662,7 @@ PHP_METHOD(Ice_Arr, __get) { zephir_read_property_zval(&_0, this_ptr, key, PH_NOISY_CC); RETURN_CCTOR(_0); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, key); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, key); zephir_check_call_status(); RETURN_MM(); @@ -653,7 +687,7 @@ PHP_METHOD(Ice_Arr, __set) { if (zephir_isset_property_zval(this_ptr, key TSRMLS_CC)) { zephir_update_property_zval_zval(this_ptr, key, value TSRMLS_CC); } else { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, key, value); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, key, value); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); @@ -671,8 +705,29 @@ PHP_METHOD(Ice_Arr, __unset) { - _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_unset(&_0, key, PH_SEPARATE); } +static zend_object_value zephir_init_properties_Ice_Arr(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("data"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("data"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } + +} + diff --git a/ext/ice/arr.zep.h b/ext/ice/arr.zep.h index 93767d59..1f81e44d 100644 --- a/ext/ice/arr.zep.h +++ b/ext/ice/arr.zep.h @@ -26,6 +26,7 @@ PHP_METHOD(Ice_Arr, __isset); PHP_METHOD(Ice_Arr, __get); PHP_METHOD(Ice_Arr, __set); PHP_METHOD(Ice_Arr, __unset); +static zend_object_value zephir_init_properties_Ice_Arr(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_arr___construct, 0, 0, 0) ZEND_ARG_ARRAY_INFO(0, data, 1) @@ -38,6 +39,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_arr_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_arr_set, 0, 0, 2) @@ -121,5 +123,5 @@ ZEPHIR_INIT_FUNCS(ice_arr_method_entry) { PHP_ME(Ice_Arr, __get, arginfo_ice_arr___get, ZEND_ACC_PUBLIC) PHP_ME(Ice_Arr, __set, arginfo_ice_arr___set, ZEND_ACC_PUBLIC) PHP_ME(Ice_Arr, __unset, arginfo_ice_arr___unset, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/assets.zep.c b/ext/ice/assets.zep.c new file mode 100644 index 00000000..edffad41 --- /dev/null +++ b/ext/ice/assets.zep.c @@ -0,0 +1,642 @@ + +#ifdef HAVE_CONFIG_H +#include "../ext_config.h" +#endif + +#include +#include "../php_ext.h" +#include "../ext.h" + +#include +#include +#include + +#include "kernel/main.h" +#include "kernel/object.h" +#include "kernel/memory.h" +#include "kernel/fcall.h" +#include "kernel/array.h" +#include "kernel/string.h" +#include "kernel/operators.h" +#include "kernel/concat.h" +#include "ext/spl/spl_exceptions.h" +#include "kernel/exception.h" +#include "kernel/file.h" + + +/** + * 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 + */ +ZEPHIR_INIT_CLASS(Ice_Assets) { + + ZEPHIR_REGISTER_CLASS(Ice, Assets, ice, assets, ice_assets_method_entry, 0); + + zend_declare_property_null(ice_assets_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_null(ice_assets_ce, SL("css"), ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_null(ice_assets_ce, SL("js"), ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_null(ice_assets_ce, SL("options"), ZEND_ACC_PROTECTED TSRMLS_CC); + + ice_assets_ce->create_object = zephir_init_properties_Ice_Assets; + zend_declare_class_constant_long(ice_assets_ce, SL("NEVER"), 0 TSRMLS_CC); + + zend_declare_class_constant_long(ice_assets_ce, SL("NOT_EXIST"), 1 TSRMLS_CC); + + zend_declare_class_constant_long(ice_assets_ce, SL("IF_CHANGE"), 2 TSRMLS_CC); + + zend_declare_class_constant_long(ice_assets_ce, SL("ALWAYS"), 3 TSRMLS_CC); + + return SUCCESS; + +} + +PHP_METHOD(Ice_Assets, getCss) { + + + RETURN_MEMBER(this_ptr, "css"); + +} + +PHP_METHOD(Ice_Assets, getJs) { + + + RETURN_MEMBER(this_ptr, "js"); + +} + +PHP_METHOD(Ice_Assets, setOptions) { + + zval *options; + + zephir_fetch_params(0, 1, 0, &options); + + + + zephir_update_property_this(this_ptr, SL("options"), options TSRMLS_CC); + +} + +/** + * Assets constructor. Fetch Di and set it as a property. + */ +PHP_METHOD(Ice_Assets, __construct) { + + int ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_1 = NULL; + zval *_0 = NULL; + + ZEPHIR_MM_GROW(); + + 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_MM_RESTORE(); + +} + +/** + * 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 + */ +PHP_METHOD(Ice_Assets, getOption) { + + zval *key, *defaultValue = NULL, *value = NULL, *_0; + + zephir_fetch_params(0, 1, 1, &key, &defaultValue); + + if (!defaultValue) { + defaultValue = ZEPHIR_GLOBAL(global_null); + } + + + _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); + } + RETVAL_ZVAL(defaultValue, 1, 0); + return; + +} + +/** + * 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 + */ +PHP_METHOD(Ice_Assets, add) { + + int ZEPHIR_LAST_CALL_STATUS; + zend_bool _0, _1; + zval *version = NULL; + zval *parameters = NULL, *version_param = NULL, *minify = NULL, *content = NULL, *type = NULL; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, ¶meters, &version_param, &minify); + + ZEPHIR_SEPARATE_PARAM(parameters); + if (!version_param) { + ZEPHIR_INIT_VAR(version); + ZVAL_EMPTY_STRING(version); + } else { + zephir_get_strval(version, version_param); + } + if (!minify) { + minify = ZEPHIR_GLOBAL(global_null); + } + + + ZEPHIR_OBS_VAR(content); + if (Z_TYPE_P(parameters) == IS_STRING) { + ZEPHIR_CPY_WRT(content, parameters); + ZEPHIR_INIT_NVAR(parameters); + array_init(parameters); + zephir_array_append(¶meters, content, PH_SEPARATE, "ice/assets.zep", 67); + } else if (!(zephir_array_isset_string_fetch(&content, parameters, SS("content"), 0 TSRMLS_CC))) { + ZEPHIR_OBS_NVAR(content); + zephir_array_isset_long_fetch(&content, parameters, 0, 0 TSRMLS_CC); + } + ZEPHIR_OBS_VAR(type); + zephir_array_isset_string_fetch(&type, parameters, SS("type"), 0 TSRMLS_CC); + _0 = zephir_end_with_str(content, SL(".css")); + if (!(_0)) { + _0 = ZEPHIR_IS_STRING(type, "text/css"); + } + _1 = zephir_end_with_str(content, SL(".js")); + if (!(_1)) { + _1 = ZEPHIR_IS_STRING(type, "text/javascript"); + } + if (_0) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addcss", NULL, 0, parameters, version, minify); + zephir_check_call_status(); + } else if (_1) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addjs", NULL, 0, parameters, version, minify); + zephir_check_call_status(); + } + 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 + */ +PHP_METHOD(Ice_Assets, addCss) { + + zend_bool _4; + int ZEPHIR_LAST_CALL_STATUS; + zval *version = NULL, *_8; + zval *parameters_param = NULL, *version_param = NULL, *minify = NULL, *content = NULL, *local = NULL, *tag = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3, *_5 = NULL, *_7 = NULL, *_9, *_10 = NULL; + zval *parameters = NULL, *_6; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, ¶meters_param, &version_param, &minify); + + parameters = parameters_param; + if (!version_param) { + ZEPHIR_INIT_VAR(version); + ZVAL_EMPTY_STRING(version); + } else { + zephir_get_strval(version, version_param); + } + if (!minify) { + ZEPHIR_CPY_WRT(minify, ZEPHIR_GLOBAL(global_null)); + } else { + ZEPHIR_SEPARATE_PARAM(minify); + } + + + _0 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_1); + ZVAL_STRING(_1, "tag", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_2); + ZVAL_NULL(_2); + ZEPHIR_INIT_VAR(_3); + ZVAL_BOOL(_3, 1); + ZEPHIR_CALL_METHOD(&tag, _0, "get", NULL, 0, _1, _2, _3); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + ZEPHIR_OBS_VAR(content); + if (!(zephir_array_isset_string_fetch(&content, parameters, SS("content"), 0 TSRMLS_CC))) { + ZEPHIR_OBS_NVAR(content); + zephir_array_isset_long_fetch(&content, parameters, 0, 0 TSRMLS_CC); + } + ZEPHIR_OBS_VAR(local); + if (!(zephir_array_isset_string_fetch(&local, parameters, SS("local"), 0 TSRMLS_CC))) { + ZEPHIR_INIT_NVAR(local); + ZVAL_BOOL(local, 1); + } + if (Z_TYPE_P(minify) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "minify", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_2); + ZVAL_LONG(_2, 0); + ZEPHIR_CALL_METHOD(&minify, this_ptr, "getoption", NULL, 0, _1, _2); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + } + _4 = !zephir_is_true(local); + if (!(_4)) { + _4 = zephir_end_with_str(content, SL(".min.css")); + } + if (_4) { + ZEPHIR_INIT_NVAR(minify); + ZVAL_LONG(minify, 0); + } + if (zephir_array_isset_string(parameters, SS("content"))) { + ZEPHIR_INIT_VAR(_6); + zephir_create_array(_6, 1, 0 TSRMLS_CC); + ZEPHIR_INIT_VAR(_7); + if (zephir_is_true(minify)) { + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "css", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "minify", NULL, 0, content, _1); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(_7, content); + } + zephir_array_update_string(&_6, SL("content"), &_7, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_5, tag, "style", NULL, 0, _6); + zephir_check_call_status(); + zephir_update_property_array_append(this_ptr, SL("css"), _5 TSRMLS_CC); + } else { + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "css", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "prepare", NULL, 0, content, _1, minify); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + ZEPHIR_INIT_LNVAR(_7); + if (!(!version) && Z_STRLEN_P(version)) { + ZEPHIR_INIT_VAR(_8); + ZEPHIR_CONCAT_SV(_8, "?v=", version); + ZEPHIR_CPY_WRT(_7, _8); + } else { + ZEPHIR_INIT_NVAR(_7); + ZVAL_STRING(_7, "", 1); + } + ZEPHIR_INIT_VAR(_9); + ZEPHIR_CONCAT_VV(_9, _5, _7); + zephir_array_update_string(¶meters, SL("href"), &_9, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_10, tag, "link", NULL, 0, parameters); + zephir_check_call_status(); + zephir_update_property_array_append(this_ptr, SL("css"), _10 TSRMLS_CC); + } + 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 + */ +PHP_METHOD(Ice_Assets, addJs) { + + zend_bool _4; + int ZEPHIR_LAST_CALL_STATUS; + zval *version = NULL, *_8; + zval *parameters_param = NULL, *version_param = NULL, *minify = NULL, *content = NULL, *local = NULL, *tag = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3, *_5 = NULL, *_7 = NULL, *_9, *_10 = NULL; + zval *parameters = NULL, *_6; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 2, ¶meters_param, &version_param, &minify); + + parameters = parameters_param; + if (!version_param) { + ZEPHIR_INIT_VAR(version); + ZVAL_EMPTY_STRING(version); + } else { + zephir_get_strval(version, version_param); + } + if (!minify) { + ZEPHIR_CPY_WRT(minify, ZEPHIR_GLOBAL(global_null)); + } else { + ZEPHIR_SEPARATE_PARAM(minify); + } + + + _0 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_1); + ZVAL_STRING(_1, "tag", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_2); + ZVAL_NULL(_2); + ZEPHIR_INIT_VAR(_3); + ZVAL_BOOL(_3, 1); + ZEPHIR_CALL_METHOD(&tag, _0, "get", NULL, 0, _1, _2, _3); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + ZEPHIR_OBS_VAR(content); + if (!(zephir_array_isset_string_fetch(&content, parameters, SS("content"), 0 TSRMLS_CC))) { + ZEPHIR_OBS_NVAR(content); + zephir_array_isset_long_fetch(&content, parameters, 0, 0 TSRMLS_CC); + } + ZEPHIR_OBS_VAR(local); + if (!(zephir_array_isset_string_fetch(&local, parameters, SS("local"), 0 TSRMLS_CC))) { + ZEPHIR_INIT_NVAR(local); + ZVAL_BOOL(local, 1); + } + if (Z_TYPE_P(minify) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "minify", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_2); + ZVAL_LONG(_2, 0); + ZEPHIR_CALL_METHOD(&minify, this_ptr, "getoption", NULL, 0, _1, _2); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + } + _4 = !zephir_is_true(local); + if (!(_4)) { + _4 = zephir_end_with_str(content, SL(".min.js")); + } + if (_4) { + ZEPHIR_INIT_NVAR(minify); + ZVAL_LONG(minify, 0); + } + if (zephir_array_isset_string(parameters, SS("content"))) { + ZEPHIR_INIT_VAR(_6); + zephir_create_array(_6, 1, 0 TSRMLS_CC); + ZEPHIR_INIT_VAR(_7); + if (zephir_is_true(minify)) { + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "js", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "minify", NULL, 0, content, _1); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(_7, content); + } + zephir_array_update_string(&_6, SL("content"), &_7, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_5, tag, "script", NULL, 0, _6); + zephir_check_call_status(); + zephir_update_property_array_append(this_ptr, SL("js"), _5 TSRMLS_CC); + } else { + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "js", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "prepare", NULL, 0, content, _1, minify); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + ZEPHIR_INIT_LNVAR(_7); + if (!(!version) && Z_STRLEN_P(version)) { + ZEPHIR_INIT_VAR(_8); + ZEPHIR_CONCAT_SV(_8, "?v=", version); + ZEPHIR_CPY_WRT(_7, _8); + } else { + ZEPHIR_INIT_NVAR(_7); + ZVAL_STRING(_7, "", 1); + } + ZEPHIR_INIT_VAR(_9); + ZEPHIR_CONCAT_VV(_9, _5, _7); + zephir_array_update_string(¶meters, SL("src"), &_9, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_10, tag, "script", NULL, 0, parameters); + zephir_check_call_status(); + zephir_update_property_array_append(this_ptr, SL("js"), _10 TSRMLS_CC); + } + RETURN_THIS(); + +} + +/** + * Minify content + * + * @param string content Input text to minify + * @param string type Type of content + * @return string + */ +PHP_METHOD(Ice_Assets, minify) { + + int ZEPHIR_LAST_CALL_STATUS; + zval *content_param = NULL, *type, *_0, *_1 = NULL, *_2, *_3, *_4, *_5; + zval *content = NULL; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 2, 0, &content_param, &type); + + if (unlikely(Z_TYPE_P(content_param) != IS_STRING && Z_TYPE_P(content_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'content' must be a string") TSRMLS_CC); + RETURN_MM_NULL(); + } + if (likely(Z_TYPE_P(content_param) == IS_STRING)) { + zephir_get_strval(content, content_param); + } else { + ZEPHIR_INIT_VAR(content); + ZVAL_EMPTY_STRING(content); + } + + + _0 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_2); + ZVAL_STRING(_2, "filter", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_3); + ZVAL_NULL(_3); + ZEPHIR_INIT_VAR(_4); + ZVAL_BOOL(_4, 1); + ZEPHIR_CALL_METHOD(&_1, _0, "get", NULL, 0, _2, _3, _4); + zephir_check_temp_parameter(_2); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(_5); + ZEPHIR_CONCAT_VS(_5, type, "min"); + ZEPHIR_RETURN_CALL_METHOD(_1, "sanitize", NULL, 0, content, _5); + zephir_check_call_status(); + RETURN_MM(); + +} + +/** + * 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 + */ +PHP_METHOD(Ice_Assets, prepare) { + + zephir_fcall_cache_entry *_1 = NULL, *_3 = NULL, *_10 = NULL; + int ZEPHIR_LAST_CALL_STATUS; + zval *uri_param = NULL, *type_param = NULL, *minify = NULL, *source = NULL, *target = NULL, *dir = NULL, *file = NULL, *uriMin = NULL, *destination = NULL, *exist = NULL, *old = NULL, *minified = NULL, *_0 = NULL, *_2 = NULL, *_5 = NULL, *_6, *_7 = NULL, *_8 = NULL, _9 = zval_used_for_init, *_11 = NULL; + zval *uri = NULL, *type = NULL, *_4; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 3, 0, &uri_param, &type_param, &minify); + + if (unlikely(Z_TYPE_P(uri_param) != IS_STRING && Z_TYPE_P(uri_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'uri' must be a string") TSRMLS_CC); + RETURN_MM_NULL(); + } + if (likely(Z_TYPE_P(uri_param) == IS_STRING)) { + zephir_get_strval(uri, uri_param); + } else { + ZEPHIR_INIT_VAR(uri); + ZVAL_EMPTY_STRING(uri); + } + zephir_get_strval(type, type_param); + ZEPHIR_SEPARATE_PARAM(minify); + + + ZEPHIR_INIT_VAR(_0); + ZVAL_STRING(_0, "source", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&source, this_ptr, "getoption", &_1, 0, _0); + zephir_check_temp_parameter(_0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(_0); + ZVAL_STRING(_0, "target", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&target, this_ptr, "getoption", &_1, 0, _0); + zephir_check_temp_parameter(_0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_2, "dirname", &_3, 35, uri); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(dir); + ZEPHIR_CONCAT_VS(dir, _2, "/"); + ZEPHIR_INIT_VAR(_4); + ZEPHIR_CONCAT_SV(_4, ".", type); + ZEPHIR_CALL_FUNCTION(&file, "basename", NULL, 36, uri, _4); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(uriMin); + ZEPHIR_CONCAT_VVVSV(uriMin, target, dir, file, ".min.", type); + ZEPHIR_INIT_VAR(destination); + ZEPHIR_CONCAT_VV(destination, source, uriMin); + ZEPHIR_INIT_VAR(exist); + ZVAL_BOOL(exist, 0); + do { + if (ZEPHIR_IS_LONG(minify, 1)) { + ZEPHIR_INIT_NVAR(minify); + ZVAL_BOOL(minify, !((zephir_file_exists(destination TSRMLS_CC) == SUCCESS))); + break; + } + if (ZEPHIR_IS_LONG(minify, 2)) { + if (!((zephir_file_exists(destination TSRMLS_CC) == SUCCESS))) { + ZEPHIR_INIT_NVAR(minify); + ZVAL_BOOL(minify, 1); + } else { + ZEPHIR_CALL_FUNCTION(&minify, "md5_file", NULL, 37, destination); + zephir_check_call_status(); + } + break; + } + if (ZEPHIR_IS_LONG(minify, 3)) { + ZEPHIR_INIT_NVAR(minify); + ZVAL_BOOL(minify, 1); + break; + } + ZEPHIR_INIT_NVAR(minify); + ZVAL_BOOL(minify, 0); + ZEPHIR_INIT_NVAR(_0); + ZVAL_STRING(_0, "forceMinified", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getoption", &_1, 0, _0); + zephir_check_temp_parameter(_0); + zephir_check_call_status(); + if (zephir_is_true(_5)) { + ZEPHIR_INIT_NVAR(exist); + ZVAL_BOOL(exist, (zephir_file_exists(destination TSRMLS_CC) == SUCCESS)); + } + break; + } while(0); + + if (!(zephir_is_true(minify))) { + ZEPHIR_INIT_NVAR(_0); + if (zephir_is_true(exist)) { + ZEPHIR_CPY_WRT(_0, uriMin); + } else { + ZEPHIR_CPY_WRT(_0, uri); + } + RETURN_CCTOR(_0); + } else { + ZEPHIR_INIT_VAR(_6); + ZEPHIR_CONCAT_VV(_6, source, uri); + zephir_file_get_contents(_0, _6 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&minified, this_ptr, "minify", NULL, 0, _0, type); + zephir_check_call_status(); + if (Z_TYPE_P(minify) == IS_STRING) { + ZEPHIR_INIT_VAR(_7); + zephir_md5(_7, minified); + if (!ZEPHIR_IS_EQUAL(minify, _7)) { + ZEPHIR_INIT_NVAR(minify); + ZVAL_BOOL(minify, 1); + } + } + if (ZEPHIR_IS_TRUE_IDENTICAL(minify)) { + ZEPHIR_CALL_FUNCTION(&_5, "dirname", &_3, 35, destination); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_8, "is_dir", NULL, 38, _5); + zephir_check_call_status(); + if (!(zephir_is_true(_8))) { + ZEPHIR_SINIT_VAR(_9); + ZVAL_LONG(&_9, 0); + ZEPHIR_CALL_FUNCTION(&old, "umask", &_10, 39, &_9); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_11, "dirname", &_3, 35, destination); + zephir_check_call_status(); + ZEPHIR_SINIT_NVAR(_9); + ZVAL_LONG(&_9, 0777); + ZEPHIR_CALL_FUNCTION(NULL, "mkdir", NULL, 40, _11, &_9, ZEPHIR_GLOBAL(global_true)); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "umask", &_10, 39, old); + zephir_check_call_status(); + } + ZEPHIR_INIT_NVAR(_7); + zephir_file_put_contents(_7, destination, minified TSRMLS_CC); + if (ZEPHIR_IS_FALSE_IDENTICAL(_7)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Directory can't be written", "ice/assets.zep", 249); + return; + } + } + RETURN_CCTOR(uriMin); + } + ZEPHIR_MM_RESTORE(); + +} + +static zend_object_value zephir_init_properties_Ice_Assets(zend_class_entry *class_type TSRMLS_DC) { + + zval *_0, *_1 = NULL, *_2, *_3; + + 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); + } + _2 = zephir_fetch_nproperty_this(this_ptr, SL("js"), PH_NOISY_CC); + if (Z_TYPE_P(_2) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("js"), _1 TSRMLS_CC); + } + _3 = zephir_fetch_nproperty_this(this_ptr, SL("css"), PH_NOISY_CC); + if (Z_TYPE_P(_3) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("css"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } + +} + diff --git a/ext/ice/assets.zep.h b/ext/ice/assets.zep.h new file mode 100644 index 00000000..b722614a --- /dev/null +++ b/ext/ice/assets.zep.h @@ -0,0 +1,68 @@ + +extern zend_class_entry *ice_assets_ce; + +ZEPHIR_INIT_CLASS(Ice_Assets); + +PHP_METHOD(Ice_Assets, getCss); +PHP_METHOD(Ice_Assets, getJs); +PHP_METHOD(Ice_Assets, setOptions); +PHP_METHOD(Ice_Assets, __construct); +PHP_METHOD(Ice_Assets, getOption); +PHP_METHOD(Ice_Assets, add); +PHP_METHOD(Ice_Assets, addCss); +PHP_METHOD(Ice_Assets, addJs); +PHP_METHOD(Ice_Assets, minify); +PHP_METHOD(Ice_Assets, prepare); +static zend_object_value zephir_init_properties_Ice_Assets(zend_class_entry *class_type TSRMLS_DC); + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_assets_setoptions, 0, 0, 1) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_assets_getoption, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, defaultValue) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_assets_add, 0, 0, 1) + ZEND_ARG_INFO(0, parameters) + ZEND_ARG_INFO(0, version) + ZEND_ARG_INFO(0, minify) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_assets_addcss, 0, 0, 1) + ZEND_ARG_ARRAY_INFO(0, parameters, 0) + ZEND_ARG_INFO(0, version) + ZEND_ARG_INFO(0, minify) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_assets_addjs, 0, 0, 1) + ZEND_ARG_ARRAY_INFO(0, parameters, 0) + ZEND_ARG_INFO(0, version) + ZEND_ARG_INFO(0, minify) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_assets_minify, 0, 0, 2) + ZEND_ARG_INFO(0, content) + ZEND_ARG_INFO(0, type) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_assets_prepare, 0, 0, 3) + ZEND_ARG_INFO(0, uri) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, minify) +ZEND_END_ARG_INFO() + +ZEPHIR_INIT_FUNCS(ice_assets_method_entry) { + PHP_ME(Ice_Assets, getCss, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Assets, getJs, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Assets, setOptions, arginfo_ice_assets_setoptions, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Assets, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_ME(Ice_Assets, getOption, arginfo_ice_assets_getoption, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Assets, add, arginfo_ice_assets_add, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Assets, addCss, arginfo_ice_assets_addcss, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Assets, addJs, arginfo_ice_assets_addjs, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Assets, minify, arginfo_ice_assets_minify, ZEND_ACC_PROTECTED) + PHP_ME(Ice_Assets, prepare, arginfo_ice_assets_prepare, ZEND_ACC_PROTECTED) + PHP_FE_END +}; diff --git a/ext/ice/auth/driver.zep.c b/ext/ice/auth/driver.zep.c index 16e7a5e0..71f7aa70 100644 --- a/ext/ice/auth/driver.zep.c +++ b/ext/ice/auth/driver.zep.c @@ -12,28 +12,39 @@ #include #include "kernel/main.h" -#include "kernel/memory.h" -#include "kernel/object.h" #include "kernel/fcall.h" +#include "kernel/memory.h" #include "kernel/array.h" +#include "kernel/object.h" #include "kernel/operators.h" #include "ext/spl/spl_exceptions.h" #include "kernel/exception.h" + +/** + * User authorization library. Handles user login and logout, as well as secure password hashing. + * + * @package Ice/Auth + * @category Library + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Auth_Driver) { ZEPHIR_REGISTER_CLASS(Ice\\Auth, Driver, ice, auth_driver, ice_auth_driver_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(ice_auth_driver_ce, SL("_session"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_driver_ce, SL("session"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_driver_ce, SL("_cookies"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_driver_ce, SL("cookies"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_driver_ce, SL("_request"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_driver_ce, SL("request"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_driver_ce, SL("_user"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_driver_ce, SL("user"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_driver_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_driver_ce, SL("options"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_auth_driver_ce->create_object = zephir_init_properties_Ice_Auth_Driver; return SUCCESS; } @@ -47,9 +58,9 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver) { PHP_METHOD(Ice_Auth_Driver, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; - zval *options_param = NULL, *di = NULL, *_2, *_3, *_4 = NULL, *_5 = NULL, *_6 = NULL; - zval *options = NULL, *_0; + zephir_fcall_cache_entry *_0 = NULL; + zval *options_param = NULL, *di = NULL, *_1, *_2, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_8 = NULL; + zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options_param); @@ -62,29 +73,42 @@ PHP_METHOD(Ice_Auth_Driver, __construct) { } - ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 7); - add_assoc_stringl_ex(_0, SS("hash_method"), SL("sha256"), 1); - add_assoc_stringl_ex(_0, SS("hash_key"), SL(""), 1); - add_assoc_stringl_ex(_0, SS("session_key"), SL("auth_user"), 1); - add_assoc_stringl_ex(_0, SS("session_roles"), SL("auth_user_roles"), 1); - add_assoc_long_ex(_0, SS("lifetime"), 1209600); - zephir_update_property_this(this_ptr, SL("_options"), _0 TSRMLS_CC); - ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_1); + ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_0, 8); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_2); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); - zephir_fast_array_merge(_2, &(_3), &(options) TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_options"), _2 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_4, di, "getsession", NULL); + ZEPHIR_INIT_VAR(_1); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC); + zephir_fast_array_merge(_1, &(_2), &(options) TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("options"), _1 TSRMLS_CC); + ZEPHIR_INIT_VAR(_4); + ZVAL_STRING(_4, "session", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_5); + ZVAL_NULL(_5); + ZEPHIR_INIT_VAR(_6); + ZVAL_BOOL(_6, 1); + ZEPHIR_CALL_METHOD(&_3, di, "get", NULL, 0, _4, _5, _6); + zephir_check_temp_parameter(_4); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_session"), _4 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_5, di, "getcookies", NULL); + zephir_update_property_this(this_ptr, SL("session"), _3 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "cookies", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_5); + ZVAL_NULL(_5); + ZEPHIR_INIT_NVAR(_6); + ZVAL_BOOL(_6, 1); + ZEPHIR_CALL_METHOD(&_7, di, "get", NULL, 0, _4, _5, _6); + zephir_check_temp_parameter(_4); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_cookies"), _5 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_6, di, "getrequest", NULL); + zephir_update_property_this(this_ptr, SL("cookies"), _7 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "request", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_5); + ZVAL_NULL(_5); + ZEPHIR_INIT_NVAR(_6); + ZVAL_BOOL(_6, 1); + ZEPHIR_CALL_METHOD(&_8, di, "get", NULL, 0, _4, _5, _6); + zephir_check_temp_parameter(_4); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_request"), _6 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("request"), _8 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -109,7 +133,7 @@ PHP_METHOD(Ice_Auth_Driver, checkHash) { zephir_get_strval(hash, hash_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "hash", NULL, password); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "hash", NULL, 0, password); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(_0, hash)); @@ -124,9 +148,10 @@ PHP_METHOD(Ice_Auth_Driver, checkHash) { */ PHP_METHOD(Ice_Auth_Driver, completeLogin) { + zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *roles = NULL; - zval *user, *roles_param = NULL, *sessionRoles = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5; + zval *user, *roles_param = NULL, *sessionRoles = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &user, &roles_param); @@ -139,28 +164,28 @@ PHP_METHOD(Ice_Auth_Driver, completeLogin) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _0, "regenerate", NULL); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _0, "regenerate", NULL, 0); zephir_check_call_status(); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "session_key", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "auth_user", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getoption", NULL, _3, _4); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getoption", &_5, 0, _3, _4); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _1, "set", NULL, _2, user); + ZEPHIR_CALL_METHOD(NULL, _1, "set", NULL, 0, _2, user); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "session_roles", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&sessionRoles, this_ptr, "getoption", NULL, _3); + ZEPHIR_CALL_METHOD(&sessionRoles, this_ptr, "getoption", &_5, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (zephir_is_true(sessionRoles)) { - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _5, "set", NULL, sessionRoles, roles); + _6 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _6, "set", NULL, 0, sessionRoles, roles); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); @@ -176,7 +201,7 @@ PHP_METHOD(Ice_Auth_Driver, completeLogin) { */ PHP_METHOD(Ice_Auth_Driver, getOption) { - zval *key_param = NULL, *defaultValue = NULL, *value, *_0; + zval *key_param = NULL, *defaultValue = NULL, *value = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); @@ -186,7 +211,6 @@ PHP_METHOD(Ice_Auth_Driver, getOption) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { @@ -198,7 +222,7 @@ PHP_METHOD(Ice_Auth_Driver, getOption) { } - _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_CTOR(value); } @@ -226,13 +250,13 @@ PHP_METHOD(Ice_Auth_Driver, getUser) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "session_key", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getoption", NULL, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getoption", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, _1, defaultValue); + ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, _1, defaultValue); zephir_check_call_status(); RETURN_MM(); @@ -246,8 +270,9 @@ PHP_METHOD(Ice_Auth_Driver, getUser) { */ PHP_METHOD(Ice_Auth_Driver, hash) { + zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *password_param = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL; + zval *password_param = NULL, *_0 = NULL, *_1 = NULL, *_3 = NULL; zval *password = NULL; ZEPHIR_MM_GROW(); @@ -258,15 +283,15 @@ PHP_METHOD(Ice_Auth_Driver, hash) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "hash_method", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getoption", NULL, _1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getoption", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "hash_key", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getoption", NULL, _1); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getoption", &_2, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac", NULL, _0, password, _2); + ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac", NULL, 25, _0, password, _3); zephir_check_call_status(); RETURN_MM(); @@ -295,26 +320,26 @@ PHP_METHOD(Ice_Auth_Driver, loggedIn) { } - ZEPHIR_CALL_METHOD(&user, this_ptr, "getuser", NULL); + ZEPHIR_CALL_METHOD(&user, this_ptr, "getuser", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(user))) { RETURN_MM_BOOL(0); } else { - if (!(role && Z_STRLEN_P(role))) { + if (!(!(!role) && Z_STRLEN_P(role))) { RETURN_MM_BOOL(1); } ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "session_roles", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&sessionRoles, this_ptr, "getoption", NULL, _0); + ZEPHIR_CALL_METHOD(&sessionRoles, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); if (zephir_is_true(sessionRoles)) { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&roles, _1, "get", NULL, sessionRoles); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&roles, _1, "get", NULL, 0, sessionRoles); zephir_check_call_status(); RETURN_MM_BOOL(zephir_fast_in_array(role, roles TSRMLS_CC)); } else { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasrole", NULL, user, role); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasrole", NULL, 0, user, role); zephir_check_call_status(); RETURN_MM(); } @@ -332,8 +357,9 @@ PHP_METHOD(Ice_Auth_Driver, loggedIn) { */ PHP_METHOD(Ice_Auth_Driver, logout) { + zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *destroy_param = NULL, *logoutAll_param = NULL, *sessionRoles = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3; + zval *destroy_param = NULL, *logoutAll_param = NULL, *sessionRoles = NULL, *_0, *_1 = NULL, *_2 = NULL, *_4; zend_bool destroy, logoutAll; ZEPHIR_MM_GROW(); @@ -352,35 +378,62 @@ PHP_METHOD(Ice_Auth_Driver, logout) { if (destroy == 1) { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _0, "destroy", NULL); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _0, "destroy", NULL, 0); zephir_check_call_status(); } else { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "session_key", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getoption", NULL, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getoption", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _0, "remove", NULL, _1); + ZEPHIR_CALL_METHOD(NULL, _0, "remove", NULL, 0, _1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "session_roles", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&sessionRoles, this_ptr, "getoption", NULL, _2); + ZEPHIR_CALL_METHOD(&sessionRoles, this_ptr, "getoption", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); if (zephir_is_true(sessionRoles)) { - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _3, "remove", NULL, sessionRoles); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _4, "remove", NULL, 0, sessionRoles); zephir_check_call_status(); } - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _3, "regenerate", NULL); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _4, "regenerate", NULL, 0); zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "loggedin", NULL); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "loggedin", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(!zephir_is_true(_1)); } +static zend_object_value zephir_init_properties_Ice_Auth_Driver(zend_class_entry *class_type TSRMLS_DC) { + + zval *_1; + zval *_0; + + 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); + zephir_create_array(_1, 5, 0 TSRMLS_CC); + add_assoc_stringl_ex(_1, SS("hash_method"), SL("sha256"), 1); + add_assoc_stringl_ex(_1, SS("hash_key"), SL(""), 1); + add_assoc_stringl_ex(_1, SS("session_key"), SL("auth_user"), 1); + add_assoc_stringl_ex(_1, SS("session_roles"), SL("auth_user_roles"), 1); + add_assoc_long_ex(_1, SS("lifetime"), 1209600); + 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/auth/driver.zep.h b/ext/ice/auth/driver.zep.h index 6e9b3106..1f0659c2 100644 --- a/ext/ice/auth/driver.zep.h +++ b/ext/ice/auth/driver.zep.h @@ -11,6 +11,7 @@ PHP_METHOD(Ice_Auth_Driver, getUser); PHP_METHOD(Ice_Auth_Driver, hash); PHP_METHOD(Ice_Auth_Driver, loggedIn); PHP_METHOD(Ice_Auth_Driver, logout); +static zend_object_value zephir_init_properties_Ice_Auth_Driver(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_auth_driver___construct, 0, 0, 0) ZEND_ARG_ARRAY_INFO(0, options, 1) @@ -57,5 +58,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_driver_method_entry) { PHP_ME(Ice_Auth_Driver, hash, arginfo_ice_auth_driver_hash, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver, loggedIn, arginfo_ice_auth_driver_loggedin, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver, logout, arginfo_ice_auth_driver_logout, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/driver/driverinterface.zep.h b/ext/ice/auth/driver/driverinterface.zep.h index e891cb5b..40c1d3a8 100644 --- a/ext/ice/auth/driver/driverinterface.zep.h +++ b/ext/ice/auth/driver/driverinterface.zep.h @@ -22,5 +22,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_driver_driverinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Auth_Driver_DriverInterface, getUser, arginfo_ice_auth_driver_driverinterface_getuser) PHP_ABSTRACT_ME(Ice_Auth_Driver_DriverInterface, hasRole, arginfo_ice_auth_driver_driverinterface_hasrole) PHP_ABSTRACT_ME(Ice_Auth_Driver_DriverInterface, login, arginfo_ice_auth_driver_driverinterface_login) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/driver/file.zep.c b/ext/ice/auth/driver/file.zep.c index a69993bf..e27f36c1 100644 --- a/ext/ice/auth/driver/file.zep.c +++ b/ext/ice/auth/driver/file.zep.c @@ -33,7 +33,7 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_File) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Auth\\Driver, File, ice, auth_driver_file, ice_auth_driver_ce, ice_auth_driver_file_method_entry, 0); - zend_declare_property_null(ice_auth_driver_file_ce, SL("_users"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_driver_file_ce, SL("users"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(ice_auth_driver_file_ce TSRMLS_CC, 1, ice_auth_driver_driverinterface_ce); return SUCCESS; @@ -48,7 +48,7 @@ PHP_METHOD(Ice_Auth_Driver_File, setUsers) { - zephir_update_property_this(this_ptr, SL("_users"), users TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("users"), users TSRMLS_CC); } @@ -61,8 +61,8 @@ PHP_METHOD(Ice_Auth_Driver_File, setUsers) { PHP_METHOD(Ice_Auth_Driver_File, getUser) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; - zval *defaultValue = NULL, *username = NULL, *user, *_0, *_2; + zephir_fcall_cache_entry *_1 = NULL; + zval *defaultValue = NULL, *username = NULL, *user = NULL, *_0, *_2, *_3; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &defaultValue); @@ -72,19 +72,29 @@ PHP_METHOD(Ice_Auth_Driver_File, getUser) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_user"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("user"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { - ZEPHIR_CALL_PARENT(&username, ice_auth_driver_file_ce, this_ptr, "getuser", &_1, defaultValue); + ZEPHIR_CALL_PARENT(&username, ice_auth_driver_file_ce, this_ptr, "getuser", &_1, 41, defaultValue); zephir_check_call_status(); if (ZEPHIR_IS_IDENTICAL(username, defaultValue)) { - zephir_update_property_this(this_ptr, SL("_user"), defaultValue TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("user"), defaultValue TSRMLS_CC); } else { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_users"), PH_NOISY_CC); - zephir_array_isset_fetch(&user, _2, username, 1 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_user"), user TSRMLS_CC); + ZEPHIR_OBS_VAR(user); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("users"), PH_NOISY_CC); + zephir_array_isset_fetch(&user, _2, username, 0 TSRMLS_CC); + zephir_array_update_string(&user, SL("username"), &username, PH_COPY | PH_SEPARATE); + zephir_update_property_this(this_ptr, SL("user"), user TSRMLS_CC); } } - RETURN_MM_MEMBER(this_ptr, "_user"); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("user"), PH_NOISY_CC); + if (zephir_is_true(_2)) { + object_init_ex(return_value, ice_arr_ce); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("user"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 6, _3); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_MM_MEMBER(this_ptr, "user"); } @@ -112,10 +122,10 @@ PHP_METHOD(Ice_Auth_Driver_File, hasRole) { if (Z_TYPE_P(user) == IS_ARRAY) { - zephir_array_fetch_string(&_0, user, SL("roles"), PH_NOISY | PH_READONLY, "ice/auth/driver/file.zep", 57 TSRMLS_CC); + zephir_array_fetch_string(&_0, user, SL("roles"), PH_NOISY | PH_READONLY, "ice/auth/driver/file.zep", 62 TSRMLS_CC); RETURN_MM_BOOL(zephir_fast_in_array(role, _0 TSRMLS_CC)); } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "User must be an array", "ice/auth/driver/file.zep", 59); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "User must be an array", "ice/auth/driver/file.zep", 64); return; } @@ -133,7 +143,7 @@ PHP_METHOD(Ice_Auth_Driver_File, login) { int ZEPHIR_LAST_CALL_STATUS; zend_bool remember, _0; - zval *username_param = NULL, *password_param = NULL, *remember_param = NULL, *user, *_1, *_2, *_3 = NULL, *_4; + zval *username_param = NULL, *password_param = NULL, *remember_param = NULL, *user = NULL, *_1, *_2, *_3 = NULL, *_4; zval *username = NULL, *password = NULL; ZEPHIR_MM_GROW(); @@ -148,22 +158,22 @@ PHP_METHOD(Ice_Auth_Driver_File, login) { } - if (ZEPHIR_IS_EMPTY(password)) { - RETURN_MM_BOOL(0); - } _0 = zephir_is_true(username); if (_0) { ZEPHIR_OBS_VAR(user); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_users"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("users"), PH_NOISY_CC); _0 = zephir_array_isset_fetch(&user, _1, username, 0 TSRMLS_CC); } if (_0) { - zephir_array_fetch_string(&_2, user, SL("password"), PH_NOISY | PH_READONLY, "ice/auth/driver/file.zep", 80 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "hash", NULL, password); + if (ZEPHIR_IS_EMPTY(password)) { + RETURN_MM_BOOL(0); + } + zephir_array_fetch_string(&_2, user, SL("password"), PH_NOISY | PH_READONLY, "ice/auth/driver/file.zep", 85 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "hash", NULL, 0, password); zephir_check_call_status(); if (ZEPHIR_IS_IDENTICAL(_2, _3)) { - zephir_array_fetch_string(&_4, user, SL("roles"), PH_NOISY | PH_READONLY, "ice/auth/driver/file.zep", 82 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "completelogin", NULL, username, _4); + zephir_array_fetch_string(&_4, user, SL("roles"), PH_NOISY | PH_READONLY, "ice/auth/driver/file.zep", 87 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "completelogin", NULL, 0, username, _4); zephir_check_call_status(); RETURN_MM_BOOL(1); } diff --git a/ext/ice/auth/driver/file.zep.h b/ext/ice/auth/driver/file.zep.h index 77347bf5..54a61bec 100644 --- a/ext/ice/auth/driver/file.zep.h +++ b/ext/ice/auth/driver/file.zep.h @@ -32,5 +32,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_driver_file_method_entry) { PHP_ME(Ice_Auth_Driver_File, getUser, arginfo_ice_auth_driver_file_getuser, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver_File, hasRole, arginfo_ice_auth_driver_file_hasrole, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver_File, login, arginfo_ice_auth_driver_file_login, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/driver/model.zep.c b/ext/ice/auth/driver/model.zep.c index 85ba4b89..480a8957 100644 --- a/ext/ice/auth/driver/model.zep.c +++ b/ext/ice/auth/driver/model.zep.c @@ -47,96 +47,86 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_Model) { */ PHP_METHOD(Ice_Auth_Driver_Model, autoLogin) { - zephir_fcall_cache_entry *_13 = NULL; - zend_object_iterator *_11; - zval *_5 = NULL, *_16 = NULL, *_18 = NULL; + zend_object_iterator *_9; zend_bool _4; zval *_3; - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_10 = NULL; + zephir_fcall_cache_entry *_2 = NULL, *_11 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *token = NULL, *user = NULL, *userRoles = NULL, *roles, *role = NULL, *_0, *_1 = NULL, *_6, *_7, *_8 = NULL, *_9 = NULL, *_12 = NULL, _14, *_15, *_17, *_19; + zval *token = NULL, *user = NULL, *userRoles = NULL, *roles = NULL, *role = NULL, *_0, *_1 = NULL, *_5, *_6, *_7 = NULL, *_8 = NULL, *_10 = NULL, _12, *_13, *_14, *_15; ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("cookies"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "auth_autologin", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&token, _0, "get", NULL, _1); + ZEPHIR_CALL_METHOD(&token, _0, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (zephir_is_true(token)) { ZEPHIR_INIT_VAR(_3); - array_init_size(_3, 2); + zephir_create_array(_3, 1, 0 TSRMLS_CC); zephir_array_update_string(&_3, SL("token"), &token, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_CE_STATIC(&token, ice_auth_driver_model_users_tokens_ce, "findone", &_2, _3); + ZEPHIR_CALL_CE_STATIC(&token, ice_auth_driver_model_users_tokens_ce, "findone", &_2, 42, _3); zephir_check_call_status(); if (zephir_is_true(token)) { - ZEPHIR_CALL_METHOD(&user, token, "getuser", NULL); + ZEPHIR_CALL_METHOD(&user, token, "getuser", NULL, 0); zephir_check_call_status(); _4 = zephir_is_true(user); if (_4) { - ZEPHIR_INIT_VAR(_5); - ZEPHIR_INIT_NVAR(_5); - ZVAL_STRING(_5, "useragent", 1); - ZEPHIR_OBS_VAR(_6); - zephir_read_property_zval(&_6, token, _5, PH_NOISY_CC); - _7 = zephir_fetch_nproperty_this(this_ptr, SL("_request"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_8, _7, "getuseragent", NULL); + ZEPHIR_OBS_VAR(_5); + zephir_read_property(&_5, token, SL("useragent"), PH_NOISY_CC); + _6 = zephir_fetch_nproperty_this(this_ptr, SL("request"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_7, _6, "getuseragent", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_9, "sha1", &_10, _8); + ZEPHIR_CALL_FUNCTION(&_8, "sha1", NULL, 43, _7); zephir_check_call_status(); - _4 = ZEPHIR_IS_IDENTICAL(_6, _9); + _4 = ZEPHIR_IS_IDENTICAL(_5, _8); } if (_4) { - ZEPHIR_CALL_METHOD(&userRoles, user, "getroles", NULL); + ZEPHIR_CALL_METHOD(&userRoles, user, "getroles", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(roles); array_init(roles); - _11 = zephir_get_iterator(userRoles TSRMLS_CC); - _11->funcs->rewind(_11 TSRMLS_CC); - for (;_11->funcs->valid(_11 TSRMLS_CC) == SUCCESS && !EG(exception); _11->funcs->move_forward(_11 TSRMLS_CC)) { - { zval **tmp; - _11->funcs->get_current_data(_11, &tmp TSRMLS_CC); - role = *tmp; + _9 = zephir_get_iterator(userRoles TSRMLS_CC); + _9->funcs->rewind(_9 TSRMLS_CC); + for (;_9->funcs->valid(_9 TSRMLS_CC) == SUCCESS && !EG(exception); _9->funcs->move_forward(_9 TSRMLS_CC)) { + { + zval **ZEPHIR_TMP_ITERATOR_PTR; + _9->funcs->get_current_data(_9, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); + ZEPHIR_CPY_WRT(role, (*ZEPHIR_TMP_ITERATOR_PTR)); } - ZEPHIR_CALL_METHOD(&_12, role, "getrole", NULL); + ZEPHIR_CALL_METHOD(&_10, role, "getrole", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(role, _12); + ZEPHIR_CPY_WRT(role, _10); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "name", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_12, role, "get", &_13, _1); + ZEPHIR_CALL_METHOD(&_10, role, "get", &_11, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); - zephir_array_append(&roles, _12, PH_SEPARATE, "ice/auth/driver/model.zep", 51); + zephir_array_append(&roles, _10, PH_SEPARATE, "ice/auth/driver/model.zep", 51); } - _11->funcs->dtor(_11 TSRMLS_CC); - ZEPHIR_SINIT_VAR(_14); - ZVAL_STRING(&_14, "login", 0); - if (zephir_fast_in_array(&_14, roles TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, token, "update", NULL); + _9->funcs->dtor(_9 TSRMLS_CC); + ZEPHIR_SINIT_VAR(_12); + ZVAL_STRING(&_12, "login", 0); + if (zephir_fast_in_array(&_12, roles TSRMLS_CC)) { + ZEPHIR_CALL_METHOD(NULL, token, "update", NULL, 0); zephir_check_call_status(); - _15 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_16); - ZEPHIR_INIT_NVAR(_16); - ZVAL_STRING(_16, "token", 1); - ZEPHIR_OBS_VAR(_17); - zephir_read_property_zval(&_17, token, _16, PH_NOISY_CC); - ZEPHIR_INIT_VAR(_18); - ZEPHIR_INIT_NVAR(_18); - ZVAL_STRING(_18, "expires", 1); - ZEPHIR_OBS_VAR(_19); - zephir_read_property_zval(&_19, token, _18, PH_NOISY_CC); + _13 = zephir_fetch_nproperty_this(this_ptr, SL("cookies"), PH_NOISY_CC); + ZEPHIR_OBS_VAR(_14); + zephir_read_property(&_14, token, SL("token"), PH_NOISY_CC); + ZEPHIR_OBS_VAR(_15); + zephir_read_property(&_15, token, SL("expires"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "auth_autologin", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _15, "set", NULL, _1, _17, _19); + ZEPHIR_CALL_METHOD(NULL, _13, "set", NULL, 0, _1, _14, _15); zephir_check_temp_parameter(_1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "completelogin", NULL, user, roles); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "completelogin", NULL, 0, user, roles); zephir_check_call_status(); RETURN_CCTOR(user); } } - ZEPHIR_CALL_METHOD(NULL, token, "remove", NULL); + ZEPHIR_CALL_METHOD(NULL, token, "remove", NULL, 0); zephir_check_call_status(); } } @@ -153,7 +143,7 @@ PHP_METHOD(Ice_Auth_Driver_Model, autoLogin) { */ PHP_METHOD(Ice_Auth_Driver_Model, completeLogin) { - zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_2 = NULL; + zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *roles = NULL; zval *user, *roles_param = NULL, *_1 = NULL; @@ -170,11 +160,11 @@ PHP_METHOD(Ice_Auth_Driver_Model, completeLogin) { if (zephir_instance_of_ev(user, ice_auth_driver_model_users_ce TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, user, "completelogin", NULL); + ZEPHIR_CALL_METHOD(NULL, user, "completelogin", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_1, "serialize", &_2, user); + ZEPHIR_CALL_FUNCTION(&_1, "serialize", NULL, 14, user); zephir_check_call_status(); - ZEPHIR_CALL_PARENT(NULL, ice_auth_driver_model_ce, this_ptr, "completelogin", &_0, _1, roles); + ZEPHIR_CALL_PARENT(NULL, ice_auth_driver_model_ce, this_ptr, "completelogin", &_0, 44, _1, roles); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); @@ -190,8 +180,8 @@ PHP_METHOD(Ice_Auth_Driver_Model, completeLogin) { PHP_METHOD(Ice_Auth_Driver_Model, getUser) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_3 = NULL; - zval *defaultValue = NULL, *data = NULL, *_0, *_2 = NULL, *_4; + zephir_fcall_cache_entry *_1 = NULL; + zval *defaultValue = NULL, *data = NULL, *_0, *user = NULL, *_2, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &defaultValue); @@ -201,25 +191,27 @@ PHP_METHOD(Ice_Auth_Driver_Model, getUser) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_user"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("user"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { - ZEPHIR_CALL_PARENT(&data, ice_auth_driver_model_ce, this_ptr, "getuser", &_1, defaultValue); + ZEPHIR_CALL_PARENT(&data, ice_auth_driver_model_ce, this_ptr, "getuser", &_1, 41, defaultValue); zephir_check_call_status(); if (ZEPHIR_IS_IDENTICAL(data, defaultValue)) { - zephir_update_property_this(this_ptr, SL("_user"), defaultValue TSRMLS_CC); - } else { - ZEPHIR_CALL_FUNCTION(&_2, "unserialize", &_3, data); + zephir_update_property_this(this_ptr, SL("user"), defaultValue TSRMLS_CC); + } else if (Z_TYPE_P(data) == IS_STRING) { + ZEPHIR_CALL_FUNCTION(&user, "unserialize", NULL, 17, data); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_user"), _2 TSRMLS_CC); + if (zephir_instance_of_ev(user, ice_auth_driver_model_users_ce TSRMLS_CC)) { + zephir_update_property_this(this_ptr, SL("user"), user TSRMLS_CC); + } } } - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_user"), PH_NOISY_CC); - if (!(zephir_is_true(_4))) { - ZEPHIR_CALL_METHOD(&_2, this_ptr, "autologin", NULL); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("user"), PH_NOISY_CC); + if (!(zephir_is_true(_2))) { + ZEPHIR_CALL_METHOD(&_3, this_ptr, "autologin", NULL, 0); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_user"), _2 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("user"), _3 TSRMLS_CC); } - RETURN_MM_MEMBER(this_ptr, "_user"); + RETURN_MM_MEMBER(this_ptr, "user"); } @@ -254,7 +246,7 @@ PHP_METHOD(Ice_Auth_Driver_Model, hasRole) { } if (_0) { ZEPHIR_INIT_VAR(_1); - ZEPHIR_CALL_METHOD(&_2, user, "getrole", NULL, role); + ZEPHIR_CALL_METHOD(&_2, user, "getrole", NULL, 0, role); zephir_check_call_status(); if (zephir_is_true(_2)) { ZVAL_BOOL(_1, 1); @@ -263,7 +255,7 @@ PHP_METHOD(Ice_Auth_Driver_Model, hasRole) { } RETURN_CCTOR(_1); } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "User must be an object", "ice/auth/driver/model.zep", 132); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "User must be an object", "ice/auth/driver/model.zep", 138); return; } @@ -279,7 +271,6 @@ PHP_METHOD(Ice_Auth_Driver_Model, hasRole) { */ PHP_METHOD(Ice_Auth_Driver_Model, login) { - zephir_nts_static zephir_fcall_cache_entry *_14 = NULL; zephir_fcall_cache_entry *_9 = NULL; zend_object_iterator *_7; zend_class_entry *_3; @@ -287,7 +278,7 @@ PHP_METHOD(Ice_Auth_Driver_Model, login) { int ZEPHIR_LAST_CALL_STATUS; zend_bool remember, _4; zval *password = NULL; - zval *username, *password_param = NULL, *remember_param = NULL, *user = NULL, *users = NULL, *roles, *userRoles = NULL, *role = NULL, *token, *lifetime = NULL, *_0 = NULL, *_1 = NULL, *_5 = NULL, *_6 = NULL, *_8 = NULL, _10, *_11, *_12 = NULL, *_13 = NULL, *_15, *_16 = NULL, *_17, *_18 = NULL, *_19 = NULL; + zval *username, *password_param = NULL, *remember_param = NULL, *user = NULL, *users = NULL, *roles = NULL, *userRoles = NULL, *role = NULL, *token = NULL, *lifetime = NULL, *_0 = NULL, *_1 = NULL, *_5 = NULL, *_6 = NULL, *_8 = NULL, _10, *_11, *_12 = NULL, *_13 = NULL, *_14, *_15 = NULL, *_16, *_17 = NULL, *_18 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &username, &password_param, &remember_param); @@ -302,9 +293,6 @@ PHP_METHOD(Ice_Auth_Driver_Model, login) { ZEPHIR_INIT_VAR(user); ZVAL_NULL(user); - if (ZEPHIR_IS_EMPTY(password)) { - RETURN_MM_BOOL(0); - } if (zephir_is_true(username)) { if (Z_TYPE_P(username) == IS_OBJECT) { ZEPHIR_CPY_WRT(user, username); @@ -313,51 +301,57 @@ PHP_METHOD(Ice_Auth_Driver_Model, login) { ZVAL_STRING(_0, "users", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "Ice\\Auth\\Driver\\Model\\Users", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&users, this_ptr, "getoption", NULL, _0, _1); + ZEPHIR_CALL_METHOD(&users, this_ptr, "getoption", NULL, 0, _0, _1); zephir_check_temp_parameter(_0); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 2); + zephir_create_array(_2, 1, 0 TSRMLS_CC); zephir_array_update_string(&_2, SL("username"), &username, PH_COPY | PH_SEPARATE); - _3 = zend_fetch_class(Z_STRVAL_P(users), Z_STRLEN_P(users), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); - ZEPHIR_CALL_CE_STATIC(&user, _3, "findone", NULL, _2); + _3 = zephir_fetch_class(users TSRMLS_CC); + ZEPHIR_CALL_CE_STATIC(&user, _3, "findone", NULL, 0, _2); zephir_check_call_status(); } + } else { + RETURN_MM_NULL(); } _4 = Z_TYPE_P(user) == IS_OBJECT; if (_4) { _4 = (zephir_instance_of_ev(user, ice_auth_driver_model_users_ce TSRMLS_CC)); } if (_4) { + if (ZEPHIR_IS_EMPTY(password)) { + RETURN_MM_BOOL(0); + } ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "password", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_5, user, "get", NULL, _0); + ZEPHIR_CALL_METHOD(&_5, user, "get", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6, this_ptr, "hash", NULL, password); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "hash", NULL, 0, password); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(_5, _6)) { - ZEPHIR_CALL_METHOD(&userRoles, user, "getroles", NULL); + ZEPHIR_CALL_METHOD(&userRoles, user, "getroles", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(roles); array_init(roles); _7 = zephir_get_iterator(userRoles TSRMLS_CC); _7->funcs->rewind(_7 TSRMLS_CC); for (;_7->funcs->valid(_7 TSRMLS_CC) == SUCCESS && !EG(exception); _7->funcs->move_forward(_7 TSRMLS_CC)) { - { zval **tmp; - _7->funcs->get_current_data(_7, &tmp TSRMLS_CC); - role = *tmp; + { + zval **ZEPHIR_TMP_ITERATOR_PTR; + _7->funcs->get_current_data(_7, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); + ZEPHIR_CPY_WRT(role, (*ZEPHIR_TMP_ITERATOR_PTR)); } - ZEPHIR_CALL_METHOD(&_8, role, "getrole", NULL); + ZEPHIR_CALL_METHOD(&_8, role, "getrole", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(role, _8); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "name", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_8, role, "get", &_9, _0); + ZEPHIR_CALL_METHOD(&_8, role, "get", &_9, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); - zephir_array_append(&roles, _8, PH_SEPARATE, "ice/auth/driver/model.zep", 171); + zephir_array_append(&roles, _8, PH_SEPARATE, "ice/auth/driver/model.zep", 180); } _7->funcs->dtor(_7 TSRMLS_CC); ZEPHIR_SINIT_VAR(_10); @@ -366,23 +360,20 @@ PHP_METHOD(Ice_Auth_Driver_Model, login) { if (remember) { ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "lifetime", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&lifetime, this_ptr, "getoption", NULL, _0); + ZEPHIR_CALL_METHOD(&lifetime, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(token); object_init_ex(token, ice_auth_driver_model_users_tokens_ce); - ZEPHIR_CALL_METHOD(NULL, token, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, token, "__construct", NULL, 45); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_0); - ZVAL_STRING(_0, "id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_8, user, "get", NULL, _0); - zephir_check_temp_parameter(_0); + ZEPHIR_CALL_METHOD(&_8, user, "getid", NULL, 0); zephir_check_call_status(); zephir_update_property_zval(token, SL("user_id"), _8 TSRMLS_CC); - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_request"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_12, _11, "getuseragent", NULL); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("request"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_12, _11, "getuseragent", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_13, "sha1", &_14, _12); + ZEPHIR_CALL_FUNCTION(&_13, "sha1", NULL, 43, _12); zephir_check_call_status(); zephir_update_property_zval(token, SL("useragent"), _13 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); @@ -390,31 +381,31 @@ PHP_METHOD(Ice_Auth_Driver_Model, login) { zephir_update_property_zval(token, SL("created"), _0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); zephir_time(_1); - ZEPHIR_INIT_VAR(_15); - zephir_add_function_ex(_15, _1, lifetime TSRMLS_CC); - zephir_update_property_zval(token, SL("expires"), _15 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_16, token, "create", NULL); + ZEPHIR_INIT_VAR(_14); + zephir_add_function(_14, _1, lifetime); + zephir_update_property_zval(token, SL("expires"), _14 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_15, token, "create", NULL, 46); zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(_16)) { - _17 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); + if (ZEPHIR_IS_TRUE_IDENTICAL(_15)) { + _16 = zephir_fetch_nproperty_this(this_ptr, SL("cookies"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "token", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_18, token, "get", &_9, _1); + ZEPHIR_CALL_METHOD(&_17, token, "get", &_9, 27, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "expires", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_19, token, "get", &_9, _1); + ZEPHIR_CALL_METHOD(&_18, token, "get", &_9, 27, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "auth_autologin", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _17, "set", NULL, _1, _18, _19); + ZEPHIR_CALL_METHOD(NULL, _16, "set", NULL, 0, _1, _17, _18); zephir_check_temp_parameter(_1); zephir_check_call_status(); } } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "completelogin", NULL, user, roles); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "completelogin", NULL, 0, user, roles); zephir_check_call_status(); RETURN_MM_BOOL(1); } @@ -435,13 +426,12 @@ PHP_METHOD(Ice_Auth_Driver_Model, login) { */ PHP_METHOD(Ice_Auth_Driver_Model, loginBy) { - zephir_fcall_cache_entry *_8 = NULL; zend_object_iterator *_7; int ZEPHIR_LAST_CALL_STATUS; zval *_1; - zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_14 = NULL; + zephir_fcall_cache_entry *_0 = NULL, *_8 = NULL; zend_bool remember, _5, _6; - zval *social, *remember_param = NULL, *user = NULL, *userSocial = NULL, *roles, *userRoles = NULL, *role = NULL, *token, *lifetime = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, _9, *_10 = NULL, *_11, *_12 = NULL, *_13 = NULL, *_15 = NULL, *_16, *_17 = NULL, *_18, *_19 = NULL, *_20 = NULL; + zval *social, *remember_param = NULL, *user = NULL, *userSocial = NULL, *roles = NULL, *userRoles = NULL, *role = NULL, *token = NULL, *lifetime = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, _9, *_10 = NULL, *_11, *_12 = NULL, *_13 = NULL, *_14 = NULL, *_15, *_16 = NULL, *_17, *_18 = NULL, *_19 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &social, &remember_param); @@ -454,52 +444,53 @@ PHP_METHOD(Ice_Auth_Driver_Model, loginBy) { ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 3); + zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "socialId", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_2, social, "get", NULL, _3); + ZEPHIR_CALL_METHOD(&_2, social, "get", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_array_update_string(&_1, SL("social_id"), &_2, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_2, social, "getadapter", NULL); + ZEPHIR_CALL_METHOD(&_2, social, "getadapter", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, _2, "getprovider", NULL); + ZEPHIR_CALL_METHOD(&_4, _2, "getprovider", NULL, 0); zephir_check_call_status(); zephir_array_update_string(&_1, SL("type"), &_4, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_CE_STATIC(&userSocial, ice_auth_driver_model_users_social_ce, "findone", &_0, _1); + ZEPHIR_CALL_CE_STATIC(&userSocial, ice_auth_driver_model_users_social_ce, "findone", &_0, 42, _1); zephir_check_call_status(); _5 = Z_TYPE_P(userSocial) == IS_OBJECT; if (_5) { _5 = (zephir_instance_of_ev(userSocial, ice_auth_driver_model_users_social_ce TSRMLS_CC)); } if (_5) { - ZEPHIR_CALL_METHOD(&user, userSocial, "getuser", NULL); + ZEPHIR_CALL_METHOD(&user, userSocial, "getuser", NULL, 0); zephir_check_call_status(); _6 = Z_TYPE_P(user) == IS_OBJECT; if (_6) { _6 = (zephir_instance_of_ev(user, ice_auth_driver_model_users_ce TSRMLS_CC)); } if (_6) { - ZEPHIR_CALL_METHOD(&userRoles, user, "getroles", NULL); + ZEPHIR_CALL_METHOD(&userRoles, user, "getroles", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(roles); array_init(roles); _7 = zephir_get_iterator(userRoles TSRMLS_CC); _7->funcs->rewind(_7 TSRMLS_CC); for (;_7->funcs->valid(_7 TSRMLS_CC) == SUCCESS && !EG(exception); _7->funcs->move_forward(_7 TSRMLS_CC)) { - { zval **tmp; - _7->funcs->get_current_data(_7, &tmp TSRMLS_CC); - role = *tmp; + { + zval **ZEPHIR_TMP_ITERATOR_PTR; + _7->funcs->get_current_data(_7, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); + ZEPHIR_CPY_WRT(role, (*ZEPHIR_TMP_ITERATOR_PTR)); } - ZEPHIR_CALL_METHOD(&_4, role, "getrole", NULL); + ZEPHIR_CALL_METHOD(&_4, role, "getrole", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(role, _4); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "name", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_4, role, "get", &_8, _3); + ZEPHIR_CALL_METHOD(&_4, role, "get", &_8, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); - zephir_array_append(&roles, _4, PH_SEPARATE, "ice/auth/driver/model.zep", 229); + zephir_array_append(&roles, _4, PH_SEPARATE, "ice/auth/driver/model.zep", 238); } _7->funcs->dtor(_7 TSRMLS_CC); ZEPHIR_SINIT_VAR(_9); @@ -508,55 +499,52 @@ PHP_METHOD(Ice_Auth_Driver_Model, loginBy) { if (remember) { ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "lifetime", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&lifetime, this_ptr, "getoption", NULL, _3); + ZEPHIR_CALL_METHOD(&lifetime, this_ptr, "getoption", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); ZEPHIR_INIT_VAR(token); object_init_ex(token, ice_auth_driver_model_users_tokens_ce); - ZEPHIR_CALL_METHOD(NULL, token, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, token, "__construct", NULL, 45); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_10, user, "get", NULL, _3); - zephir_check_temp_parameter(_3); + ZEPHIR_CALL_METHOD(&_10, user, "getid", NULL, 0); zephir_check_call_status(); zephir_update_property_zval(token, SL("user_id"), _10 TSRMLS_CC); - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_request"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_12, _11, "getuseragent", NULL); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("request"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_12, _11, "getuseragent", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_13, "sha1", &_14, _12); + ZEPHIR_CALL_FUNCTION(&_13, "sha1", NULL, 43, _12); zephir_check_call_status(); zephir_update_property_zval(token, SL("useragent"), _13 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); zephir_time(_3); zephir_update_property_zval(token, SL("created"), _3 TSRMLS_CC); + ZEPHIR_INIT_VAR(_14); + zephir_time(_14); ZEPHIR_INIT_VAR(_15); - zephir_time(_15); - ZEPHIR_INIT_VAR(_16); - zephir_add_function_ex(_16, _15, lifetime TSRMLS_CC); - zephir_update_property_zval(token, SL("expires"), _16 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_17, token, "create", NULL); + zephir_add_function(_15, _14, lifetime); + zephir_update_property_zval(token, SL("expires"), _15 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_16, token, "create", NULL, 46); zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(_17)) { - _18 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); - ZEPHIR_INIT_NVAR(_15); - ZVAL_STRING(_15, "token", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_19, token, "get", &_8, _15); - zephir_check_temp_parameter(_15); + if (ZEPHIR_IS_TRUE_IDENTICAL(_16)) { + _17 = zephir_fetch_nproperty_this(this_ptr, SL("cookies"), PH_NOISY_CC); + ZEPHIR_INIT_NVAR(_14); + ZVAL_STRING(_14, "token", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_18, token, "get", &_8, 27, _14); + zephir_check_temp_parameter(_14); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_15); - ZVAL_STRING(_15, "expires", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_20, token, "get", &_8, _15); - zephir_check_temp_parameter(_15); + ZEPHIR_INIT_NVAR(_14); + ZVAL_STRING(_14, "expires", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_19, token, "get", &_8, 27, _14); + zephir_check_temp_parameter(_14); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_15); - ZVAL_STRING(_15, "auth_autologin", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _18, "set", NULL, _15, _19, _20); - zephir_check_temp_parameter(_15); + ZEPHIR_INIT_NVAR(_14); + ZVAL_STRING(_14, "auth_autologin", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _17, "set", NULL, 0, _14, _18, _19); + zephir_check_temp_parameter(_14); zephir_check_call_status(); } } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "completelogin", NULL, user, roles); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "completelogin", NULL, 0, user, roles); zephir_check_call_status(); RETURN_MM_BOOL(1); } @@ -577,9 +565,9 @@ PHP_METHOD(Ice_Auth_Driver_Model, loginBy) { PHP_METHOD(Ice_Auth_Driver_Model, logout) { zval *_4 = NULL; - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; + zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *destroy_param = NULL, *logoutAll_param = NULL, *token = NULL, *tokens, *user = NULL, *_0, *_1 = NULL, *_2, *_5 = NULL; + zval *destroy_param = NULL, *logoutAll_param = NULL, *token = NULL, *tokens = NULL, *user = NULL, *_0, *_1 = NULL, *_2, *_5 = NULL; zend_bool destroy, logoutAll; ZEPHIR_MM_GROW(); @@ -597,50 +585,53 @@ PHP_METHOD(Ice_Auth_Driver_Model, logout) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("cookies"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "auth_autologin", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&token, _0, "get", NULL, _1); + ZEPHIR_CALL_METHOD(&token, _0, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); if (zephir_is_true(token)) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_cookies"), PH_NOISY_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("cookies"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "auth_autologin", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _2, "remove", NULL, _1); + ZEPHIR_CALL_METHOD(NULL, _2, "remove", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); - array_init_size(_4, 2); + zephir_create_array(_4, 1, 0 TSRMLS_CC); zephir_array_update_string(&_4, SL("token"), &token, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_CE_STATIC(&token, ice_auth_driver_model_users_tokens_ce, "findone", &_3, _4); + ZEPHIR_CALL_CE_STATIC(&token, ice_auth_driver_model_users_tokens_ce, "findone", &_3, 42, _4); zephir_check_call_status(); if (zephir_is_true(token)) { - ZEPHIR_CALL_METHOD(NULL, token, "remove", NULL); + ZEPHIR_CALL_METHOD(NULL, token, "remove", NULL, 0); zephir_check_call_status(); } } if (logoutAll) { ZEPHIR_INIT_VAR(tokens); object_init_ex(tokens, ice_auth_driver_model_users_tokens_ce); - ZEPHIR_CALL_METHOD(NULL, tokens, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, tokens, "__construct", NULL, 45); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&user, this_ptr, "getuser", NULL); + ZEPHIR_CALL_METHOD(&user, this_ptr, "getuser", NULL, 0); zephir_check_call_status(); if (zephir_is_true(user)) { ZEPHIR_INIT_NVAR(_4); - array_init_size(_4, 2); - ZEPHIR_INIT_NVAR(_1); - ZVAL_STRING(_1, "id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_5, user, "get", NULL, _1); - zephir_check_temp_parameter(_1); + zephir_create_array(_4, 1, 0 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_5, user, "getid", NULL, 0); zephir_check_call_status(); zephir_array_update_string(&_4, SL("user_id"), &_5, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, tokens, "remove", NULL, _4); + ZEPHIR_CALL_METHOD(NULL, tokens, "remove", NULL, 47, _4); zephir_check_call_status(); } } - ZEPHIR_RETURN_CALL_PARENT(ice_auth_driver_model_ce, this_ptr, "logout", &_6, (destroy ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false))); + ZEPHIR_INIT_NVAR(_1); + if (destroy) { + ZVAL_BOOL(_1, 1); + } else { + ZVAL_BOOL(_1, 0); + } + ZEPHIR_RETURN_CALL_PARENT(ice_auth_driver_model_ce, this_ptr, "logout", &_6, 48, _1); zephir_check_call_status(); RETURN_MM(); @@ -654,16 +645,15 @@ PHP_METHOD(Ice_Auth_Driver_Model, logout) { */ PHP_METHOD(Ice_Auth_Driver_Model, refreshUser) { - zephir_nts_static zephir_fcall_cache_entry *_9 = NULL, *_10 = NULL; - zephir_fcall_cache_entry *_8 = NULL; + zephir_fcall_cache_entry *_8 = NULL, *_9 = NULL; zend_object_iterator *_6; zend_bool _0, _1; int ZEPHIR_LAST_CALL_STATUS; - zval *user = NULL, *refreshed = NULL, *userRoles = NULL, *userRole = NULL, *roles, *role = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL; + zval *user = NULL, *refreshed = NULL, *userRoles = NULL, *userRole = NULL, *roles = NULL, *role = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_7 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&user, this_ptr, "getuser", NULL); + ZEPHIR_CALL_METHOD(&user, this_ptr, "getuser", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(user))) { RETURN_MM_NULL(); @@ -676,46 +666,47 @@ PHP_METHOD(Ice_Auth_Driver_Model, refreshUser) { if (_1) { ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "session_roles", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getoption", NULL, _3); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getoption", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); _1 = zephir_is_true(_2); } if (_1) { - ZEPHIR_CALL_METHOD(&_5, user, "getprimary", NULL); + ZEPHIR_CALL_METHOD(&_5, user, "getprimary", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, user, "get", NULL, _5); + ZEPHIR_CALL_METHOD(&_4, user, "get", NULL, 0, _5); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&refreshed, user, "loadone", NULL, _4); + ZEPHIR_CALL_METHOD(&refreshed, user, "loadone", NULL, 0, _4); zephir_check_call_status(); ZEPHIR_CPY_WRT(user, refreshed); - ZEPHIR_CALL_METHOD(&userRoles, user, "getroles", NULL); + ZEPHIR_CALL_METHOD(&userRoles, user, "getroles", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(roles); array_init(roles); _6 = zephir_get_iterator(userRoles TSRMLS_CC); _6->funcs->rewind(_6 TSRMLS_CC); for (;_6->funcs->valid(_6 TSRMLS_CC) == SUCCESS && !EG(exception); _6->funcs->move_forward(_6 TSRMLS_CC)) { - { zval **tmp; - _6->funcs->get_current_data(_6, &tmp TSRMLS_CC); - userRole = *tmp; + { + zval **ZEPHIR_TMP_ITERATOR_PTR; + _6->funcs->get_current_data(_6, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); + ZEPHIR_CPY_WRT(userRole, (*ZEPHIR_TMP_ITERATOR_PTR)); } - ZEPHIR_CALL_METHOD(&_7, userRole, "getrole", NULL); + ZEPHIR_CALL_METHOD(&_7, userRole, "getrole", NULL, 0); zephir_check_call_status(); ZEPHIR_CPY_WRT(role, _7); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "name", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_7, role, "get", &_8, _3); + ZEPHIR_CALL_METHOD(&_7, role, "get", &_8, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); - zephir_array_append(&roles, _7, PH_SEPARATE, "ice/auth/driver/model.zep", 324); + zephir_array_append(&roles, _7, PH_SEPARATE, "ice/auth/driver/model.zep", 333); } _6->funcs->dtor(_6 TSRMLS_CC); - ZEPHIR_CALL_FUNCTION(&_7, "serialize", &_10, user); + ZEPHIR_CALL_FUNCTION(&_7, "serialize", NULL, 14, user); zephir_check_call_status(); - ZEPHIR_CALL_PARENT(NULL, ice_auth_driver_model_ce, this_ptr, "completelogin", &_9, _7, roles); + ZEPHIR_CALL_PARENT(NULL, ice_auth_driver_model_ce, this_ptr, "completelogin", &_9, 44, _7, roles); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_user"), user TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("user"), user TSRMLS_CC); } } RETURN_CCTOR(user); diff --git a/ext/ice/auth/driver/model.zep.h b/ext/ice/auth/driver/model.zep.h index 637e2f97..0f899619 100644 --- a/ext/ice/auth/driver/model.zep.h +++ b/ext/ice/auth/driver/model.zep.h @@ -51,5 +51,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_driver_model_method_entry) { PHP_ME(Ice_Auth_Driver_Model, loginBy, arginfo_ice_auth_driver_model_loginby, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver_Model, logout, arginfo_ice_auth_driver_model_logout, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver_Model, refreshUser, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/driver/model/roles.zep.c b/ext/ice/auth/driver/model/roles.zep.c index b7db2fbe..6e508715 100644 --- a/ext/ice/auth/driver/model/roles.zep.c +++ b/ext/ice/auth/driver/model/roles.zep.c @@ -14,6 +14,7 @@ #include "kernel/main.h" #include "kernel/fcall.h" #include "kernel/memory.h" +#include "kernel/array.h" /** @@ -40,23 +41,22 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_Model_Roles) { */ PHP_METHOD(Ice_Auth_Driver_Model_Roles, initialize) { + zval *_1; int ZEPHIR_LAST_CALL_STATUS; - zval *_1, *_2, *_3; - zval *_0; + zval *_0 = NULL, *_2, *_3; ZEPHIR_MM_GROW(); - ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 2); - add_assoc_stringl_ex(_0, SS("alias"), SL("RolesUsers"), 1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getidkey", NULL, 0); + zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); - ZVAL_STRING(_1, "id", ZEPHIR_TEMP_PARAM_COPY); + zephir_create_array(_1, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_1, SS("alias"), SL("RolesUsers"), 1); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "Ice\\Auth\\Driver\\Model\\Roles\\Users", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "role_id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasmany", NULL, _1, _2, _3, _0); - zephir_check_temp_parameter(_1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasmany", NULL, 0, _0, _2, _3, _1); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); diff --git a/ext/ice/auth/driver/model/roles.zep.h b/ext/ice/auth/driver/model/roles.zep.h index 6bd4b55a..2291098c 100644 --- a/ext/ice/auth/driver/model/roles.zep.h +++ b/ext/ice/auth/driver/model/roles.zep.h @@ -7,5 +7,5 @@ PHP_METHOD(Ice_Auth_Driver_Model_Roles, initialize); ZEPHIR_INIT_FUNCS(ice_auth_driver_model_roles_method_entry) { PHP_ME(Ice_Auth_Driver_Model_Roles, initialize, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/driver/model/roles/users.zep.c b/ext/ice/auth/driver/model/roles/users.zep.c index 22ca0d1b..dd9e3ca9 100644 --- a/ext/ice/auth/driver/model/roles/users.zep.c +++ b/ext/ice/auth/driver/model/roles/users.zep.c @@ -14,6 +14,7 @@ #include "kernel/main.h" #include "kernel/memory.h" #include "kernel/fcall.h" +#include "kernel/array.h" /** @@ -29,7 +30,7 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_Model_Roles_Users) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Auth\\Driver\\Model\\Roles, Users, ice, auth_driver_model_roles_users, ice_mvc_model_ce, ice_auth_driver_model_roles_users_method_entry, 0); - zend_declare_property_string(ice_auth_driver_model_roles_users_ce, SL("_from"), "roles_users", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_auth_driver_model_roles_users_ce, SL("from"), "roles_users", ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -42,48 +43,53 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_Model_Roles_Users) { */ PHP_METHOD(Ice_Auth_Driver_Model_Roles_Users, initialize) { - zval *_4, *_5; + zval *_6, *_8; int ZEPHIR_LAST_CALL_STATUS; - zval *auth = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_6; + zval *auth = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3, *_4 = NULL, *_5 = NULL, *_7 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&auth, _0, "getauth", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); + ZEPHIR_INIT_VAR(_1); + ZVAL_STRING(_1, "auth", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); - ZVAL_STRING(_2, "users", ZEPHIR_TEMP_PARAM_COPY); + ZVAL_NULL(_2); ZEPHIR_INIT_VAR(_3); - ZVAL_STRING(_3, "Ice\\Auth\\Driver\\Model\\Users", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, auth, "getoption", NULL, _2, _3); - zephir_check_temp_parameter(_2); - zephir_check_temp_parameter(_3); + ZVAL_BOOL(_3, 1); + ZEPHIR_CALL_METHOD(&auth, _0, "get", NULL, 0, _1, _2, _3); + zephir_check_temp_parameter(_1); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_4); - array_init_size(_4, 2); - add_assoc_stringl_ex(_4, SS("alias"), SL("User"), 1); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "users", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_2); - ZVAL_STRING(_2, "user_id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "belongsto", NULL, _2, _1, _3, _4); + ZVAL_STRING(_2, "Ice\\Auth\\Driver\\Model\\Users", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_4, auth, "getoption", NULL, 0, _1, _2); + zephir_check_temp_parameter(_1); zephir_check_temp_parameter(_2); - zephir_check_temp_parameter(_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_5); - array_init_size(_5, 2); - add_assoc_stringl_ex(_5, SS("alias"), SL("Role"), 1); - ZEPHIR_INIT_NVAR(_2); - ZVAL_STRING(_2, "role_id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "Ice\\Auth\\Driver\\Model\\Roles", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getidkey", NULL, 0); + zephir_check_call_status(); ZEPHIR_INIT_VAR(_6); - ZVAL_STRING(_6, "id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "belongsto", NULL, _2, _3, _6, _5); + zephir_create_array(_6, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_6, SS("alias"), SL("User"), 1); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "user_id", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "belongsto", NULL, 0, _1, _4, _5, _6); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "getidkey", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(_8); + zephir_create_array(_8, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_8, SS("alias"), SL("Role"), 1); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "role_id", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_2); + ZVAL_STRING(_2, "Ice\\Auth\\Driver\\Model\\Roles", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "belongsto", NULL, 0, _1, _2, _7, _8); + zephir_check_temp_parameter(_1); zephir_check_temp_parameter(_2); - zephir_check_temp_parameter(_3); - zephir_check_temp_parameter(_6); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); diff --git a/ext/ice/auth/driver/model/roles/users.zep.h b/ext/ice/auth/driver/model/roles/users.zep.h index 93748cee..e02d1a24 100644 --- a/ext/ice/auth/driver/model/roles/users.zep.h +++ b/ext/ice/auth/driver/model/roles/users.zep.h @@ -7,5 +7,5 @@ PHP_METHOD(Ice_Auth_Driver_Model_Roles_Users, initialize); ZEPHIR_INIT_FUNCS(ice_auth_driver_model_roles_users_method_entry) { PHP_ME(Ice_Auth_Driver_Model_Roles_Users, initialize, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/driver/model/users.zep.c b/ext/ice/auth/driver/model/users.zep.c index 3d117506..62c86eef 100644 --- a/ext/ice/auth/driver/model/users.zep.c +++ b/ext/ice/auth/driver/model/users.zep.c @@ -14,10 +14,10 @@ #include "kernel/main.h" #include "kernel/fcall.h" #include "kernel/memory.h" +#include "kernel/array.h" #include "kernel/operators.h" #include "kernel/object.h" #include "kernel/time.h" -#include "kernel/array.h" /** @@ -44,51 +44,48 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_Model_Users) { */ PHP_METHOD(Ice_Auth_Driver_Model_Users, initialize) { + zval *_1, *_5, *_7; int ZEPHIR_LAST_CALL_STATUS; - zval *_1 = NULL, *_2 = NULL, *_3 = NULL; - zval *_0, *_4, *_5; + zval *_0 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 2); - add_assoc_stringl_ex(_0, SS("alias"), SL("Tokens"), 1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getidkey", NULL, 0); + zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); - ZVAL_STRING(_1, "id", ZEPHIR_TEMP_PARAM_COPY); + zephir_create_array(_1, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_1, SS("alias"), SL("Tokens"), 1); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "Ice\\Auth\\Driver\\Model\\Users\\Tokens", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "user_id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasmany", NULL, _1, _2, _3, _0); - zephir_check_temp_parameter(_1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasmany", NULL, 0, _0, _2, _3, _1); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_4); - array_init_size(_4, 2); - add_assoc_stringl_ex(_4, SS("alias"), SL("Roles"), 1); - ZEPHIR_INIT_NVAR(_1); - ZVAL_STRING(_1, "id", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "getidkey", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(_5); + zephir_create_array(_5, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_5, SS("alias"), SL("Roles"), 1); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "Ice\\Auth\\Driver\\Model\\Roles\\Users", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "user_id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasmany", NULL, _1, _2, _3, _4); - zephir_check_temp_parameter(_1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasmany", NULL, 0, _4, _2, _3, _5); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_5); - array_init_size(_5, 2); - add_assoc_stringl_ex(_5, SS("alias"), SL("Social"), 1); - ZEPHIR_INIT_NVAR(_1); - ZVAL_STRING(_1, "id", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "getidkey", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(_7); + zephir_create_array(_7, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_7, SS("alias"), SL("Social"), 1); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "Ice\\Auth\\Driver\\Model\\Users\\Social", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "user_id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasone", NULL, _1, _2, _3, _5); - zephir_check_temp_parameter(_1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasone", NULL, 0, _6, _2, _3, _7); zephir_check_temp_parameter(_2); zephir_check_temp_parameter(_3); zephir_check_call_status(); @@ -110,16 +107,16 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users, completeLogin) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "logins", 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(); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, (zephir_get_numberval(_0) + 1)); - zephir_update_property_zval(this_ptr, SL("logins"), _1 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("logins"), _1 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); zephir_time(_2); - zephir_update_property_zval(this_ptr, SL("lastlogin"), _2 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "update", NULL); + zephir_update_property_this(this_ptr, SL("lastlogin"), _2 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "update", NULL, 0); zephir_check_call_status(); RETURN_THIS(); @@ -135,7 +132,7 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users, getRole) { int ZEPHIR_LAST_CALL_STATUS; zval *_2, *_3; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL; zval *name_param = NULL, *role = NULL, *roles = NULL, *_0 = NULL, *_4 = NULL, *_5 = NULL; zval *name = NULL; @@ -151,31 +148,28 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users, getRole) { ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 2); + zephir_create_array(_2, 1, 0 TSRMLS_CC); zephir_array_update_string(&_2, SL("name"), &name, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_CE_STATIC(&_0, ice_auth_driver_model_roles_ce, "findone", &_1, _2); + ZEPHIR_CALL_CE_STATIC(&_0, ice_auth_driver_model_roles_ce, "findone", &_1, 42, _2); zephir_check_call_status(); ZEPHIR_CPY_WRT(role, _0); if (!(zephir_is_true(role))) { RETURN_MM_NULL(); } ZEPHIR_INIT_VAR(_3); - array_init_size(_3, 2); - ZEPHIR_INIT_VAR(_4); - ZVAL_STRING(_4, "id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_0, role, "get", NULL, _4); - zephir_check_temp_parameter(_4); + zephir_create_array(_3, 1, 0 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_0, role, "getid", NULL, 0); zephir_check_call_status(); zephir_array_update_string(&_3, SL("role_id"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&roles, this_ptr, "getroles", NULL, _3); + ZEPHIR_CALL_METHOD(&roles, this_ptr, "getroles", NULL, 0, _3); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_4); - ZEPHIR_CALL_METHOD(&_0, roles, "count", NULL); + ZEPHIR_INIT_VAR(_4); + ZEPHIR_CALL_METHOD(&_0, roles, "count", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_0)) { - ZEPHIR_CALL_METHOD(&_5, roles, "getiterator", NULL); + ZEPHIR_CALL_METHOD(&_5, roles, "getiterator", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, _5, "current", NULL); + ZEPHIR_CALL_METHOD(&_4, _5, "current", NULL, 0); zephir_check_call_status(); } else { ZVAL_BOOL(_4, 0); diff --git a/ext/ice/auth/driver/model/users.zep.h b/ext/ice/auth/driver/model/users.zep.h index 2cc7d487..b75345a7 100644 --- a/ext/ice/auth/driver/model/users.zep.h +++ b/ext/ice/auth/driver/model/users.zep.h @@ -15,5 +15,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_driver_model_users_method_entry) { PHP_ME(Ice_Auth_Driver_Model_Users, initialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver_Model_Users, completeLogin, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver_Model_Users, getRole, arginfo_ice_auth_driver_model_users_getrole, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/driver/model/users/social.zep.c b/ext/ice/auth/driver/model/users/social.zep.c index 5ecc943a..16cf9f52 100644 --- a/ext/ice/auth/driver/model/users/social.zep.c +++ b/ext/ice/auth/driver/model/users/social.zep.c @@ -30,7 +30,7 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_Model_Users_Social) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Auth\\Driver\\Model\\Users, Social, ice, auth_driver_model_users_social, ice_mvc_model_ce, ice_auth_driver_model_users_social_method_entry, 0); - zend_declare_property_string(ice_auth_driver_model_users_social_ce, SL("_from"), "user_social", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_auth_driver_model_users_social_ce, SL("from"), "user_social", ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -43,34 +43,40 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_Model_Users_Social) { */ PHP_METHOD(Ice_Auth_Driver_Model_Users_Social, initialize) { - zval *_4; + zval *_6; int ZEPHIR_LAST_CALL_STATUS; - zval *auth = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL; + zval *auth = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3, *_4 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&auth, _0, "getauth", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); + ZEPHIR_INIT_VAR(_1); + ZVAL_STRING(_1, "auth", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); - ZVAL_STRING(_2, "users", ZEPHIR_TEMP_PARAM_COPY); + ZVAL_NULL(_2); ZEPHIR_INIT_VAR(_3); - ZVAL_STRING(_3, "Ice\\Auth\\Driver\\Model\\Users", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, auth, "getoption", NULL, _2, _3); - zephir_check_temp_parameter(_2); - zephir_check_temp_parameter(_3); + ZVAL_BOOL(_3, 1); + ZEPHIR_CALL_METHOD(&auth, _0, "get", NULL, 0, _1, _2, _3); + zephir_check_temp_parameter(_1); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_4); - array_init_size(_4, 2); - add_assoc_stringl_ex(_4, SS("alias"), SL("User"), 1); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "users", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_2); - ZVAL_STRING(_2, "user_id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasone", NULL, _2, _1, _3, _4); + ZVAL_STRING(_2, "Ice\\Auth\\Driver\\Model\\Users", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_4, auth, "getoption", NULL, 0, _1, _2); + zephir_check_temp_parameter(_1); zephir_check_temp_parameter(_2); - zephir_check_temp_parameter(_3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getidkey", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(_6); + zephir_create_array(_6, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_6, SS("alias"), SL("User"), 1); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "user_id", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "hasone", NULL, 0, _1, _4, _5, _6); + zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -90,14 +96,14 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Social, onConstruct) { ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "social_id", 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "type", 1); zephir_array_fast_append(_0, _1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setprimary", NULL, _0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setprimary", NULL, 0, _0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); diff --git a/ext/ice/auth/driver/model/users/social.zep.h b/ext/ice/auth/driver/model/users/social.zep.h index 5542c8b2..7090c14d 100644 --- a/ext/ice/auth/driver/model/users/social.zep.h +++ b/ext/ice/auth/driver/model/users/social.zep.h @@ -9,5 +9,5 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Social, onConstruct); ZEPHIR_INIT_FUNCS(ice_auth_driver_model_users_social_method_entry) { PHP_ME(Ice_Auth_Driver_Model_Users_Social, initialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver_Model_Users_Social, onConstruct, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/driver/model/users/tokens.zep.c b/ext/ice/auth/driver/model/users/tokens.zep.c index 960dab55..d21bb596 100644 --- a/ext/ice/auth/driver/model/users/tokens.zep.c +++ b/ext/ice/auth/driver/model/users/tokens.zep.c @@ -15,6 +15,7 @@ #include "kernel/memory.h" #include "kernel/fcall.h" #include "kernel/array.h" +#include "kernel/math.h" #include "kernel/operators.h" #include "kernel/time.h" #include "kernel/object.h" @@ -34,7 +35,7 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_Model_Users_Tokens) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Auth\\Driver\\Model\\Users, Tokens, ice, auth_driver_model_users_tokens, ice_mvc_model_ce, ice_auth_driver_model_users_tokens_method_entry, 0); - zend_declare_property_string(ice_auth_driver_model_users_tokens_ce, SL("_from"), "user_tokens", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_auth_driver_model_users_tokens_ce, SL("from"), "user_tokens", ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -48,74 +49,77 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Driver_Model_Users_Tokens) { PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, initialize) { zend_bool _10, _12; - zephir_nts_static zephir_fcall_cache_entry *_8 = NULL; - zval *_4; + zval *_6; int ZEPHIR_LAST_CALL_STATUS; - zval *auth = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, _5, _6, *_7 = NULL, *_9 = NULL, *_11 = NULL, *_13 = NULL; + zval *auth = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3, *_4 = NULL, *_5 = NULL, _7, _8, *_9 = NULL, *_11 = NULL, *_13 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&auth, _0, "getauth", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); + ZEPHIR_INIT_VAR(_1); + ZVAL_STRING(_1, "auth", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); - ZVAL_STRING(_2, "users", ZEPHIR_TEMP_PARAM_COPY); + ZVAL_NULL(_2); ZEPHIR_INIT_VAR(_3); - ZVAL_STRING(_3, "Ice\\Auth\\Driver\\Model\\Users", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, auth, "getoption", NULL, _2, _3); - zephir_check_temp_parameter(_2); - zephir_check_temp_parameter(_3); + ZVAL_BOOL(_3, 1); + ZEPHIR_CALL_METHOD(&auth, _0, "get", NULL, 0, _1, _2, _3); + zephir_check_temp_parameter(_1); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_4); - array_init_size(_4, 3); - add_assoc_stringl_ex(_4, SS("alias"), SL("User"), 1); - zephir_array_update_string(&_4, SL("foreignKey"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "users", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_2); - ZVAL_STRING(_2, "user_id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "belongsto", NULL, _2, _1, _3, _4); + ZVAL_STRING(_2, "Ice\\Auth\\Driver\\Model\\Users", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_4, auth, "getoption", NULL, 0, _1, _2); + zephir_check_temp_parameter(_1); zephir_check_temp_parameter(_2); - zephir_check_temp_parameter(_3); zephir_check_call_status(); - ZEPHIR_SINIT_VAR(_5); - ZVAL_LONG(&_5, 1); - ZEPHIR_SINIT_VAR(_6); - ZVAL_LONG(&_6, 100); - ZEPHIR_CALL_FUNCTION(&_7, "mt_rand", &_8, &_5, &_6); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getidkey", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_LONG_IDENTICAL(_7, 1)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "deleteexpired", NULL); + ZEPHIR_INIT_VAR(_6); + zephir_create_array(_6, 2, 0 TSRMLS_CC); + add_assoc_stringl_ex(_6, SS("alias"), SL("User"), 1); + zephir_array_update_string(&_6, SL("foreignKey"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "user_id", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "belongsto", NULL, 0, _1, _4, _5, _6); + zephir_check_temp_parameter(_1); + zephir_check_call_status(); + ZEPHIR_SINIT_VAR(_7); + ZVAL_LONG(&_7, 1); + ZEPHIR_SINIT_VAR(_8); + ZVAL_LONG(&_8, 100); + if (zephir_mt_rand(zephir_get_intval(&_7), zephir_get_intval(&_8) TSRMLS_CC) == 1) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "deleteexpired", NULL, 0); zephir_check_call_status(); } - ZEPHIR_INIT_NVAR(_2); - ZVAL_STRING(_2, "expires", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_9, this_ptr, "has", NULL, _2); - zephir_check_temp_parameter(_2); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "expires", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "has", NULL, 0, _1); + zephir_check_temp_parameter(_1); zephir_check_call_status(); _10 = zephir_is_true(_9); if (_10) { - ZEPHIR_INIT_NVAR(_2); - ZVAL_STRING(_2, "expires", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_11, this_ptr, "get", NULL, _2); - zephir_check_temp_parameter(_2); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "expires", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_11, this_ptr, "get", NULL, 0, _1); + zephir_check_temp_parameter(_1); zephir_check_call_status(); _10 = zephir_is_true(_11); } _12 = _10; if (_12) { - ZEPHIR_INIT_NVAR(_2); - ZVAL_STRING(_2, "expires", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_13, this_ptr, "get", NULL, _2); - zephir_check_temp_parameter(_2); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "expires", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_13, this_ptr, "get", NULL, 27, _1); + zephir_check_temp_parameter(_1); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_2); - zephir_time(_2); - _12 = ZEPHIR_LT(_13, _2); + ZEPHIR_INIT_NVAR(_1); + zephir_time(_1); + _12 = ZEPHIR_LT(_13, _1); } if (_12) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); @@ -131,7 +135,7 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, initialize) { */ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, create) { - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *fields = NULL, *extra = NULL, *_0 = NULL; @@ -147,10 +151,10 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, create) { } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "_generate", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "generate", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, SL("token"), _0 TSRMLS_CC); - ZEPHIR_RETURN_CALL_PARENT(ice_auth_driver_model_users_tokens_ce, this_ptr, "create", &_1, fields); + zephir_update_property_this(this_ptr, SL("token"), _0 TSRMLS_CC); + ZEPHIR_RETURN_CALL_PARENT(ice_auth_driver_model_users_tokens_ce, this_ptr, "create", &_1, 49, fields); zephir_check_call_status(); RETURN_MM(); @@ -171,23 +175,24 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, deleteExpired) { ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 2); + zephir_create_array(_0, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 2); + zephir_create_array(_1, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); zephir_time(_2); zephir_array_update_string(&_1, SL("<"), &_2, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("expires"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&expired, this_ptr, "load", NULL, _0); + ZEPHIR_CALL_METHOD(&expired, this_ptr, "load", NULL, 0, _0); zephir_check_call_status(); _3 = zephir_get_iterator(expired TSRMLS_CC); _3->funcs->rewind(_3 TSRMLS_CC); for (;_3->funcs->valid(_3 TSRMLS_CC) == SUCCESS && !EG(exception); _3->funcs->move_forward(_3 TSRMLS_CC)) { - { zval **tmp; - _3->funcs->get_current_data(_3, &tmp TSRMLS_CC); - token = *tmp; + { + zval **ZEPHIR_TMP_ITERATOR_PTR; + _3->funcs->get_current_data(_3, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); + ZEPHIR_CPY_WRT(token, (*ZEPHIR_TMP_ITERATOR_PTR)); } - ZEPHIR_CALL_METHOD(NULL, token, "remove", NULL); + ZEPHIR_CALL_METHOD(NULL, token, "remove", NULL, 0); zephir_check_call_status(); } _3->funcs->dtor(_3 TSRMLS_CC); @@ -204,7 +209,7 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, deleteExpired) { */ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, update) { - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *fields = NULL, *extra = NULL, *_0 = NULL; @@ -220,10 +225,10 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, update) { } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "_generate", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "generate", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, SL("token"), _0 TSRMLS_CC); - ZEPHIR_RETURN_CALL_PARENT(ice_auth_driver_model_users_tokens_ce, this_ptr, "update", &_1, fields); + zephir_update_property_this(this_ptr, SL("token"), _0 TSRMLS_CC); + ZEPHIR_RETURN_CALL_PARENT(ice_auth_driver_model_users_tokens_ce, this_ptr, "update", &_1, 50, fields); zephir_check_call_status(); RETURN_MM(); @@ -235,12 +240,11 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, update) { * @return string * @uses Text::random() */ -PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, _generate) { +PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, generate) { zval *_8 = NULL; - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_1 = NULL, *_7 = NULL; + zephir_fcall_cache_entry *_1 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL; zval *token = NULL, *_0 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL; ZEPHIR_MM_GROW(); @@ -250,16 +254,16 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, _generate) { ZVAL_LONG(_2, 0); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 32); - ZEPHIR_CALL_CE_STATIC(&_0, ice_text_ce, "random", &_1, _2, _3); + ZEPHIR_CALL_CE_STATIC(&_0, ice_text_ce, "random", &_1, 0, _2, _3); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_4, "uniqid", &_5, _0, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_CALL_FUNCTION(&_4, "uniqid", &_5, 51, _0, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&token, "sha1", &_6, _4); + ZEPHIR_CALL_FUNCTION(&token, "sha1", &_6, 43, _4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_8); - array_init_size(_8, 2); + zephir_create_array(_8, 1, 0 TSRMLS_CC); zephir_array_update_string(&_8, SL("token"), &token, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_SELF(&_0, "findone", &_7, _8); + ZEPHIR_CALL_SELF(&_0, "findone", &_7, 0, _8); zephir_check_call_status(); } while (zephir_is_true(_0)); RETURN_CCTOR(token); diff --git a/ext/ice/auth/driver/model/users/tokens.zep.h b/ext/ice/auth/driver/model/users/tokens.zep.h index f47ff9f0..71b84d7a 100644 --- a/ext/ice/auth/driver/model/users/tokens.zep.h +++ b/ext/ice/auth/driver/model/users/tokens.zep.h @@ -7,7 +7,7 @@ PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, initialize); PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, create); PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, deleteExpired); PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, update); -PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, _generate); +PHP_METHOD(Ice_Auth_Driver_Model_Users_Tokens, generate); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_auth_driver_model_users_tokens_create, 0, 0, 0) ZEND_ARG_INFO(0, fields) @@ -24,6 +24,6 @@ ZEPHIR_INIT_FUNCS(ice_auth_driver_model_users_tokens_method_entry) { PHP_ME(Ice_Auth_Driver_Model_Users_Tokens, create, arginfo_ice_auth_driver_model_users_tokens_create, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver_Model_Users_Tokens, deleteExpired, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Driver_Model_Users_Tokens, update, arginfo_ice_auth_driver_model_users_tokens_update, ZEND_ACC_PUBLIC) - PHP_ME(Ice_Auth_Driver_Model_Users_Tokens, _generate, NULL, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_ME(Ice_Auth_Driver_Model_Users_Tokens, generate, NULL, ZEND_ACC_PROTECTED) + PHP_FE_END }; diff --git a/ext/ice/auth/social.zep.c b/ext/ice/auth/social.zep.c index a12ea431..8f025f54 100644 --- a/ext/ice/auth/social.zep.c +++ b/ext/ice/auth/social.zep.c @@ -32,7 +32,7 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Social) { ZEPHIR_REGISTER_CLASS(Ice\\Auth, Social, ice, auth_social, ice_auth_social_method_entry, 0); - zend_declare_property_null(ice_auth_social_ce, SL("_adapter"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_social_ce, SL("adapter"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -41,7 +41,7 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Social) { PHP_METHOD(Ice_Auth_Social, getAdapter) { - RETURN_MEMBER(this_ptr, "_adapter"); + RETURN_MEMBER(this_ptr, "adapter"); } @@ -58,7 +58,7 @@ PHP_METHOD(Ice_Auth_Social, __construct) { - zephir_update_property_this(this_ptr, SL("_adapter"), adapter TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("adapter"), adapter TSRMLS_CC); } @@ -74,8 +74,8 @@ PHP_METHOD(Ice_Auth_Social, authenticate) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_adapter"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "authenticate", NULL); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("adapter"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "authenticate", NULL, 0); zephir_check_call_status(); RETURN_MM(); @@ -103,8 +103,8 @@ PHP_METHOD(Ice_Auth_Social, get) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_adapter"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, key, defaultValue); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("adapter"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, key, defaultValue); zephir_check_call_status(); RETURN_MM(); @@ -134,9 +134,9 @@ PHP_METHOD(Ice_Auth_Social, __call) { ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_adapter"), PH_NOISY_CC); + zephir_read_property_this(&_1, this_ptr, SL("adapter"), PH_NOISY_CC); zephir_array_fast_append(_0, _1); zephir_array_fast_append(_0, method); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _0, arguments); diff --git a/ext/ice/auth/social.zep.h b/ext/ice/auth/social.zep.h index fa0749de..90a081bf 100644 --- a/ext/ice/auth/social.zep.h +++ b/ext/ice/auth/social.zep.h @@ -29,5 +29,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_social_method_entry) { PHP_ME(Ice_Auth_Social, authenticate, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social, get, arginfo_ice_auth_social_get, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social, __call, arginfo_ice_auth_social___call, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/social/adapter.zep.c b/ext/ice/auth/social/adapter.zep.c index 01cecb8f..dce6e2b5 100644 --- a/ext/ice/auth/social/adapter.zep.c +++ b/ext/ice/auth/social/adapter.zep.c @@ -22,26 +22,37 @@ #include "ext/spl/spl_exceptions.h" #include "kernel/concat.h" + +/** + * Auth social adapter. + * + * @package Ice/Auth + * @category Adapter + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Auth_Social_Adapter) { ZEPHIR_REGISTER_CLASS(Ice\\Auth\\Social, Adapter, ice, auth_social_adapter, ice_auth_social_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(ice_auth_social_adapter_ce, SL("_accessToken"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_social_adapter_ce, SL("accessToken"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_social_adapter_ce, SL("_clientId"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_social_adapter_ce, SL("clientId"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_social_adapter_ce, SL("_clientSecret"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_social_adapter_ce, SL("clientSecret"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_social_adapter_ce, SL("_redirectUri"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_social_adapter_ce, SL("redirectUri"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_social_adapter_ce, SL("_provider"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_social_adapter_ce, SL("provider"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_social_adapter_ce, SL("_socialFieldsMap"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_social_adapter_ce, SL("socialFieldsMap"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_auth_social_adapter_ce, SL("_userInfo"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_auth_social_adapter_ce, SL("userInfo"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_auth_social_adapter_ce, SL("_responseType"), "code", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_auth_social_adapter_ce, SL("responseType"), "code", ZEND_ACC_PROTECTED TSRMLS_CC); + ice_auth_social_adapter_ce->create_object = zephir_init_properties_Ice_Auth_Social_Adapter; zend_declare_class_constant_long(ice_auth_social_adapter_ce, SL("GET"), 0 TSRMLS_CC); zend_declare_class_constant_long(ice_auth_social_adapter_ce, SL("POST"), 1 TSRMLS_CC); @@ -59,28 +70,28 @@ PHP_METHOD(Ice_Auth_Social_Adapter, setAccessToken) { - zephir_update_property_this(this_ptr, SL("_accessToken"), accessToken TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("accessToken"), accessToken TSRMLS_CC); } PHP_METHOD(Ice_Auth_Social_Adapter, getAccessToken) { - RETURN_MEMBER(this_ptr, "_accessToken"); + RETURN_MEMBER(this_ptr, "accessToken"); } PHP_METHOD(Ice_Auth_Social_Adapter, getProvider) { - RETURN_MEMBER(this_ptr, "_provider"); + RETURN_MEMBER(this_ptr, "provider"); } PHP_METHOD(Ice_Auth_Social_Adapter, getResponseType) { - RETURN_MEMBER(this_ptr, "_responseType"); + RETURN_MEMBER(this_ptr, "responseType"); } @@ -92,11 +103,11 @@ PHP_METHOD(Ice_Auth_Social_Adapter, getResponseType) { */ PHP_METHOD(Ice_Auth_Social_Adapter, __construct) { - zval *_12; - zend_bool _5, _10; + zval *_13; + zend_bool _6, _11; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL; - zval *config = NULL, *_0, *clientId, *clientSecret, *redirectUri, *tmp = NULL, *_1 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7, *_8 = NULL, *_9, *_11, *_13 = NULL; + zephir_fcall_cache_entry *_1 = NULL; + zval *config = NULL, *clientId = NULL, *clientSecret = NULL, *redirectUri = NULL, *tmp = NULL, *_0 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5, *_7 = NULL, *_8, *_9 = NULL, *_10, *_12; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &config); @@ -109,77 +120,81 @@ PHP_METHOD(Ice_Auth_Social_Adapter, __construct) { } - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_socialFieldsMap"), _0 TSRMLS_CC); if (!(zephir_fast_count_int(config TSRMLS_CC))) { - ZEPHIR_CALL_CE_STATIC(&_1, ice_di_ce, "fetch", &_2); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, _1, "getconfig", NULL); + ZEPHIR_CALL_CE_STATIC(&_0, ice_di_ce, "fetch", &_1, 8); zephir_check_call_status(); + ZEPHIR_INIT_VAR(_3); + ZVAL_STRING(_3, "config", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_4); - ZVAL_STRING(_4, "auth", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&tmp, _3, "get", NULL, _4); - zephir_check_temp_parameter(_4); + ZVAL_NULL(_4); + ZEPHIR_INIT_VAR(_5); + ZVAL_BOOL(_5, 1); + ZEPHIR_CALL_METHOD(&_2, _0, "get", NULL, 0, _3, _4, _5); + zephir_check_temp_parameter(_3); zephir_check_call_status(); - _5 = zephir_is_true(tmp); - if (_5) { - _7 = zephir_fetch_nproperty_this(this_ptr, SL("_provider"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_6, tmp, "has", NULL, _7); + ZEPHIR_INIT_NVAR(_3); + ZVAL_STRING(_3, "auth", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&tmp, _2, "get", NULL, 0, _3); + zephir_check_temp_parameter(_3); + zephir_check_call_status(); + _6 = zephir_is_true(tmp); + if (_6) { + _8 = zephir_fetch_nproperty_this(this_ptr, SL("provider"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_7, tmp, "has", NULL, 0, _8); zephir_check_call_status(); - _5 = zephir_is_true(_6); + _6 = zephir_is_true(_7); } - if (_5) { - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_provider"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_8, tmp, "get", NULL, _9); + if (_6) { + _10 = zephir_fetch_nproperty_this(this_ptr, SL("provider"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_9, tmp, "get", NULL, 0, _10); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&config, _8, "toarray", NULL); + ZEPHIR_CALL_METHOD(&config, _9, "toarray", NULL, 0); zephir_check_call_status(); } } ZEPHIR_OBS_VAR(clientId); if (zephir_array_isset_string_fetch(&clientId, config, SS("client_id"), 0 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_clientId"), clientId TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("clientId"), clientId TSRMLS_CC); } ZEPHIR_OBS_VAR(clientSecret); if (zephir_array_isset_string_fetch(&clientSecret, config, SS("client_secret"), 0 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_clientSecret"), clientSecret TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("clientSecret"), clientSecret TSRMLS_CC); } ZEPHIR_OBS_VAR(redirectUri); if (zephir_array_isset_string_fetch(&redirectUri, config, SS("redirect_uri"), 0 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_redirectUri"), redirectUri TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("redirectUri"), redirectUri TSRMLS_CC); } - _7 = zephir_fetch_nproperty_this(this_ptr, SL("_clientId"), PH_NOISY_CC); - _5 = !zephir_is_true(_7); - if (!(_5)) { - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_clientSecret"), PH_NOISY_CC); - _5 = !zephir_is_true(_9); + _8 = zephir_fetch_nproperty_this(this_ptr, SL("clientId"), PH_NOISY_CC); + _6 = !zephir_is_true(_8); + if (!(_6)) { + _10 = zephir_fetch_nproperty_this(this_ptr, SL("clientSecret"), PH_NOISY_CC); + _6 = !zephir_is_true(_10); } - _10 = _5; - if (!(_10)) { - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_redirectUri"), PH_NOISY_CC); - _10 = !zephir_is_true(_11); + _11 = _6; + if (!(_11)) { + _12 = zephir_fetch_nproperty_this(this_ptr, SL("redirectUri"), PH_NOISY_CC); + _11 = !zephir_is_true(_12); } - if (_10) { - ZEPHIR_INIT_NVAR(_4); - object_init_ex(_4, ice_exception_ce); - ZEPHIR_INIT_VAR(_12); - array_init_size(_12, 6); + if (_11) { + ZEPHIR_INIT_NVAR(_3); + object_init_ex(_3, ice_exception_ce); ZEPHIR_INIT_VAR(_13); - ZVAL_STRING(_13, "Option `%s`, `%s`, `%s` are required", 1); - zephir_array_fast_append(_12, _13); - ZEPHIR_INIT_NVAR(_13); - ZVAL_STRING(_13, "client_id", 1); - zephir_array_fast_append(_12, _13); - ZEPHIR_INIT_NVAR(_13); - ZVAL_STRING(_13, "client_secret", 1); - zephir_array_fast_append(_12, _13); - ZEPHIR_INIT_NVAR(_13); - ZVAL_STRING(_13, "redirect_uri", 1); - zephir_array_fast_append(_12, _13); - ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, _12); + zephir_create_array(_13, 4, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "Option `%s`, `%s`, `%s` are required", 1); + zephir_array_fast_append(_13, _4); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "client_id", 1); + zephir_array_fast_append(_13, _4); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "client_secret", 1); + zephir_array_fast_append(_13, _4); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "redirect_uri", 1); + zephir_array_fast_append(_13, _4); + ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 2, _13); zephir_check_call_status(); - zephir_throw_exception_debug(_4, "ice/auth/social/adapter.zep", 60 TSRMLS_CC); + zephir_throw_exception_debug(_3, "ice/auth/social/adapter.zep", 60 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } @@ -197,8 +212,7 @@ PHP_METHOD(Ice_Auth_Social_Adapter, __construct) { PHP_METHOD(Ice_Auth_Social_Adapter, __call) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL; - zval *name_param = NULL, *arguments = NULL, *key = NULL, *value, _0, *_1, *_3 = NULL; + zval *name_param = NULL, *arguments = NULL, *key = NULL, *value = NULL, _0, *_1, *_2 = NULL; zval *name = NULL; ZEPHIR_MM_GROW(); @@ -208,7 +222,6 @@ PHP_METHOD(Ice_Auth_Social_Adapter, __call) { 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 { @@ -225,14 +238,14 @@ PHP_METHOD(Ice_Auth_Social_Adapter, __call) { ZVAL_LONG(&_0, 3); ZEPHIR_INIT_VAR(_1); zephir_substr(_1, name, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CALL_FUNCTION(&key, "lcfirst", &_2, _1); + ZEPHIR_CALL_FUNCTION(&key, "lcfirst", NULL, 18, _1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, key); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "has", NULL, 0, key); zephir_check_call_status(); - if (zephir_is_true(_3)) { + if (zephir_is_true(_2)) { ZEPHIR_OBS_VAR(value); zephir_array_isset_long_fetch(&value, arguments, 0, 0 TSRMLS_CC); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, key, value); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, key, value); zephir_check_call_status(); RETURN_MM(); } else { @@ -260,13 +273,13 @@ PHP_METHOD(Ice_Auth_Social_Adapter, has) { zephir_get_strval(key, key_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_socialFieldsMap"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("socialFieldsMap"), PH_NOISY_CC); if (zephir_array_isset(_0, key)) { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_socialFieldsMap"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("socialFieldsMap"), PH_NOISY_CC); zephir_array_fetch(&_2, _1, key, PH_NOISY | PH_READONLY, "ice/auth/social/adapter.zep", 97 TSRMLS_CC); zephir_get_strval(key, _2); } - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_userInfo"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("userInfo"), PH_NOISY_CC); RETURN_MM_BOOL(zephir_array_isset(_1, key)); } @@ -281,7 +294,7 @@ PHP_METHOD(Ice_Auth_Social_Adapter, has) { */ PHP_METHOD(Ice_Auth_Social_Adapter, get) { - zval *key_param = NULL, *defaultValue = NULL, *value, *_0, *_1, *_2; + zval *key_param = NULL, *defaultValue = NULL, *value = NULL, *_0, *_1, *_2; zval *key = NULL; ZEPHIR_MM_GROW(); @@ -293,13 +306,13 @@ PHP_METHOD(Ice_Auth_Social_Adapter, get) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_socialFieldsMap"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("socialFieldsMap"), PH_NOISY_CC); if (zephir_array_isset(_0, key)) { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_socialFieldsMap"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("socialFieldsMap"), PH_NOISY_CC); zephir_array_fetch(&_2, _1, key, PH_NOISY | PH_READONLY, "ice/auth/social/adapter.zep", 117 TSRMLS_CC); zephir_get_strval(key, _2); } - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_userInfo"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("userInfo"), PH_NOISY_CC); if (zephir_array_isset_fetch(&value, _1, key, 1 TSRMLS_CC)) { RETURN_CTOR(value); } @@ -315,21 +328,20 @@ PHP_METHOD(Ice_Auth_Social_Adapter, get) { */ PHP_METHOD(Ice_Auth_Social_Adapter, getAuthUrl) { - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *config = NULL, *_0, *_1, *_2 = NULL, *_4 = NULL; + zval *config = NULL, *_0, *_1, *_2 = NULL, *_3 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&config, this_ptr, "prepareauthparams", NULL); + ZEPHIR_CALL_METHOD(&config, this_ptr, "prepareauthparams", NULL, 0); zephir_check_call_status(); zephir_array_fetch_string(&_0, config, SL("auth_url"), PH_NOISY | PH_READONLY, "ice/auth/social/adapter.zep", 138 TSRMLS_CC); zephir_array_fetch_string(&_1, config, SL("auth_params"), PH_NOISY | PH_READONLY, "ice/auth/social/adapter.zep", 138 TSRMLS_CC); - ZEPHIR_CALL_FUNCTION(&_2, "http_build_query", &_3, _1); + ZEPHIR_CALL_FUNCTION(&_2, "http_build_query", NULL, 19, _1); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_4, "urldecode", &_5, _2); + ZEPHIR_CALL_FUNCTION(&_3, "urldecode", NULL, 20, _2); zephir_check_call_status(); - ZEPHIR_CONCAT_VSV(return_value, _0, "?", _4); + ZEPHIR_CONCAT_VSV(return_value, _0, "?", _3); RETURN_MM(); } @@ -345,8 +357,7 @@ PHP_METHOD(Ice_Auth_Social_Adapter, getAuthUrl) { */ PHP_METHOD(Ice_Auth_Social_Adapter, call) { - zephir_fcall_cache_entry *_6 = NULL; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_3 = NULL; + zephir_fcall_cache_entry *_1 = NULL, *_3 = NULL, *_6 = NULL; zend_bool parse; zval *params = NULL; zval *url = NULL; @@ -370,50 +381,50 @@ PHP_METHOD(Ice_Auth_Social_Adapter, call) { } - ZEPHIR_CALL_FUNCTION(&curl, "curl_init", NULL); + ZEPHIR_CALL_FUNCTION(&curl, "curl_init", NULL, 21); zephir_check_call_status(); if (method == 0) { - ZEPHIR_CALL_FUNCTION(&_0, "http_build_query", &_1, params); + ZEPHIR_CALL_FUNCTION(&_0, "http_build_query", &_1, 19, params); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_2, "urldecode", &_3, _0); + ZEPHIR_CALL_FUNCTION(&_2, "urldecode", &_3, 20, _0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); ZEPHIR_CONCAT_VSV(_4, url, "?", _2); ZEPHIR_SINIT_VAR(_5); ZVAL_LONG(&_5, 10002); - ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, curl, &_5, _4); + ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, 22, curl, &_5, _4); zephir_check_call_status(); } else { ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 10002); - ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, curl, &_5, url); + ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, 22, curl, &_5, url); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 47); ZEPHIR_SINIT_VAR(_7); ZVAL_LONG(&_7, 1); - ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, curl, &_5, &_7); + ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, 22, curl, &_5, &_7); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_0, "http_build_query", &_1, params); + ZEPHIR_CALL_FUNCTION(&_0, "http_build_query", &_1, 19, params); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_2, "urldecode", &_3, _0); + ZEPHIR_CALL_FUNCTION(&_2, "urldecode", &_3, 20, _0); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 10015); - ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, curl, &_5, _2); + ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, 22, curl, &_5, _2); zephir_check_call_status(); } ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 19913); - ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, curl, &_5, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, 22, curl, &_5, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_5); ZVAL_LONG(&_5, 64); - ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, curl, &_5, ZEPHIR_GLOBAL(global_false)); + ZEPHIR_CALL_FUNCTION(NULL, "curl_setopt", &_6, 22, curl, &_5, ZEPHIR_GLOBAL(global_false)); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&result, "curl_exec", NULL, curl); + ZEPHIR_CALL_FUNCTION(&result, "curl_exec", NULL, 23, curl); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "curl_close", NULL, curl); + ZEPHIR_CALL_FUNCTION(NULL, "curl_close", NULL, 24, curl); zephir_check_call_status(); if (parse) { ZEPHIR_INIT_VAR(_8); @@ -424,3 +435,24 @@ PHP_METHOD(Ice_Auth_Social_Adapter, call) { } +static zend_object_value zephir_init_properties_Ice_Auth_Social_Adapter(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("socialFieldsMap"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("socialFieldsMap"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } + +} + diff --git a/ext/ice/auth/social/adapter.zep.h b/ext/ice/auth/social/adapter.zep.h index 84eae487..9d7aca64 100644 --- a/ext/ice/auth/social/adapter.zep.h +++ b/ext/ice/auth/social/adapter.zep.h @@ -13,6 +13,7 @@ PHP_METHOD(Ice_Auth_Social_Adapter, has); PHP_METHOD(Ice_Auth_Social_Adapter, get); PHP_METHOD(Ice_Auth_Social_Adapter, getAuthUrl); PHP_METHOD(Ice_Auth_Social_Adapter, call); +static zend_object_value zephir_init_properties_Ice_Auth_Social_Adapter(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_auth_social_adapter_setaccesstoken, 0, 0, 1) ZEND_ARG_INFO(0, accessToken) @@ -54,5 +55,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_social_adapter_method_entry) { PHP_ME(Ice_Auth_Social_Adapter, get, arginfo_ice_auth_social_adapter_get, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social_Adapter, getAuthUrl, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social_Adapter, call, arginfo_ice_auth_social_adapter_call, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/social/facebook.zep.c b/ext/ice/auth/social/facebook.zep.c index d4986d1e..7e8b5d9f 100644 --- a/ext/ice/auth/social/facebook.zep.c +++ b/ext/ice/auth/social/facebook.zep.c @@ -15,9 +15,9 @@ #include "kernel/object.h" #include "kernel/memory.h" #include "kernel/fcall.h" +#include "kernel/array.h" #include "kernel/operators.h" #include "kernel/concat.h" -#include "kernel/array.h" /** @@ -46,7 +46,7 @@ PHP_METHOD(Ice_Auth_Social_Facebook, __construct) { zval *_2; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL; zval *config = NULL, *_0; ZEPHIR_MM_GROW(); @@ -60,18 +60,18 @@ PHP_METHOD(Ice_Auth_Social_Facebook, __construct) { ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_STRING(_0, "facebook", 1); - zephir_update_property_this(this_ptr, SL("_provider"), _0 TSRMLS_CC); - ZEPHIR_CALL_PARENT(NULL, ice_auth_social_facebook_ce, this_ptr, "__construct", &_1, config); + zephir_update_property_this(this_ptr, SL("provider"), _0 TSRMLS_CC); + ZEPHIR_CALL_PARENT(NULL, ice_auth_social_facebook_ce, this_ptr, "__construct", &_1, 52, config); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 8); + zephir_create_array(_2, 6, 0 TSRMLS_CC); add_assoc_stringl_ex(_2, SS("socialId"), SL("id"), 1); add_assoc_stringl_ex(_2, SS("email"), SL("email"), 1); add_assoc_stringl_ex(_2, SS("name"), SL("name"), 1); add_assoc_stringl_ex(_2, SS("sex"), SL("gender"), 1); add_assoc_stringl_ex(_2, SS("socialPage"), SL("link"), 1); add_assoc_stringl_ex(_2, SS("birthday"), SL("birthday"), 1); - zephir_update_property_this(this_ptr, SL("_socialFieldsMap"), _2 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("socialFieldsMap"), _2 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -90,13 +90,13 @@ PHP_METHOD(Ice_Auth_Social_Facebook, getImage) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "id", 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, "id", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "get", NULL, _1); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CONCAT_SVS(return_value, "http://graph.facebook.com/", _2, "/picture?type=large"); @@ -113,33 +113,32 @@ PHP_METHOD(Ice_Auth_Social_Facebook, getImage) { */ PHP_METHOD(Ice_Auth_Social_Facebook, authenticate) { - zephir_nts_static zephir_fcall_cache_entry *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *params = NULL, *tokenInfo, *userInfo = NULL, *_GET, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5, *_8, *_9; - zend_bool result, _7; + zval *params = NULL, *tokenInfo = NULL, *userInfo = NULL, *_GET, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5, *_7, *_8; + zend_bool result = 0, _6; ZEPHIR_MM_GROW(); + zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); result = 0; ZEPHIR_INIT_VAR(tokenInfo); ZVAL_NULL(tokenInfo); - zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); if (zephir_array_isset_string(_GET, SS("code"))) { ZEPHIR_INIT_VAR(params); - array_init_size(params, 6); + zephir_create_array(params, 4, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_clientId"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("clientId"), PH_NOISY_CC); zephir_array_update_string(¶ms, SL("client_id"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_redirectUri"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("redirectUri"), PH_NOISY_CC); zephir_array_update_string(¶ms, SL("redirect_uri"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_clientSecret"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("clientSecret"), PH_NOISY_CC); zephir_array_update_string(¶ms, SL("client_secret"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_0); zephir_array_fetch_string(&_0, _GET, SL("code"), PH_NOISY, "ice/auth/social/facebook.zep", 69 TSRMLS_CC); zephir_array_update_string(¶ms, SL("code"), &_0, PH_COPY | PH_SEPARATE); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_accessToken"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("accessToken"), PH_NOISY_CC); if (!(zephir_is_true(_1))) { ZEPHIR_INIT_VAR(_3); ZVAL_LONG(_3, 0); @@ -147,38 +146,38 @@ PHP_METHOD(Ice_Auth_Social_Facebook, authenticate) { ZVAL_STRING(_4, "https://graph.facebook.com/oauth/access_token", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_5); ZVAL_BOOL(_5, 0); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "call", NULL, _3, _4, params, _5); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "call", NULL, 0, _3, _4, params, _5); zephir_check_temp_parameter(_4); zephir_check_call_status(); - Z_SET_ISREF_P(tokenInfo); - ZEPHIR_CALL_FUNCTION(NULL, "parse_str", &_6, _2, tokenInfo); - Z_UNSET_ISREF_P(tokenInfo); + ZEPHIR_MAKE_REF(tokenInfo); + ZEPHIR_CALL_FUNCTION(NULL, "parse_str", NULL, 53, _2, tokenInfo); + ZEPHIR_UNREF(tokenInfo); zephir_check_call_status(); - _7 = zephir_fast_count_int(tokenInfo TSRMLS_CC) > 0; - if (_7) { - _7 = zephir_array_isset_string(tokenInfo, SS("access_token")); + _6 = zephir_fast_count_int(tokenInfo TSRMLS_CC) > 0; + if (_6) { + _6 = zephir_array_isset_string(tokenInfo, SS("access_token")); } - if (_7) { - zephir_array_fetch_string(&_8, tokenInfo, SL("access_token"), PH_NOISY | PH_READONLY, "ice/auth/social/facebook.zep", 76 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_accessToken"), _8 TSRMLS_CC); + if (_6) { + zephir_array_fetch_string(&_7, tokenInfo, SL("access_token"), PH_NOISY | PH_READONLY, "ice/auth/social/facebook.zep", 76 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("accessToken"), _7 TSRMLS_CC); } } - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_accessToken"), PH_NOISY_CC); - if (zephir_is_true(_9)) { + _8 = zephir_fetch_nproperty_this(this_ptr, SL("accessToken"), PH_NOISY_CC); + if (zephir_is_true(_8)) { ZEPHIR_INIT_NVAR(params); - array_init_size(params, 2); + zephir_create_array(params, 1, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_accessToken"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("accessToken"), PH_NOISY_CC); zephir_array_update_string(¶ms, SL("access_token"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_3); ZVAL_LONG(_3, 0); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "https://graph.facebook.com/me", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&userInfo, this_ptr, "call", NULL, _3, _4, params); + ZEPHIR_CALL_METHOD(&userInfo, this_ptr, "call", NULL, 0, _3, _4, params); zephir_check_temp_parameter(_4); zephir_check_call_status(); if (zephir_array_isset_string(userInfo, SS("id"))) { - zephir_update_property_this(this_ptr, SL("_userInfo"), userInfo TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("userInfo"), userInfo TSRMLS_CC); result = 1; } } @@ -199,15 +198,15 @@ PHP_METHOD(Ice_Auth_Social_Facebook, prepareAuthParams) { ZEPHIR_MM_GROW(); - array_init_size(return_value, 3); + zephir_create_array(return_value, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("auth_url"), SL("https://www.facebook.com/dialog/oauth"), 1); ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 6); + zephir_create_array(_0, 4, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_clientId"), PH_NOISY_CC); + zephir_read_property_this(&_1, this_ptr, SL("clientId"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("client_id"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_redirectUri"), PH_NOISY_CC); + zephir_read_property_this(&_1, this_ptr, SL("redirectUri"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("redirect_uri"), &_1, PH_COPY | PH_SEPARATE); add_assoc_stringl_ex(_0, SS("response_type"), SL("code"), 1); add_assoc_stringl_ex(_0, SS("scope"), SL("email,user_birthday"), 1); diff --git a/ext/ice/auth/social/facebook.zep.h b/ext/ice/auth/social/facebook.zep.h index b37aa4af..66fb26a7 100644 --- a/ext/ice/auth/social/facebook.zep.h +++ b/ext/ice/auth/social/facebook.zep.h @@ -17,5 +17,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_social_facebook_method_entry) { PHP_ME(Ice_Auth_Social_Facebook, getImage, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social_Facebook, authenticate, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social_Facebook, prepareAuthParams, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/social/google.zep.c b/ext/ice/auth/social/google.zep.c index 89f0eb38..d285c068 100644 --- a/ext/ice/auth/social/google.zep.c +++ b/ext/ice/auth/social/google.zep.c @@ -15,9 +15,9 @@ #include "kernel/object.h" #include "kernel/memory.h" #include "kernel/fcall.h" +#include "kernel/array.h" #include "kernel/operators.h" #include "kernel/string.h" -#include "kernel/array.h" /** @@ -46,7 +46,7 @@ PHP_METHOD(Ice_Auth_Social_Google, __construct) { zval *_2; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL; zval *config = NULL, *_0; ZEPHIR_MM_GROW(); @@ -60,18 +60,18 @@ PHP_METHOD(Ice_Auth_Social_Google, __construct) { ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_STRING(_0, "google", 1); - zephir_update_property_this(this_ptr, SL("_provider"), _0 TSRMLS_CC); - ZEPHIR_CALL_PARENT(NULL, ice_auth_social_google_ce, this_ptr, "__construct", &_1, config); + zephir_update_property_this(this_ptr, SL("provider"), _0 TSRMLS_CC); + ZEPHIR_CALL_PARENT(NULL, ice_auth_social_google_ce, this_ptr, "__construct", &_1, 52, config); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 8); + zephir_create_array(_2, 6, 0 TSRMLS_CC); add_assoc_stringl_ex(_2, SS("socialId"), SL("id"), 1); add_assoc_stringl_ex(_2, SS("email"), SL("email"), 1); add_assoc_stringl_ex(_2, SS("name"), SL("name"), 1); add_assoc_stringl_ex(_2, SS("sex"), SL("gender"), 1); add_assoc_stringl_ex(_2, SS("socialPage"), SL("link"), 1); add_assoc_stringl_ex(_2, SS("image"), SL("picture"), 1); - zephir_update_property_this(this_ptr, SL("_socialFieldsMap"), _2 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("socialFieldsMap"), _2 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -91,30 +91,30 @@ PHP_METHOD(Ice_Auth_Social_Google, getBirthday) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "birthday", 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); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "Y", 0); - ZEPHIR_CALL_FUNCTION(&_3, "date", &_4, &_2); + ZEPHIR_CALL_FUNCTION(&_3, "date", &_4, 54, &_2); zephir_check_call_status(); - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_userInfo"), PH_NOISY_CC); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("userInfo"), PH_NOISY_CC); zephir_array_fetch_string(&_6, _5, SL("birthday"), PH_NOISY | PH_READONLY, "ice/auth/social/google.zep", 45 TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 0000); - zephir_fast_str_replace(_1, &_2, _3, _6 TSRMLS_CC); + zephir_fast_str_replace(&_1, &_2, _3, _6 TSRMLS_CC); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, "birthday", 1); - zephir_update_property_array(this_ptr, SL("_userInfo"), _7, _1 TSRMLS_CC); - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_userInfo"), PH_NOISY_CC); + zephir_update_property_array(this_ptr, SL("userInfo"), _7, _1 TSRMLS_CC); + _8 = zephir_fetch_nproperty_this(this_ptr, SL("userInfo"), PH_NOISY_CC); zephir_array_fetch_string(&_9, _8, SL("birthday"), PH_NOISY | PH_READONLY, "ice/auth/social/google.zep", 47 TSRMLS_CC); - ZEPHIR_CALL_FUNCTION(&_10, "strtotime", NULL, _9); + ZEPHIR_CALL_FUNCTION(&_10, "strtotime", NULL, 55, _9); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_11); ZVAL_STRING(&_11, "d.m.Y", 0); - ZEPHIR_RETURN_CALL_FUNCTION("date", &_4, &_11, _10); + ZEPHIR_RETURN_CALL_FUNCTION("date", &_4, 54, &_11, _10); zephir_check_call_status(); RETURN_MM(); } @@ -130,58 +130,58 @@ PHP_METHOD(Ice_Auth_Social_Google, getBirthday) { PHP_METHOD(Ice_Auth_Social_Google, authenticate) { int ZEPHIR_LAST_CALL_STATUS; - zval *params, *tokenInfo = NULL, *userInfo = NULL, *_GET, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5, *_6, *_7; - zend_bool result; + zval *params = NULL, *tokenInfo = NULL, *userInfo = NULL, *_GET, *_0 = NULL, *_1, *_2 = NULL, *_3 = NULL, *_4, *_5, *_6, *_7; + zend_bool result = 0; ZEPHIR_MM_GROW(); + zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); result = 0; - zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); if (zephir_array_isset_string(_GET, SS("code"))) { ZEPHIR_INIT_VAR(params); - array_init_size(params, 7); + zephir_create_array(params, 5, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_clientId"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("clientId"), PH_NOISY_CC); zephir_array_update_string(¶ms, SL("client_id"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_clientSecret"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("clientSecret"), PH_NOISY_CC); zephir_array_update_string(¶ms, SL("client_secret"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_redirectUri"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("redirectUri"), PH_NOISY_CC); zephir_array_update_string(¶ms, SL("redirect_uri"), &_0, PH_COPY | PH_SEPARATE); add_assoc_stringl_ex(params, SS("grant_type"), SL("authorization_code"), 1); ZEPHIR_OBS_NVAR(_0); zephir_array_fetch_string(&_0, _GET, SL("code"), PH_NOISY, "ice/auth/social/google.zep", 71 TSRMLS_CC); zephir_array_update_string(¶ms, SL("code"), &_0, PH_COPY | PH_SEPARATE); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_accessToken"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("accessToken"), PH_NOISY_CC); if (!(zephir_is_true(_1))) { ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 1); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "https://accounts.google.com/o/oauth2/token", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&tokenInfo, this_ptr, "call", NULL, _2, _3, params); + ZEPHIR_CALL_METHOD(&tokenInfo, this_ptr, "call", NULL, 0, _2, _3, params); zephir_check_temp_parameter(_3); zephir_check_call_status(); if (zephir_array_isset_string(tokenInfo, SS("access_token"))) { zephir_array_fetch_string(&_4, tokenInfo, SL("access_token"), PH_NOISY | PH_READONLY, "ice/auth/social/google.zep", 78 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_accessToken"), _4 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("accessToken"), _4 TSRMLS_CC); } } - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_accessToken"), PH_NOISY_CC); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("accessToken"), PH_NOISY_CC); if (zephir_is_true(_5)) { - _6 = zephir_fetch_nproperty_this(this_ptr, SL("_accessToken"), PH_NOISY_CC); + _6 = zephir_fetch_nproperty_this(this_ptr, SL("accessToken"), PH_NOISY_CC); zephir_array_update_string(¶ms, SL("access_token"), &_6, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_2); ZVAL_LONG(_2, 0); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "https://www.googleapis.com/oauth2/v1/userinfo", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&userInfo, this_ptr, "call", NULL, _2, _3, params); + ZEPHIR_CALL_METHOD(&userInfo, this_ptr, "call", NULL, 0, _2, _3, params); zephir_check_temp_parameter(_3); zephir_check_call_status(); - _7 = zephir_fetch_nproperty_this(this_ptr, SL("_socialFieldsMap"), PH_NOISY_CC); + _7 = zephir_fetch_nproperty_this(this_ptr, SL("socialFieldsMap"), PH_NOISY_CC); zephir_array_fetch_string(&_4, _7, SL("socialId"), PH_READONLY, "ice/auth/social/google.zep", 86 TSRMLS_CC); if (zephir_array_isset(userInfo, _4)) { - zephir_update_property_this(this_ptr, SL("_userInfo"), userInfo TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("userInfo"), userInfo TSRMLS_CC); result = 1; } } @@ -202,16 +202,16 @@ PHP_METHOD(Ice_Auth_Social_Google, prepareAuthParams) { ZEPHIR_MM_GROW(); - array_init_size(return_value, 3); + zephir_create_array(return_value, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("auth_url"), SL("https://accounts.google.com/o/oauth2/auth"), 1); ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 6); + zephir_create_array(_0, 4, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_redirectUri"), PH_NOISY_CC); + zephir_read_property_this(&_1, this_ptr, SL("redirectUri"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("redirect_uri"), &_1, PH_COPY | PH_SEPARATE); add_assoc_stringl_ex(_0, SS("response_type"), SL("code"), 1); ZEPHIR_OBS_NVAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_clientId"), PH_NOISY_CC); + zephir_read_property_this(&_1, this_ptr, SL("clientId"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("client_id"), &_1, PH_COPY | PH_SEPARATE); add_assoc_stringl_ex(_0, SS("scope"), SL("https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"), 1); zephir_array_update_string(&return_value, SL("auth_params"), &_0, PH_COPY | PH_SEPARATE); diff --git a/ext/ice/auth/social/google.zep.h b/ext/ice/auth/social/google.zep.h index fc014db0..d2029705 100644 --- a/ext/ice/auth/social/google.zep.h +++ b/ext/ice/auth/social/google.zep.h @@ -17,5 +17,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_social_google_method_entry) { PHP_ME(Ice_Auth_Social_Google, getBirthday, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social_Google, authenticate, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social_Google, prepareAuthParams, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/social/socialinterface.zep.h b/ext/ice/auth/social/socialinterface.zep.h index d2bc0a66..337f73c1 100644 --- a/ext/ice/auth/social/socialinterface.zep.h +++ b/ext/ice/auth/social/socialinterface.zep.h @@ -5,5 +5,5 @@ ZEPHIR_INIT_CLASS(Ice_Auth_Social_SocialInterface); ZEPHIR_INIT_FUNCS(ice_auth_social_socialinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Auth_Social_SocialInterface, authenticate, NULL) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/auth/social/twitter.zep.c b/ext/ice/auth/social/twitter.zep.c index bff99ea8..a2342c6f 100644 --- a/ext/ice/auth/social/twitter.zep.c +++ b/ext/ice/auth/social/twitter.zep.c @@ -15,10 +15,10 @@ #include "kernel/object.h" #include "kernel/memory.h" #include "kernel/fcall.h" +#include "kernel/array.h" #include "kernel/operators.h" #include "kernel/concat.h" #include "kernel/string.h" -#include "kernel/array.h" #include "kernel/time.h" @@ -48,7 +48,7 @@ PHP_METHOD(Ice_Auth_Social_Twitter, __construct) { zval *_2; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL; zval *config = NULL, *_0; ZEPHIR_MM_GROW(); @@ -62,20 +62,20 @@ PHP_METHOD(Ice_Auth_Social_Twitter, __construct) { ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_STRING(_0, "twitter", 1); - zephir_update_property_this(this_ptr, SL("_provider"), _0 TSRMLS_CC); - ZEPHIR_CALL_PARENT(NULL, ice_auth_social_twitter_ce, this_ptr, "__construct", &_1, config); + zephir_update_property_this(this_ptr, SL("provider"), _0 TSRMLS_CC); + ZEPHIR_CALL_PARENT(NULL, ice_auth_social_twitter_ce, this_ptr, "__construct", &_1, 52, config); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 7); + zephir_create_array(_2, 5, 0 TSRMLS_CC); add_assoc_stringl_ex(_2, SS("socialId"), SL("id"), 1); add_assoc_stringl_ex(_2, SS("email"), SL("email"), 1); add_assoc_stringl_ex(_2, SS("name"), SL("name"), 1); add_assoc_stringl_ex(_2, SS("sex"), SL("sex"), 1); add_assoc_stringl_ex(_2, SS("birthday"), SL("bdate"), 1); - zephir_update_property_this(this_ptr, SL("_socialFieldsMap"), _2 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("socialFieldsMap"), _2 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_STRING(_0, "oauth_token", 1); - zephir_update_property_this(this_ptr, SL("_responseType"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("responseType"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -94,13 +94,13 @@ PHP_METHOD(Ice_Auth_Social_Twitter, getSocialPage) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "screen_name", 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, "screen_name", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "get", NULL, _1); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_CONCAT_SV(return_value, "http://twitter.com/", _2); @@ -124,14 +124,14 @@ PHP_METHOD(Ice_Auth_Social_Twitter, getImage) { ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "profile_image_url", 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); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "profile_image_url", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "get", NULL, _3); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "get", NULL, 0, _3); zephir_check_temp_parameter(_3); zephir_check_call_status(); zephir_fast_explode_str(_1, SL("_normal"), _2, LONG_MAX TSRMLS_CC); @@ -149,22 +149,22 @@ PHP_METHOD(Ice_Auth_Social_Twitter, getImage) { */ PHP_METHOD(Ice_Auth_Social_Twitter, authenticate) { - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; + zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *params = NULL, *accessTokenUrl, *accessTokens = NULL, *getDataUrl, *userInfo = NULL, *_GET, *_1 = NULL, *_2 = NULL, *_4 = NULL, *_5, *_7; - zend_bool result, _0; + zval *params = NULL, *accessTokenUrl = NULL, *accessTokens = NULL, *getDataUrl = NULL, *userInfo = NULL, *_GET, *_1 = NULL, *_2 = NULL, *_4 = NULL, *_5, *_6; + zend_bool result = 0, _0; ZEPHIR_MM_GROW(); + zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); result = 0; - zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); _0 = zephir_array_isset_string(_GET, SS("oauth_token")); if (_0) { _0 = zephir_array_isset_string(_GET, SS("oauth_verifier")); } if (_0) { ZEPHIR_INIT_VAR(params); - array_init_size(params, 3); + zephir_create_array(params, 2, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); zephir_array_fetch_string(&_1, _GET, SL("oauth_token"), PH_NOISY, "ice/auth/social/twitter.zep", 78 TSRMLS_CC); zephir_array_update_string(¶ms, SL("oauth_token"), &_1, PH_COPY | PH_SEPARATE); @@ -173,24 +173,24 @@ PHP_METHOD(Ice_Auth_Social_Twitter, authenticate) { zephir_array_update_string(¶ms, SL("oauth_verifier"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(accessTokenUrl); ZVAL_STRING(accessTokenUrl, "https://api.twitter.com/oauth/access_token", 1); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "prepareurlparams", &_3, accessTokenUrl, params); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "prepareurlparams", &_3, 56, accessTokenUrl, params); zephir_check_call_status(); ZEPHIR_CPY_WRT(params, _2); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, 0); ZEPHIR_INIT_VAR(_5); ZVAL_BOOL(_5, 0); - ZEPHIR_CALL_METHOD(&accessTokens, this_ptr, "call", NULL, _4, accessTokenUrl, params, _5); + ZEPHIR_CALL_METHOD(&accessTokens, this_ptr, "call", NULL, 0, _4, accessTokenUrl, params, _5); zephir_check_call_status(); - Z_SET_ISREF_P(accessTokens); - ZEPHIR_CALL_FUNCTION(NULL, "parse_str", &_6, accessTokens, accessTokens); - Z_UNSET_ISREF_P(accessTokens); + ZEPHIR_MAKE_REF(accessTokens); + ZEPHIR_CALL_FUNCTION(NULL, "parse_str", NULL, 53, accessTokens, accessTokens); + ZEPHIR_UNREF(accessTokens); zephir_check_call_status(); if (zephir_array_isset_string(accessTokens, SS("oauth_token"))) { ZEPHIR_INIT_VAR(getDataUrl); ZVAL_STRING(getDataUrl, "https://api.twitter.com/1.1/users/show.json", 1); ZEPHIR_INIT_NVAR(params); - array_init_size(params, 4); + zephir_create_array(params, 3, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_1); zephir_array_fetch_string(&_1, accessTokens, SL("oauth_token"), PH_NOISY, "ice/auth/social/twitter.zep", 91 TSRMLS_CC); zephir_array_update_string(¶ms, SL("oauth_token"), &_1, PH_COPY | PH_SEPARATE); @@ -198,16 +198,16 @@ PHP_METHOD(Ice_Auth_Social_Twitter, authenticate) { zephir_array_fetch_string(&_1, accessTokens, SL("screen_name"), PH_NOISY, "ice/auth/social/twitter.zep", 92 TSRMLS_CC); zephir_array_update_string(¶ms, SL("screen_name"), &_1, PH_COPY | PH_SEPARATE); add_assoc_stringl_ex(params, SS("include_entities"), SL("false"), 1); - zephir_array_fetch_string(&_7, accessTokens, SL("oauth_token_secret"), PH_NOISY | PH_READONLY, "ice/auth/social/twitter.zep", 95 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "prepareurlparams", &_3, getDataUrl, params, _7); + zephir_array_fetch_string(&_6, accessTokens, SL("oauth_token_secret"), PH_NOISY | PH_READONLY, "ice/auth/social/twitter.zep", 95 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "prepareurlparams", &_3, 56, getDataUrl, params, _6); zephir_check_call_status(); ZEPHIR_CPY_WRT(params, _2); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, 0); - ZEPHIR_CALL_METHOD(&userInfo, this_ptr, "call", NULL, _4, getDataUrl, params); + ZEPHIR_CALL_METHOD(&userInfo, this_ptr, "call", NULL, 0, _4, getDataUrl, params); zephir_check_call_status(); if (zephir_array_isset_string(userInfo, SS("id"))) { - zephir_update_property_this(this_ptr, SL("_userInfo"), userInfo TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("userInfo"), userInfo TSRMLS_CC); result = 1; } } @@ -223,46 +223,45 @@ PHP_METHOD(Ice_Auth_Social_Twitter, authenticate) { */ PHP_METHOD(Ice_Auth_Social_Twitter, prepareAuthParams) { - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *_0, *_6; - zval *requestTokenUrl, *requestTokens = NULL, *params = NULL, *_1, *_3, *_4, *_7 = NULL; + zval *_0, *_4; + zval *requestTokenUrl = NULL, *requestTokens = NULL, *params = NULL, *_1, *_2, *_3, *_5 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(requestTokenUrl); ZVAL_STRING(requestTokenUrl, "https://api.twitter.com/oauth/request_token", 1); ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 2); + zephir_create_array(_0, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_redirectUri"), PH_NOISY_CC); + zephir_read_property_this(&_1, this_ptr, SL("redirectUri"), PH_NOISY_CC); zephir_array_update_string(&_0, SL("oauth_callback"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(¶ms, this_ptr, "prepareurlparams", &_2, requestTokenUrl, _0); + ZEPHIR_CALL_METHOD(¶ms, this_ptr, "prepareurlparams", NULL, 56, requestTokenUrl, _0); zephir_check_call_status(); + ZEPHIR_INIT_VAR(_2); + ZVAL_LONG(_2, 0); ZEPHIR_INIT_VAR(_3); - ZVAL_LONG(_3, 0); - ZEPHIR_INIT_VAR(_4); - ZVAL_BOOL(_4, 0); - ZEPHIR_CALL_METHOD(&requestTokens, this_ptr, "call", NULL, _3, requestTokenUrl, params, _4); + ZVAL_BOOL(_3, 0); + ZEPHIR_CALL_METHOD(&requestTokens, this_ptr, "call", NULL, 0, _2, requestTokenUrl, params, _3); zephir_check_call_status(); - Z_SET_ISREF_P(requestTokens); - ZEPHIR_CALL_FUNCTION(NULL, "parse_str", &_5, requestTokens, requestTokens); - Z_UNSET_ISREF_P(requestTokens); + ZEPHIR_MAKE_REF(requestTokens); + ZEPHIR_CALL_FUNCTION(NULL, "parse_str", NULL, 53, requestTokens, requestTokens); + ZEPHIR_UNREF(requestTokens); zephir_check_call_status(); - array_init_size(return_value, 3); + zephir_create_array(return_value, 2, 0 TSRMLS_CC); add_assoc_stringl_ex(return_value, SS("auth_url"), SL("https://api.twitter.com/oauth/authenticate"), 1); - ZEPHIR_INIT_VAR(_6); - array_init_size(_6, 2); - ZEPHIR_INIT_VAR(_7); + ZEPHIR_INIT_VAR(_4); + zephir_create_array(_4, 1, 0 TSRMLS_CC); + ZEPHIR_INIT_VAR(_5); if (zephir_array_isset_string(requestTokens, SS("oauth_token"))) { - ZEPHIR_OBS_NVAR(_7); - zephir_array_fetch_string(&_7, requestTokens, SL("oauth_token"), PH_NOISY, "ice/auth/social/twitter.zep", 124 TSRMLS_CC); + ZEPHIR_OBS_NVAR(_5); + zephir_array_fetch_string(&_5, requestTokens, SL("oauth_token"), PH_NOISY, "ice/auth/social/twitter.zep", 124 TSRMLS_CC); } else { - ZEPHIR_INIT_NVAR(_7); - ZVAL_NULL(_7); + ZEPHIR_INIT_NVAR(_5); + ZVAL_NULL(_5); } - zephir_array_update_string(&_6, SL("oauth_token"), &_7, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&return_value, SL("auth_params"), &_6, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_4, SL("oauth_token"), &_5, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&return_value, SL("auth_params"), &_4, PH_COPY | PH_SEPARATE); RETURN_MM(); } @@ -274,10 +273,10 @@ PHP_METHOD(Ice_Auth_Social_Twitter, prepareAuthParams) { */ PHP_METHOD(Ice_Auth_Social_Twitter, prepareUrlParams) { + zephir_fcall_cache_entry *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_8 = NULL, *_10 = NULL, *_12 = NULL, *_18 = NULL, *_20 = NULL; zval *_1; - zval *url_param = NULL, *params = NULL, *oauthToken_param = NULL, *type_param = NULL, *sigBaseStr, *key, *_0, *_2, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_9 = NULL, *_11 = NULL, *_13 = NULL, *_14, _15 = zval_used_for_init, *_16 = NULL, *_17 = NULL, *_19 = NULL; + zval *url_param = NULL, *params = NULL, *oauthToken_param = NULL, *type_param = NULL, *sigBaseStr = NULL, *key = NULL, *_0, *_2, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_10, _11 = zval_used_for_init, *_12 = NULL, *_13 = NULL, *_14 = NULL; zval *url = NULL, *oauthToken = NULL, *type = NULL; ZEPHIR_MM_GROW(); @@ -306,16 +305,16 @@ PHP_METHOD(Ice_Auth_Social_Twitter, prepareUrlParams) { ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 8); + zephir_create_array(_1, 6, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_2); - zephir_read_property_this(&_2, this_ptr, SL("_clientId"), PH_NOISY_CC); + zephir_read_property_this(&_2, this_ptr, SL("clientId"), PH_NOISY_CC); zephir_array_update_string(&_1, SL("oauth_consumer_key"), &_2, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_3); - ZEPHIR_CALL_FUNCTION(&_4, "rand", &_5); + ZEPHIR_CALL_FUNCTION(&_4, "rand", NULL, 57); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_6, "uniqid", &_7, _4, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_CALL_FUNCTION(&_5, "uniqid", NULL, 51, _4, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - zephir_md5(_3, _6); + zephir_md5(_3, _5); zephir_array_update_string(&_1, SL("oauth_nonce"), &_3, PH_COPY | PH_SEPARATE); add_assoc_stringl_ex(_1, SS("oauth_signature_method"), SL("HMAC-SHA1"), 1); ZEPHIR_INIT_NVAR(_3); @@ -325,33 +324,33 @@ PHP_METHOD(Ice_Auth_Social_Twitter, prepareUrlParams) { add_assoc_stringl_ex(_1, SS("oauth_version"), SL("1.0"), 1); zephir_fast_array_merge(_0, &(_1), &(params) TSRMLS_CC); ZEPHIR_CPY_WRT(params, _0); - Z_SET_ISREF_P(params); - ZEPHIR_CALL_FUNCTION(NULL, "ksort", &_8, params); - Z_UNSET_ISREF_P(params); + ZEPHIR_MAKE_REF(params); + ZEPHIR_CALL_FUNCTION(NULL, "ksort", NULL, 58, params); + ZEPHIR_UNREF(params); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_9, "urlencode", &_10, url); + ZEPHIR_CALL_FUNCTION(&_6, "urlencode", &_7, 59, url); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_11, "http_build_query", &_12, params); + ZEPHIR_CALL_FUNCTION(&_8, "http_build_query", NULL, 19, params); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_13, "urlencode", &_10, _11); + ZEPHIR_CALL_FUNCTION(&_9, "urlencode", &_7, 59, _8); zephir_check_call_status(); ZEPHIR_INIT_VAR(sigBaseStr); - ZEPHIR_CONCAT_VSVSV(sigBaseStr, type, "&", _9, "&", _13); - _14 = zephir_fetch_nproperty_this(this_ptr, SL("_clientSecret"), PH_NOISY_CC); + ZEPHIR_CONCAT_VSVSV(sigBaseStr, type, "&", _6, "&", _9); + _10 = zephir_fetch_nproperty_this(this_ptr, SL("clientSecret"), PH_NOISY_CC); ZEPHIR_INIT_VAR(key); - ZEPHIR_CONCAT_VSV(key, _14, "&", oauthToken); - ZEPHIR_SINIT_VAR(_15); - ZVAL_STRING(&_15, "sha1", 0); - ZEPHIR_CALL_FUNCTION(&_16, "hash_hmac", NULL, &_15, sigBaseStr, key, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_CONCAT_VSV(key, _10, "&", oauthToken); + ZEPHIR_SINIT_VAR(_11); + ZVAL_STRING(&_11, "sha1", 0); + ZEPHIR_CALL_FUNCTION(&_12, "hash_hmac", NULL, 25, &_11, sigBaseStr, key, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_17, "base64_encode", &_18, _16); + ZEPHIR_CALL_FUNCTION(&_13, "base64_encode", NULL, 15, _12); zephir_check_call_status(); - zephir_array_update_string(¶ms, SL("oauth_signature"), &_17, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_15); - ZVAL_STRING(&_15, "urlencode", 0); - ZEPHIR_CALL_FUNCTION(&_19, "array_map", &_20, &_15, params); + zephir_array_update_string(¶ms, SL("oauth_signature"), &_13, PH_COPY | PH_SEPARATE); + ZEPHIR_SINIT_NVAR(_11); + ZVAL_STRING(&_11, "urlencode", 0); + ZEPHIR_CALL_FUNCTION(&_14, "array_map", NULL, 31, &_11, params); zephir_check_call_status(); - ZEPHIR_CPY_WRT(params, _19); + ZEPHIR_CPY_WRT(params, _14); RETVAL_ZVAL(params, 1, 0); RETURN_MM(); diff --git a/ext/ice/auth/social/twitter.zep.h b/ext/ice/auth/social/twitter.zep.h index 7f45afc1..83f33b6d 100644 --- a/ext/ice/auth/social/twitter.zep.h +++ b/ext/ice/auth/social/twitter.zep.h @@ -28,5 +28,5 @@ ZEPHIR_INIT_FUNCS(ice_auth_social_twitter_method_entry) { PHP_ME(Ice_Auth_Social_Twitter, authenticate, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social_Twitter, prepareAuthParams, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Auth_Social_Twitter, prepareUrlParams, arginfo_ice_auth_social_twitter_prepareurlparams, ZEND_ACC_PRIVATE) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/cli/console.zep.c b/ext/ice/cli/console.zep.c index 821b2c6f..856708d5 100644 --- a/ext/ice/cli/console.zep.c +++ b/ext/ice/cli/console.zep.c @@ -33,7 +33,7 @@ ZEPHIR_INIT_CLASS(Ice_Cli_Console) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Cli, Console, ice, cli_console, ice_di_access_ce, ice_cli_console_method_entry, 0); - zend_declare_property_null(ice_cli_console_ce, SL("_modules"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_cli_console_ce, SL("modules"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_class_constant_long(ice_cli_console_ce, SL("NORMAL"), 0 TSRMLS_CC); @@ -50,7 +50,7 @@ ZEPHIR_INIT_CLASS(Ice_Cli_Console) { PHP_METHOD(Ice_Cli_Console, getModules) { - RETURN_MEMBER(this_ptr, "_modules"); + RETURN_MEMBER(this_ptr, "modules"); } @@ -62,7 +62,38 @@ PHP_METHOD(Ice_Cli_Console, setModules) { - zephir_update_property_this(this_ptr, SL("_modules"), modules TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("modules"), modules TSRMLS_CC); + +} + +/** + * Console constructor + * + * @param Di $di + */ +PHP_METHOD(Ice_Cli_Console, __construct) { + + int ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_0 = NULL; + zval *di = NULL, *_1, *_2; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &di); + + if (!di) { + di = ZEPHIR_GLOBAL(global_null); + } + + + ZEPHIR_CALL_PARENT(NULL, ice_cli_console_ce, this_ptr, "__construct", &_0, 29, di); + zephir_check_call_status(); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_2); + ZVAL_STRING(_2, "console", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _1, "set", NULL, 0, _2, this_ptr); + zephir_check_temp_parameter(_2); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } @@ -75,7 +106,7 @@ PHP_METHOD(Ice_Cli_Console, setModules) { PHP_METHOD(Ice_Cli_Console, handle) { int ZEPHIR_LAST_CALL_STATUS; - zval *arguments = NULL, *router = NULL, *response = NULL, *dispatcher = NULL, *_0, *_1, *_2, *_3, *_4, *_5, *_6; + zval *arguments = NULL, *router = NULL, *response = NULL, *dispatcher = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4, *_5, *_6, *_7, *_8, *_9; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &arguments); @@ -85,30 +116,44 @@ PHP_METHOD(Ice_Cli_Console, handle) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&router, _0, "getrouter", NULL); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_1); + ZVAL_STRING(_1, "router", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_2); + ZVAL_NULL(_2); + ZEPHIR_INIT_VAR(_3); + ZVAL_BOOL(_3, 1); + ZEPHIR_CALL_METHOD(&router, _0, "get", NULL, 0, _1, _2, _3); + zephir_check_temp_parameter(_1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&response, router, "handle", NULL, arguments); + ZEPHIR_CALL_METHOD(&response, router, "handle", NULL, 0, arguments); zephir_check_call_status(); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&dispatcher, _1, "getdispatcher", NULL); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "dispatcher", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_2); + ZVAL_NULL(_2); + ZEPHIR_INIT_NVAR(_3); + ZVAL_BOOL(_3, 1); + ZEPHIR_CALL_METHOD(&dispatcher, _4, "get", NULL, 0, _1, _2, _3); + zephir_check_temp_parameter(_1); zephir_check_call_status(); - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_modules"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmodules", NULL, _2); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("modules"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmodules", NULL, 0, _5); zephir_check_call_status(); - zephir_array_fetch_string(&_3, response, SL("module"), PH_NOISY | PH_READONLY, "ice/cli/console.zep", 40 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmodule", NULL, _3); + zephir_array_fetch_string(&_6, response, SL("module"), PH_NOISY | PH_READONLY, "ice/cli/console.zep", 55 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmodule", NULL, 0, _6); zephir_check_call_status(); - zephir_array_fetch_string(&_4, response, SL("handler"), PH_NOISY | PH_READONLY, "ice/cli/console.zep", 41 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "sethandler", NULL, _4); + zephir_array_fetch_string(&_7, response, SL("handler"), PH_NOISY | PH_READONLY, "ice/cli/console.zep", 56 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "sethandler", NULL, 0, _7); zephir_check_call_status(); - zephir_array_fetch_string(&_5, response, SL("action"), PH_NOISY | PH_READONLY, "ice/cli/console.zep", 42 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "setaction", NULL, _5); + zephir_array_fetch_string(&_8, response, SL("action"), PH_NOISY | PH_READONLY, "ice/cli/console.zep", 57 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "setaction", NULL, 0, _8); zephir_check_call_status(); - zephir_array_fetch_string(&_6, response, SL("params"), PH_NOISY | PH_READONLY, "ice/cli/console.zep", 43 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "setparams", NULL, _6); + zephir_array_fetch_string(&_9, response, SL("params"), PH_NOISY | PH_READONLY, "ice/cli/console.zep", 58 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "setparams", NULL, 0, _9); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&response, dispatcher, "dispatch", NULL); + ZEPHIR_CALL_METHOD(&response, dispatcher, "dispatch", NULL, 0); zephir_check_call_status(); RETURN_CCTOR(response); @@ -127,7 +172,7 @@ PHP_METHOD(Ice_Cli_Console, handle) { PHP_METHOD(Ice_Cli_Console, color) { int decoration; - zval *text_param = NULL, *color_param = NULL, *decoration_param = NULL, *bgColor_param = NULL, *colors, *bgColors, *colored, *e, *foreground, *background, _0, *_1 = NULL, *_2; + zval *text_param = NULL, *color_param = NULL, *decoration_param = NULL, *bgColor_param = NULL, *colors = NULL, *bgColors = NULL, *colored = NULL, *e = NULL, *foreground = NULL, *background = NULL, _0, *_1 = NULL, *_2; zval *text = NULL, *color = NULL, *bgColor = NULL; ZEPHIR_MM_GROW(); @@ -154,7 +199,7 @@ PHP_METHOD(Ice_Cli_Console, color) { ZEPHIR_INIT_VAR(colors); - array_init_size(colors, 12); + zephir_create_array(colors, 9, 0 TSRMLS_CC); add_assoc_long_ex(colors, SS("black"), 30); add_assoc_long_ex(colors, SS("red"), 31); add_assoc_long_ex(colors, SS("green"), 32); @@ -165,7 +210,7 @@ PHP_METHOD(Ice_Cli_Console, color) { add_assoc_long_ex(colors, SS("lightgray"), 37); add_assoc_long_ex(colors, SS("white"), 97); ZEPHIR_INIT_VAR(bgColors); - array_init_size(bgColors, 12); + zephir_create_array(bgColors, 9, 0 TSRMLS_CC); add_assoc_long_ex(bgColors, SS("black"), 40); add_assoc_long_ex(bgColors, SS("red"), 41); add_assoc_long_ex(bgColors, SS("green"), 42); diff --git a/ext/ice/cli/console.zep.h b/ext/ice/cli/console.zep.h index 94ed9b44..ff86e11d 100644 --- a/ext/ice/cli/console.zep.h +++ b/ext/ice/cli/console.zep.h @@ -5,6 +5,7 @@ ZEPHIR_INIT_CLASS(Ice_Cli_Console); PHP_METHOD(Ice_Cli_Console, getModules); PHP_METHOD(Ice_Cli_Console, setModules); +PHP_METHOD(Ice_Cli_Console, __construct); PHP_METHOD(Ice_Cli_Console, handle); PHP_METHOD(Ice_Cli_Console, color); @@ -12,6 +13,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_cli_console_setmodules, 0, 0, 1) ZEND_ARG_INFO(0, modules) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_cli_console___construct, 0, 0, 0) + ZEND_ARG_OBJ_INFO(0, di, Ice\\Di, 1) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_cli_console_handle, 0, 0, 0) ZEND_ARG_INFO(0, arguments) ZEND_END_ARG_INFO() @@ -26,7 +31,8 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_cli_console_method_entry) { PHP_ME(Ice_Cli_Console, getModules, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Cli_Console, setModules, arginfo_ice_cli_console_setmodules, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Cli_Console, __construct, arginfo_ice_cli_console___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Cli_Console, handle, arginfo_ice_cli_console_handle, ZEND_ACC_PUBLIC) PHP_ME(Ice_Cli_Console, color, arginfo_ice_cli_console_color, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/cli/dispatcher.zep.c b/ext/ice/cli/dispatcher.zep.c index f8a97ca5..749c65eb 100644 --- a/ext/ice/cli/dispatcher.zep.c +++ b/ext/ice/cli/dispatcher.zep.c @@ -28,7 +28,7 @@ ZEPHIR_INIT_CLASS(Ice_Cli_Dispatcher) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Cli, Dispatcher, ice, cli_dispatcher, ice_dispatcher_ce, NULL, 0); - zend_declare_property_string(ice_cli_dispatcher_ce, SL("_handlerSuffix"), "Task", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_cli_dispatcher_ce, SL("handlerSuffix"), "Task", ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; diff --git a/ext/ice/cli/router.zep.c b/ext/ice/cli/router.zep.c index ff4a51e9..733c89b9 100644 --- a/ext/ice/cli/router.zep.c +++ b/ext/ice/cli/router.zep.c @@ -22,24 +22,36 @@ #include "kernel/string.h" #include "kernel/operators.h" + +/** + * Router is the standard framework router. Routing is the process of taking a command-line arguments and decomposing it + * into parameters to determine which module, task, and action of that task should receive the request. + * + * @package Ice/Router + * @category Component + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Cli_Router) { ZEPHIR_REGISTER_CLASS(Ice\\Cli, Router, ice, cli_router, ice_cli_router_method_entry, 0); - zend_declare_property_string(ice_cli_router_ce, SL("_defaultModule"), "shell", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_cli_router_ce, SL("defaultModule"), "shell", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_cli_router_ce, SL("_defaultHandler"), "main", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_cli_router_ce, SL("defaultHandler"), "main", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_cli_router_ce, SL("_defaultAction"), "main", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_cli_router_ce, SL("defaultAction"), "main", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_cli_router_ce, SL("_module"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_cli_router_ce, SL("module"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_cli_router_ce, SL("_handler"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_cli_router_ce, SL("handler"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_cli_router_ce, SL("_action"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_cli_router_ce, SL("action"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_cli_router_ce, SL("_params"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_cli_router_ce, SL("params"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_cli_router_ce->create_object = zephir_init_properties_Ice_Cli_Router; return SUCCESS; } @@ -47,7 +59,7 @@ ZEPHIR_INIT_CLASS(Ice_Cli_Router) { PHP_METHOD(Ice_Cli_Router, getDefaultModule) { - RETURN_MEMBER(this_ptr, "_defaultModule"); + RETURN_MEMBER(this_ptr, "defaultModule"); } @@ -59,14 +71,14 @@ PHP_METHOD(Ice_Cli_Router, setDefaultModule) { - zephir_update_property_this(this_ptr, SL("_defaultModule"), defaultModule TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultModule"), defaultModule TSRMLS_CC); } PHP_METHOD(Ice_Cli_Router, getDefaultHandler) { - RETURN_MEMBER(this_ptr, "_defaultHandler"); + RETURN_MEMBER(this_ptr, "defaultHandler"); } @@ -78,14 +90,14 @@ PHP_METHOD(Ice_Cli_Router, setDefaultHandler) { - zephir_update_property_this(this_ptr, SL("_defaultHandler"), defaultHandler TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultHandler"), defaultHandler TSRMLS_CC); } PHP_METHOD(Ice_Cli_Router, getDefaultAction) { - RETURN_MEMBER(this_ptr, "_defaultAction"); + RETURN_MEMBER(this_ptr, "defaultAction"); } @@ -97,35 +109,35 @@ PHP_METHOD(Ice_Cli_Router, setDefaultAction) { - zephir_update_property_this(this_ptr, SL("_defaultAction"), defaultAction TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultAction"), defaultAction TSRMLS_CC); } PHP_METHOD(Ice_Cli_Router, getModule) { - RETURN_MEMBER(this_ptr, "_module"); + RETURN_MEMBER(this_ptr, "module"); } PHP_METHOD(Ice_Cli_Router, getHandler) { - RETURN_MEMBER(this_ptr, "_handler"); + RETURN_MEMBER(this_ptr, "handler"); } PHP_METHOD(Ice_Cli_Router, getAction) { - RETURN_MEMBER(this_ptr, "_action"); + RETURN_MEMBER(this_ptr, "action"); } PHP_METHOD(Ice_Cli_Router, getParams) { - RETURN_MEMBER(this_ptr, "_params"); + RETURN_MEMBER(this_ptr, "params"); } @@ -136,7 +148,7 @@ PHP_METHOD(Ice_Cli_Router, getParams) { */ PHP_METHOD(Ice_Cli_Router, setDefaults) { - zval *defaults_param = NULL, *module, *handler, *action; + zval *defaults_param = NULL, *module = NULL, *handler = NULL, *action = NULL; zval *defaults = NULL; zephir_fetch_params(0, 1, 0, &defaults_param); @@ -144,15 +156,14 @@ PHP_METHOD(Ice_Cli_Router, setDefaults) { defaults = defaults_param; - if (zephir_array_isset_string_fetch(&module, defaults, SS("module"), 1 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_defaultModule"), module TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultModule"), module TSRMLS_CC); } if (zephir_array_isset_string_fetch(&handler, defaults, SS("handler"), 1 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_defaultHandler"), handler TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultHandler"), handler TSRMLS_CC); } if (zephir_array_isset_string_fetch(&action, defaults, SS("action"), 1 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_defaultAction"), action TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultAction"), action TSRMLS_CC); } } @@ -169,12 +180,11 @@ PHP_METHOD(Ice_Cli_Router, setDefaults) { */ PHP_METHOD(Ice_Cli_Router, handle) { - zend_bool _16, _18, _20; - HashTable *_5; - HashPosition _4; + zend_bool _15, _17, _19; + HashTable *_4; + HashPosition _3; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL; - zval *arguments = NULL, *params, *argument = NULL, *_0, *_1, *_2, **_6, _7 = zval_used_for_init, _8 = zval_used_for_init, *_9 = NULL, _10 = zval_used_for_init, *_11 = NULL, _12 = zval_used_for_init, *_13 = NULL, *_14, *_15 = NULL, *_17, *_19; + zval *arguments = NULL, *params = NULL, *argument = NULL, *_0, *_1, *_2, **_5, _6 = zval_used_for_init, _7 = zval_used_for_init, *_8 = NULL, _9 = zval_used_for_init, *_10 = NULL, _11 = zval_used_for_init, *_12 = NULL, *_13, *_14 = NULL, *_16, *_18; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &arguments); @@ -188,115 +198,123 @@ PHP_METHOD(Ice_Cli_Router, handle) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Arguments must be an array", "ice/cli/router.zep", 65); return; } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC); - zephir_update_property_this(this_ptr, SL("_module"), _0 TSRMLS_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultHandler"), PH_NOISY_CC); - zephir_update_property_this(this_ptr, SL("_handler"), _1 TSRMLS_CC); - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC); - zephir_update_property_this(this_ptr, SL("_action"), _2 TSRMLS_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("defaultModule"), PH_NOISY_CC); + zephir_update_property_this(this_ptr, SL("module"), _0 TSRMLS_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("defaultHandler"), PH_NOISY_CC); + zephir_update_property_this(this_ptr, SL("handler"), _1 TSRMLS_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("defaultAction"), PH_NOISY_CC); + zephir_update_property_this(this_ptr, SL("action"), _2 TSRMLS_CC); ZEPHIR_INIT_VAR(params); array_init(params); - Z_SET_ISREF_P(arguments); - ZEPHIR_CALL_FUNCTION(NULL, "array_shift", &_3, arguments); - Z_UNSET_ISREF_P(arguments); + ZEPHIR_MAKE_REF(arguments); + ZEPHIR_CALL_FUNCTION(NULL, "array_shift", NULL, 4, arguments); + ZEPHIR_UNREF(arguments); zephir_check_call_status(); - zephir_is_iterable(arguments, &_5, &_4, 0, 0, "ice/cli/router.zep", 97); + zephir_is_iterable(arguments, &_4, &_3, 0, 0, "ice/cli/router.zep", 97); 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(_4, (void**) &_5, &_3) == SUCCESS + ; zephir_hash_move_forward_ex(_4, &_3) ) { - ZEPHIR_GET_HVALUE(argument, _6); + ZEPHIR_GET_HVALUE(argument, _5); + ZEPHIR_SINIT_NVAR(_6); + ZVAL_LONG(&_6, 0); ZEPHIR_SINIT_NVAR(_7); - ZVAL_LONG(&_7, 0); - ZEPHIR_SINIT_NVAR(_8); - ZVAL_LONG(&_8, 2); - ZEPHIR_INIT_NVAR(_9); - zephir_substr(_9, argument, 0 , 2 , 0); - if (!ZEPHIR_IS_STRING_IDENTICAL(_9, "--")) { + ZVAL_LONG(&_7, 2); + ZEPHIR_INIT_NVAR(_8); + zephir_substr(_8, argument, 0 , 2 , 0); + if (!ZEPHIR_IS_STRING_IDENTICAL(_8, "--")) { zephir_array_append(¶ms, argument, PH_SEPARATE, "ice/cli/router.zep", 81); continue; } - ZEPHIR_SINIT_NVAR(_10); - ZVAL_LONG(&_10, 2); - ZEPHIR_INIT_NVAR(_11); - zephir_substr(_11, argument, 2 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CPY_WRT(argument, _11); - ZEPHIR_SINIT_NVAR(_12); - ZVAL_STRING(&_12, "=", 0); - ZEPHIR_INIT_NVAR(_11); - zephir_fast_strpos(_11, argument, &_12, 0 ); - if (zephir_is_true(_11)) { - ZEPHIR_INIT_NVAR(_13); - zephir_fast_explode_str(_13, SL("="), argument, 2 TSRMLS_CC); - ZEPHIR_CPY_WRT(argument, _13); - zephir_array_fetch_long(&_14, argument, 1, PH_NOISY | PH_READONLY, "ice/cli/router.zep", 91 TSRMLS_CC); - ZEPHIR_OBS_NVAR(_15); - zephir_array_fetch_long(&_15, argument, 0, PH_NOISY, "ice/cli/router.zep", 91 TSRMLS_CC); - zephir_array_update_zval(¶ms, _15, &_14, PH_COPY | PH_SEPARATE); + ZEPHIR_SINIT_NVAR(_9); + ZVAL_LONG(&_9, 2); + ZEPHIR_INIT_NVAR(_10); + zephir_substr(_10, argument, 2 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_CPY_WRT(argument, _10); + ZEPHIR_SINIT_NVAR(_11); + ZVAL_STRING(&_11, "=", 0); + ZEPHIR_INIT_NVAR(_10); + zephir_fast_strpos(_10, argument, &_11, 0 ); + if (zephir_is_true(_10)) { + ZEPHIR_INIT_NVAR(_12); + zephir_fast_explode_str(_12, SL("="), argument, 2 TSRMLS_CC); + ZEPHIR_CPY_WRT(argument, _12); + zephir_array_fetch_long(&_13, argument, 1, PH_NOISY | PH_READONLY, "ice/cli/router.zep", 91 TSRMLS_CC); + ZEPHIR_OBS_NVAR(_14); + zephir_array_fetch_long(&_14, argument, 0, PH_NOISY, "ice/cli/router.zep", 91 TSRMLS_CC); + zephir_array_update_zval(¶ms, _14, &_13, PH_COPY | PH_SEPARATE); } else { zephir_array_update_zval(¶ms, argument, &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE); } } - _16 = zephir_array_isset_string(params, SS("module")); - if (_16) { - zephir_array_fetch_string(&_14, params, SL("module"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 97 TSRMLS_CC); - _16 = zephir_is_true(_14); + _15 = zephir_array_isset_string(params, SS("module")); + if (_15) { + zephir_array_fetch_string(&_13, params, SL("module"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 97 TSRMLS_CC); + _15 = zephir_is_true(_13); } - if (_16) { - zephir_array_fetch_string(&_17, params, SL("module"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 98 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_module"), _17 TSRMLS_CC); + if (_15) { + zephir_array_fetch_string(&_16, params, SL("module"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 98 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("module"), _16 TSRMLS_CC); zephir_array_unset_string(¶ms, SS("module"), PH_SEPARATE); } - _18 = zephir_array_isset_string(params, SS("handler")); - if (_18) { - zephir_array_fetch_string(&_17, params, SL("handler"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 103 TSRMLS_CC); - _18 = zephir_is_true(_17); + _17 = zephir_array_isset_string(params, SS("handler")); + if (_17) { + zephir_array_fetch_string(&_16, params, SL("handler"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 103 TSRMLS_CC); + _17 = zephir_is_true(_16); } - if (_18) { - zephir_array_fetch_string(&_19, params, SL("handler"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 104 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_handler"), _19 TSRMLS_CC); + if (_17) { + zephir_array_fetch_string(&_18, params, SL("handler"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 104 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("handler"), _18 TSRMLS_CC); zephir_array_unset_string(¶ms, SS("handler"), PH_SEPARATE); } - _20 = zephir_array_isset_string(params, SS("action")); - if (_20) { - zephir_array_fetch_string(&_17, params, SL("action"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 109 TSRMLS_CC); - _20 = zephir_is_true(_17); + _19 = zephir_array_isset_string(params, SS("action")); + if (_19) { + zephir_array_fetch_string(&_16, params, SL("action"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 109 TSRMLS_CC); + _19 = zephir_is_true(_16); } - if (_20) { - zephir_array_fetch_string(&_19, params, SL("action"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 110 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_action"), _19 TSRMLS_CC); + if (_19) { + zephir_array_fetch_string(&_18, params, SL("action"), PH_NOISY | PH_READONLY, "ice/cli/router.zep", 110 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("action"), _18 TSRMLS_CC); zephir_array_unset_string(¶ms, SS("action"), PH_SEPARATE); } if (zephir_fast_count_int(params TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_params"), params TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("params"), params TSRMLS_CC); } - array_init_size(return_value, 6); - ZEPHIR_OBS_NVAR(_15); - zephir_read_property_this(&_15, this_ptr, SL("_module"), PH_NOISY_CC); - zephir_array_update_string(&return_value, SL("module"), &_15, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(_15); - zephir_read_property_this(&_15, this_ptr, SL("_handler"), PH_NOISY_CC); - zephir_array_update_string(&return_value, SL("handler"), &_15, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(_15); - zephir_read_property_this(&_15, this_ptr, SL("_action"), PH_NOISY_CC); - zephir_array_update_string(&return_value, SL("action"), &_15, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(_15); - zephir_read_property_this(&_15, this_ptr, SL("_params"), PH_NOISY_CC); - zephir_array_update_string(&return_value, SL("params"), &_15, PH_COPY | PH_SEPARATE); + zephir_create_array(return_value, 4, 0 TSRMLS_CC); + ZEPHIR_OBS_NVAR(_14); + zephir_read_property_this(&_14, this_ptr, SL("module"), PH_NOISY_CC); + zephir_array_update_string(&return_value, SL("module"), &_14, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(_14); + zephir_read_property_this(&_14, this_ptr, SL("handler"), PH_NOISY_CC); + zephir_array_update_string(&return_value, SL("handler"), &_14, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(_14); + zephir_read_property_this(&_14, this_ptr, SL("action"), PH_NOISY_CC); + zephir_array_update_string(&return_value, SL("action"), &_14, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(_14); + zephir_read_property_this(&_14, this_ptr, SL("params"), PH_NOISY_CC); + zephir_array_update_string(&return_value, SL("params"), &_14, PH_COPY | PH_SEPARATE); RETURN_MM(); } -PHP_METHOD(Ice_Cli_Router, __construct) { +static zend_object_value zephir_init_properties_Ice_Cli_Router(zend_class_entry *class_type TSRMLS_DC) { - zval *_0; + zval *_0, *_1; - ZEPHIR_MM_GROW(); - - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_params"), _0 TSRMLS_CC); - ZEPHIR_MM_RESTORE(); + ZEPHIR_MM_GROW(); + + { + zval *this_ptr = NULL; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("params"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("params"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } } diff --git a/ext/ice/cli/router.zep.h b/ext/ice/cli/router.zep.h index 385f7bb5..15372977 100644 --- a/ext/ice/cli/router.zep.h +++ b/ext/ice/cli/router.zep.h @@ -15,7 +15,7 @@ PHP_METHOD(Ice_Cli_Router, getAction); PHP_METHOD(Ice_Cli_Router, getParams); PHP_METHOD(Ice_Cli_Router, setDefaults); PHP_METHOD(Ice_Cli_Router, handle); -PHP_METHOD(Ice_Cli_Router, __construct); +static zend_object_value zephir_init_properties_Ice_Cli_Router(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_cli_router_setdefaultmodule, 0, 0, 1) ZEND_ARG_INFO(0, defaultModule) @@ -50,6 +50,5 @@ ZEPHIR_INIT_FUNCS(ice_cli_router_method_entry) { PHP_ME(Ice_Cli_Router, getParams, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Cli_Router, setDefaults, arginfo_ice_cli_router_setdefaults, ZEND_ACC_PUBLIC) PHP_ME(Ice_Cli_Router, handle, arginfo_ice_cli_router_handle, ZEND_ACC_PUBLIC) - PHP_ME(Ice_Cli_Router, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/cli/task.zep.c b/ext/ice/cli/task.zep.c index 6350fcde..7944b8b7 100644 --- a/ext/ice/cli/task.zep.c +++ b/ext/ice/cli/task.zep.c @@ -42,14 +42,14 @@ ZEPHIR_INIT_CLASS(Ice_Cli_Task) { PHP_METHOD(Ice_Cli_Task, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_0 = NULL; + zephir_fcall_cache_entry *_0 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_CALL_PARENT(NULL, ice_cli_task_ce, this_ptr, "__construct", &_0); + ZEPHIR_CALL_PARENT(NULL, ice_cli_task_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); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); diff --git a/ext/ice/cli/task.zep.h b/ext/ice/cli/task.zep.h index 06e18792..d0ed89f4 100644 --- a/ext/ice/cli/task.zep.h +++ b/ext/ice/cli/task.zep.h @@ -7,5 +7,5 @@ PHP_METHOD(Ice_Cli_Task, __construct); ZEPHIR_INIT_FUNCS(ice_cli_task_method_entry) { PHP_ME(Ice_Cli_Task, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL|ZEND_ACC_CTOR) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/config.zep.c b/ext/ice/config.zep.c index 294ee36a..d695928e 100644 --- a/ext/ice/config.zep.c +++ b/ext/ice/config.zep.c @@ -48,7 +48,7 @@ PHP_METHOD(Ice_Config, __construct) { int ZEPHIR_LAST_CALL_STATUS; HashTable *_1, *_4; HashPosition _0, _3; - zend_bool hasNumericKey; + zend_bool hasNumericKey = 0; zval *data = NULL, *key = NULL, *value = NULL, *subkey = NULL, *subvalue = NULL, **_2, **_5, *_6 = NULL; ZEPHIR_MM_GROW(); @@ -93,16 +93,16 @@ PHP_METHOD(Ice_Config, __construct) { } } if (hasNumericKey) { - zephir_update_property_array(this_ptr, SL("_data"), key, value TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("data"), key, value TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_6); object_init_ex(_6, ice_config_ce); - ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_7, value); + ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_7, 26, value); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("_data"), key, _6 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("data"), key, _6 TSRMLS_CC); } } else { - zephir_update_property_array(this_ptr, SL("_data"), key, value TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("data"), key, value TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); diff --git a/ext/ice/config.zep.h b/ext/ice/config.zep.h index 44306177..41a9c261 100644 --- a/ext/ice/config.zep.h +++ b/ext/ice/config.zep.h @@ -11,5 +11,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_config_method_entry) { PHP_ME(Ice_Config, __construct, arginfo_ice_config___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/config/ini.zep.c b/ext/ice/config/ini.zep.c index d10274be..c40a9956 100644 --- a/ext/ice/config/ini.zep.c +++ b/ext/ice/config/ini.zep.c @@ -16,6 +16,7 @@ #include "kernel/fcall.h" #include "kernel/memory.h" #include "kernel/operators.h" +#include "kernel/string.h" #include "kernel/hash.h" #include "kernel/array.h" @@ -45,7 +46,7 @@ ZEPHIR_INIT_CLASS(Ice_Config_Ini) { PHP_METHOD(Ice_Config_Ini, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_2 = NULL, *_3 = NULL; + zephir_fcall_cache_entry *_0 = NULL, *_2 = NULL; zval *data = NULL, *ini = NULL, *raw = NULL, _1; ZEPHIR_MM_GROW(); @@ -62,15 +63,15 @@ PHP_METHOD(Ice_Config_Ini, __construct) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "The file path must be a string", "ice/config/ini.zep", 29); return; } - ZEPHIR_CALL_FUNCTION(&ini, "parse_ini_file", &_0, data, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_CALL_FUNCTION(&ini, "parse_ini_file", &_0, 60, data, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 1); - ZEPHIR_CALL_FUNCTION(&raw, "parse_ini_file", &_0, data, ZEPHIR_GLOBAL(global_true), &_1); + ZEPHIR_CALL_FUNCTION(&raw, "parse_ini_file", &_0, 60, data, ZEPHIR_GLOBAL(global_true), &_1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&data, this_ptr, "map", &_2, ini, raw); + ZEPHIR_CALL_METHOD(&data, this_ptr, "map", NULL, 61, ini, raw); zephir_check_call_status(); - ZEPHIR_CALL_PARENT(NULL, ice_config_ini_ce, this_ptr, "__construct", &_3, data); + ZEPHIR_CALL_PARENT(NULL, ice_config_ini_ce, this_ptr, "__construct", &_2, 26, data); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -85,10 +86,8 @@ PHP_METHOD(Ice_Config_Ini, __construct) { */ PHP_METHOD(Ice_Config_Ini, cast) { - int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_9 = NULL; zend_bool _0, _1, _2, _3, _4, _5, _6; - zval *ini, *raw, *_7, *_8 = NULL; + zval *ini, *raw, *_7, *_8, _9; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &ini, &raw); @@ -135,10 +134,10 @@ PHP_METHOD(Ice_Config_Ini, cast) { } if (zephir_is_numeric(ini)) { ZEPHIR_INIT_VAR(_7); - ZVAL_STRING(_7, "/[.]+/", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_FUNCTION(&_8, "preg_match", &_9, _7, ini); - zephir_check_temp_parameter(_7); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(_8); + ZEPHIR_SINIT_VAR(_9); + ZVAL_STRING(&_9, "/[.]+/", 0); + zephir_preg_match(_8, &_9, ini, _7, 0, 0 , 0 TSRMLS_CC); if (zephir_is_true(_8)) { RETURN_MM_DOUBLE(zephir_get_doubleval(ini)); } else { @@ -160,19 +159,19 @@ PHP_METHOD(Ice_Config_Ini, cast) { */ PHP_METHOD(Ice_Config_Ini, map) { - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL; + zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; - zval *ini, *raw, *key = NULL, *value = NULL, *data, **_2, *_3 = NULL, *_4; + zval *ini, *raw, *key = NULL, *value = NULL, *data = NULL, **_2, *_3 = NULL, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &ini, &raw); - ZEPHIR_INIT_VAR(data); - array_init(data); + ZEPHIR_INIT_VAR(data); + array_init(data); zephir_is_iterable(ini, &_1, &_0, 0, 0, "ice/config/ini.zep", 94); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS @@ -182,12 +181,12 @@ PHP_METHOD(Ice_Config_Ini, map) { ZEPHIR_GET_HVALUE(value, _2); if (Z_TYPE_P(value) == IS_ARRAY) { zephir_array_fetch(&_4, raw, key, PH_NOISY | PH_READONLY, "ice/config/ini.zep", 89 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "map", &_5, value, _4); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "map", &_5, 61, value, _4); zephir_check_call_status(); zephir_array_update_zval(&data, key, &_3, PH_COPY | PH_SEPARATE); } else { zephir_array_fetch(&_4, raw, key, PH_NOISY | PH_READONLY, "ice/config/ini.zep", 91 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "cast", &_6, value, _4); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "cast", &_6, 62, value, _4); zephir_check_call_status(); zephir_array_update_zval(&data, key, &_3, PH_COPY | PH_SEPARATE); } diff --git a/ext/ice/config/ini.zep.h b/ext/ice/config/ini.zep.h index 298a7cbf..32df29af 100644 --- a/ext/ice/config/ini.zep.h +++ b/ext/ice/config/ini.zep.h @@ -25,5 +25,5 @@ ZEPHIR_INIT_FUNCS(ice_config_ini_method_entry) { PHP_ME(Ice_Config_Ini, __construct, arginfo_ice_config_ini___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Config_Ini, cast, arginfo_ice_config_ini_cast, ZEND_ACC_PRIVATE) PHP_ME(Ice_Config_Ini, map, arginfo_ice_config_ini_map, ZEND_ACC_PRIVATE) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/config/json.zep.c b/ext/ice/config/json.zep.c new file mode 100644 index 00000000..379d8caa --- /dev/null +++ b/ext/ice/config/json.zep.c @@ -0,0 +1,72 @@ + +#ifdef HAVE_CONFIG_H +#include "../../ext_config.h" +#endif + +#include +#include "../../php_ext.h" +#include "../../ext.h" + +#include +#include +#include + +#include "kernel/main.h" +#include "kernel/exception.h" +#include "kernel/fcall.h" +#include "kernel/memory.h" +#include "kernel/string.h" +#include "kernel/file.h" +#include "kernel/operators.h" + + +/** + * 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 + */ +ZEPHIR_INIT_CLASS(Ice_Config_Json) { + + ZEPHIR_REGISTER_CLASS_EX(Ice\\Config, Json, ice, config_json, ice_config_ce, ice_config_json_method_entry, 0); + + return SUCCESS; + +} + +/** + * Config json constructor. + * + * @param string data Path to the json file + */ +PHP_METHOD(Ice_Config_Json, __construct) { + + int ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_0 = NULL; + zval *data = NULL, *_1, *_2; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &data); + + if (!data) { + data = ZEPHIR_GLOBAL(global_null); + } + + + if (Z_TYPE_P(data) != IS_STRING) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "The file path must be a string", "ice/config/json.zep", 27); + return; + } + ZEPHIR_INIT_VAR(_1); + ZEPHIR_INIT_VAR(_2); + zephir_file_get_contents(_2, data TSRMLS_CC); + zephir_json_decode(_1, &(_1), _2, zephir_get_intval(ZEPHIR_GLOBAL(global_true)) TSRMLS_CC); + ZEPHIR_CALL_PARENT(NULL, ice_config_json_ce, this_ptr, "__construct", &_0, 26, _1); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); + +} + diff --git a/ext/ice/config/json.zep.h b/ext/ice/config/json.zep.h new file mode 100644 index 00000000..fd9cca8f --- /dev/null +++ b/ext/ice/config/json.zep.h @@ -0,0 +1,15 @@ + +extern zend_class_entry *ice_config_json_ce; + +ZEPHIR_INIT_CLASS(Ice_Config_Json); + +PHP_METHOD(Ice_Config_Json, __construct); + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_config_json___construct, 0, 0, 0) + ZEND_ARG_INFO(0, data) +ZEND_END_ARG_INFO() + +ZEPHIR_INIT_FUNCS(ice_config_json_method_entry) { + PHP_ME(Ice_Config_Json, __construct, arginfo_ice_config_json___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_FE_END +}; diff --git a/ext/ice/cookies.zep.c b/ext/ice/cookies.zep.c index 4c99fb6e..3ad2b92e 100644 --- a/ext/ice/cookies.zep.c +++ b/ext/ice/cookies.zep.c @@ -35,21 +35,21 @@ ZEPHIR_INIT_CLASS(Ice_Cookies) { ZEPHIR_REGISTER_CLASS(Ice, Cookies, ice, cookies, ice_cookies_method_entry, 0); - zend_declare_property_null(ice_cookies_ce, SL("_di"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_cookies_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_cookies_ce, SL("_salt"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_cookies_ce, SL("salt"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_long(ice_cookies_ce, SL("_expiration"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_long(ice_cookies_ce, SL("expiration"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_cookies_ce, SL("_path"), "/", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_cookies_ce, SL("path"), "/", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_cookies_ce, SL("_domain"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_cookies_ce, SL("domain"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_bool(ice_cookies_ce, SL("_secure"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(ice_cookies_ce, SL("secure"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_bool(ice_cookies_ce, SL("_httpOnly"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(ice_cookies_ce, SL("httpOnly"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_bool(ice_cookies_ce, SL("_encrypt"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(ice_cookies_ce, SL("encrypt"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -58,7 +58,7 @@ ZEPHIR_INIT_CLASS(Ice_Cookies) { PHP_METHOD(Ice_Cookies, getSalt) { - RETURN_MEMBER(this_ptr, "_salt"); + RETURN_MEMBER(this_ptr, "salt"); } @@ -70,14 +70,14 @@ PHP_METHOD(Ice_Cookies, setSalt) { - zephir_update_property_this(this_ptr, SL("_salt"), salt TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("salt"), salt TSRMLS_CC); } PHP_METHOD(Ice_Cookies, getExpiration) { - RETURN_MEMBER(this_ptr, "_expiration"); + RETURN_MEMBER(this_ptr, "expiration"); } @@ -89,14 +89,14 @@ PHP_METHOD(Ice_Cookies, setExpiration) { - zephir_update_property_this(this_ptr, SL("_expiration"), expiration TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("expiration"), expiration TSRMLS_CC); } PHP_METHOD(Ice_Cookies, getPath) { - RETURN_MEMBER(this_ptr, "_path"); + RETURN_MEMBER(this_ptr, "path"); } @@ -108,14 +108,14 @@ PHP_METHOD(Ice_Cookies, setPath) { - zephir_update_property_this(this_ptr, SL("_path"), path TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("path"), path TSRMLS_CC); } PHP_METHOD(Ice_Cookies, getDomain) { - RETURN_MEMBER(this_ptr, "_domain"); + RETURN_MEMBER(this_ptr, "domain"); } @@ -127,14 +127,14 @@ PHP_METHOD(Ice_Cookies, setDomain) { - zephir_update_property_this(this_ptr, SL("_domain"), domain TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("domain"), domain TSRMLS_CC); } PHP_METHOD(Ice_Cookies, getSecure) { - RETURN_MEMBER(this_ptr, "_secure"); + RETURN_MEMBER(this_ptr, "secure"); } @@ -146,14 +146,14 @@ PHP_METHOD(Ice_Cookies, setSecure) { - zephir_update_property_this(this_ptr, SL("_secure"), secure TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("secure"), secure TSRMLS_CC); } PHP_METHOD(Ice_Cookies, getHttpOnly) { - RETURN_MEMBER(this_ptr, "_httpOnly"); + RETURN_MEMBER(this_ptr, "httpOnly"); } @@ -165,14 +165,14 @@ PHP_METHOD(Ice_Cookies, setHttpOnly) { - zephir_update_property_this(this_ptr, SL("_httpOnly"), httpOnly TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("httpOnly"), httpOnly TSRMLS_CC); } PHP_METHOD(Ice_Cookies, getEncrypt) { - RETURN_MEMBER(this_ptr, "_encrypt"); + RETURN_MEMBER(this_ptr, "encrypt"); } @@ -184,14 +184,14 @@ PHP_METHOD(Ice_Cookies, setEncrypt) { - zephir_update_property_this(this_ptr, SL("_encrypt"), encrypt TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("encrypt"), encrypt TSRMLS_CC); } PHP_METHOD(Ice_Cookies, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL; zval *salt_param = NULL, *_0 = NULL; zval *salt = NULL; @@ -206,10 +206,10 @@ PHP_METHOD(Ice_Cookies, __construct) { } - 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("_salt"), salt TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("di"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("salt"), salt TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -226,12 +226,12 @@ PHP_METHOD(Ice_Cookies, has) { zval *key = NULL; ZEPHIR_MM_GROW(); + zephir_get_global(&_COOKIE, SS("_COOKIE") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &key_param); zephir_get_strval(key, key_param); - zephir_get_global(&_COOKIE, SS("_COOKIE") TSRMLS_CC); RETURN_MM_BOOL(zephir_array_isset(_COOKIE, key)); } @@ -247,10 +247,11 @@ PHP_METHOD(Ice_Cookies, has) { PHP_METHOD(Ice_Cookies, get) { int ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *defaultValue = NULL, *cookie, *tmp, *hash, *value = NULL, *_COOKIE, _0, *_1, *_2 = NULL, *_3, *_4, *_5 = NULL, *_6 = NULL; + zval *key_param = NULL, *defaultValue = NULL, *cookie = NULL, *tmp = NULL, *hash = NULL, *value = NULL, *_COOKIE, _0, *_1, *_2 = NULL, *_3, *_4, *_5 = NULL, *_6, *_7, *_8, *_9 = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); + zephir_get_global(&_COOKIE, SS("_COOKIE") TSRMLS_CC); zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); zephir_get_strval(key, key_param); @@ -260,7 +261,6 @@ PHP_METHOD(Ice_Cookies, get) { ZEPHIR_OBS_VAR(cookie); - zephir_get_global(&_COOKIE, SS("_COOKIE") TSRMLS_CC); if (!(zephir_array_isset_fetch(&cookie, _COOKIE, key, 0 TSRMLS_CC))) { RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); @@ -276,21 +276,28 @@ PHP_METHOD(Ice_Cookies, get) { zephir_array_fetch_long(&hash, tmp, 0, PH_NOISY, "ice/cookies.zep", 65 TSRMLS_CC); ZEPHIR_OBS_VAR(value); zephir_array_fetch_long(&value, tmp, 1, PH_NOISY, "ice/cookies.zep", 66 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "salt", NULL, key, value); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "salt", NULL, 0, key, value); zephir_check_call_status(); if (ZEPHIR_IS_EQUAL(_2, hash)) { - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_encrypt"), PH_NOISY_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("encrypt"), PH_NOISY_CC); if (zephir_is_true(_3)) { - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_5, _4, "getcrypt", NULL); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_6); + ZVAL_STRING(_6, "crypt", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_7); + ZVAL_NULL(_7); + ZEPHIR_INIT_VAR(_8); + ZVAL_BOOL(_8, 1); + ZEPHIR_CALL_METHOD(&_5, _4, "get", NULL, 0, _6, _7, _8); + zephir_check_temp_parameter(_6); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6, _5, "decrypt", NULL, value); + ZEPHIR_CALL_METHOD(&_9, _5, "decrypt", NULL, 0, value); zephir_check_call_status(); - ZEPHIR_CPY_WRT(value, _6); + ZEPHIR_CPY_WRT(value, _9); } RETURN_CCTOR(value); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, key); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0, key); zephir_check_call_status(); } RETVAL_ZVAL(defaultValue, 1, 0); @@ -310,7 +317,7 @@ PHP_METHOD(Ice_Cookies, get) { PHP_METHOD(Ice_Cookies, set) { int lifetime, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value_param = NULL, *lifetime_param = NULL, *_0, *_1, *_2, *_3 = NULL, *_4 = NULL, *_5, *_6, *_7, *_8, *_9; + zval *key_param = NULL, *value_param = NULL, *lifetime_param = NULL, *_0, *_1, *_2, *_3 = NULL, *_4 = NULL, *_5, *_6, *_7 = NULL, *_8, *_9, *_10, *_11; zval *key = NULL, *value = NULL; ZEPHIR_MM_GROW(); @@ -327,32 +334,39 @@ PHP_METHOD(Ice_Cookies, set) { if (!(lifetime)) { ZEPHIR_OBS_VAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_expiration"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("expiration"), PH_NOISY_CC); lifetime = zephir_get_intval(_0); } - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_encrypt"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("encrypt"), PH_NOISY_CC); if (zephir_is_true(_1)) { if (!(ZEPHIR_IS_EMPTY(value))) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_3, _2, "getcrypt", NULL); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_4); + ZVAL_STRING(_4, "crypt", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_5); + ZVAL_NULL(_5); + ZEPHIR_INIT_VAR(_6); + ZVAL_BOOL(_6, 1); + ZEPHIR_CALL_METHOD(&_3, _2, "get", NULL, 0, _4, _5, _6); + zephir_check_temp_parameter(_4); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, _3, "encrypt", NULL, value); + ZEPHIR_CALL_METHOD(&_7, _3, "encrypt", NULL, 0, value); zephir_check_call_status(); - zephir_get_strval(value, _4); + zephir_get_strval(value, _7); } } - ZEPHIR_CALL_METHOD(&_3, this_ptr, "salt", NULL, key, value); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "salt", NULL, 0, key, value); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_5); - ZEPHIR_CONCAT_VSV(_5, _3, "~", value); - zephir_get_strval(value, _5); - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_path"), PH_NOISY_CC); - _6 = zephir_fetch_nproperty_this(this_ptr, SL("_domain"), PH_NOISY_CC); - _7 = zephir_fetch_nproperty_this(this_ptr, SL("_secure"), PH_NOISY_CC); - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_httpOnly"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_9); - ZVAL_LONG(_9, lifetime); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_setcookie", NULL, key, value, _9, _2, _6, _7, _8); + ZEPHIR_INIT_VAR(_8); + ZEPHIR_CONCAT_VSV(_8, _3, "~", value); + zephir_get_strval(value, _8); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("path"), PH_NOISY_CC); + _9 = zephir_fetch_nproperty_this(this_ptr, SL("domain"), PH_NOISY_CC); + _10 = zephir_fetch_nproperty_this(this_ptr, SL("secure"), PH_NOISY_CC); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("httpOnly"), PH_NOISY_CC); + ZEPHIR_INIT_NVAR(_4); + ZVAL_LONG(_4, lifetime); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setcookie", NULL, 0, key, value, _4, _2, _9, _10, _11); zephir_check_call_status(); RETURN_MM(); @@ -371,22 +385,22 @@ PHP_METHOD(Ice_Cookies, remove) { zval *key = NULL; ZEPHIR_MM_GROW(); + zephir_get_global(&_COOKIE, SS("_COOKIE") TSRMLS_CC); zephir_fetch_params(1, 1, 0, &key_param); zephir_get_strval(key, key_param); - zephir_get_global(&_COOKIE, SS("_COOKIE") TSRMLS_CC); zephir_array_unset(&_COOKIE, key, PH_SEPARATE); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_path"), PH_NOISY_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_domain"), PH_NOISY_CC); - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_secure"), PH_NOISY_CC); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_httpOnly"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("path"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("domain"), PH_NOISY_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("secure"), PH_NOISY_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("httpOnly"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_4); ZVAL_NULL(_4); ZEPHIR_INIT_VAR(_5); ZVAL_LONG(_5, -86400); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_setcookie", NULL, key, _4, _5, _0, _1, _2, _3); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setcookie", NULL, 0, key, _4, _5, _0, _1, _2, _3); zephir_check_call_status(); RETURN_MM(); @@ -402,29 +416,35 @@ PHP_METHOD(Ice_Cookies, remove) { */ PHP_METHOD(Ice_Cookies, salt) { - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *name, *value, *userAgent = NULL, *_0, *_1, *_2 = NULL, *_3, *_4; + zval *name, *value, *userAgent = NULL, *_0, *_1, *_2 = NULL, *_3, *_4, *_5, *_6, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &name, &value); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_salt"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("salt"), PH_NOISY_CC); if (!(zephir_is_true(_0))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "A valid cookie salt is required.", "ice/cookies.zep", 141); return; } - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_2, _1, "getrequest", NULL); + _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(&userAgent, _2, "getuseragent", NULL); + ZEPHIR_CALL_METHOD(&userAgent, _2, "getuseragent", NULL, 0); zephir_check_call_status(); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_salt"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_4); - ZEPHIR_CONCAT_VVVV(_4, userAgent, name, value, _3); - ZEPHIR_RETURN_CALL_FUNCTION("sha1", &_5, _4); + _6 = zephir_fetch_nproperty_this(this_ptr, SL("salt"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_7); + ZEPHIR_CONCAT_VVVV(_7, userAgent, name, value, _6); + ZEPHIR_RETURN_CALL_FUNCTION("sha1", NULL, 43, _7); zephir_check_call_status(); RETURN_MM(); @@ -444,12 +464,11 @@ PHP_METHOD(Ice_Cookies, salt) { * @return bool * @see setcookie */ -PHP_METHOD(Ice_Cookies, _setcookie) { +PHP_METHOD(Ice_Cookies, setcookie) { - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; zend_bool secure, httpOnly; int expire, ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *value_param = NULL, *expire_param = NULL, *path_param = NULL, *domain_param = NULL, *secure_param = NULL, *httpOnly_param = NULL, _0; + zval *name_param = NULL, *value_param = NULL, *expire_param = NULL, *path_param = NULL, *domain_param = NULL, *secure_param = NULL, *httpOnly_param = NULL, _0, _1, _2; zval *name = NULL, *value = NULL, *path = NULL, *domain = NULL; ZEPHIR_MM_GROW(); @@ -466,7 +485,11 @@ PHP_METHOD(Ice_Cookies, _setcookie) { ZEPHIR_SINIT_VAR(_0); ZVAL_LONG(&_0, expire); - ZEPHIR_RETURN_CALL_FUNCTION("setcookie", &_1, name, value, &_0, path, domain, (secure ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false)), (httpOnly ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false))); + ZEPHIR_SINIT_VAR(_1); + ZVAL_BOOL(&_1, (secure ? 1 : 0)); + ZEPHIR_SINIT_VAR(_2); + ZVAL_BOOL(&_2, (httpOnly ? 1 : 0)); + ZEPHIR_RETURN_CALL_FUNCTION("setcookie", NULL, 63, name, value, &_0, path, domain, &_1, &_2); zephir_check_call_status(); RETURN_MM(); diff --git a/ext/ice/cookies.zep.h b/ext/ice/cookies.zep.h index 904d059f..9201473b 100644 --- a/ext/ice/cookies.zep.h +++ b/ext/ice/cookies.zep.h @@ -23,7 +23,7 @@ PHP_METHOD(Ice_Cookies, get); PHP_METHOD(Ice_Cookies, set); PHP_METHOD(Ice_Cookies, remove); PHP_METHOD(Ice_Cookies, salt); -PHP_METHOD(Ice_Cookies, _setcookie); +PHP_METHOD(Ice_Cookies, setcookie); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_cookies_setsalt, 0, 0, 1) ZEND_ARG_INFO(0, salt) @@ -81,7 +81,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_cookies_salt, 0, 0, 2) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_cookies__setcookie, 0, 0, 7) +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_cookies_setcookie, 0, 0, 7) ZEND_ARG_INFO(0, name) ZEND_ARG_INFO(0, value) ZEND_ARG_INFO(0, expire) @@ -112,6 +112,6 @@ ZEPHIR_INIT_FUNCS(ice_cookies_method_entry) { PHP_ME(Ice_Cookies, set, arginfo_ice_cookies_set, ZEND_ACC_PUBLIC) PHP_ME(Ice_Cookies, remove, arginfo_ice_cookies_remove, ZEND_ACC_PUBLIC) PHP_ME(Ice_Cookies, salt, arginfo_ice_cookies_salt, ZEND_ACC_PUBLIC) - PHP_ME(Ice_Cookies, _setcookie, arginfo_ice_cookies__setcookie, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_ME(Ice_Cookies, setcookie, arginfo_ice_cookies_setcookie, ZEND_ACC_PROTECTED) + PHP_FE_END }; diff --git a/ext/ice/crypt.zep.c b/ext/ice/crypt.zep.c index 1a718bdc..4afad244 100644 --- a/ext/ice/crypt.zep.c +++ b/ext/ice/crypt.zep.c @@ -36,13 +36,13 @@ ZEPHIR_INIT_CLASS(Ice_Crypt) { ZEPHIR_REGISTER_CLASS(Ice, Crypt, ice, crypt, ice_crypt_method_entry, 0); - zend_declare_property_null(ice_crypt_ce, SL("_key"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_crypt_ce, SL("key"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_crypt_ce, SL("_cipher"), "aes-256", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_crypt_ce, SL("cipher"), "aes-256", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_crypt_ce, SL("_mode"), "cbc", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_crypt_ce, SL("mode"), "cbc", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_long(ice_crypt_ce, SL("_block"), 16, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_long(ice_crypt_ce, SL("block"), 16, ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -65,7 +65,7 @@ PHP_METHOD(Ice_Crypt, __construct) { zephir_get_strval(key, key_param); - zephir_update_property_this(this_ptr, SL("_key"), key TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("key"), key TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -78,10 +78,10 @@ PHP_METHOD(Ice_Crypt, __construct) { */ PHP_METHOD(Ice_Crypt, encrypt) { - zval *_6; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_3 = NULL; + zval *_5; + zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *iv = NULL, *value = NULL, *mac = NULL, *_0 = NULL, *_2 = NULL, *_4 = NULL, *_5; + zval *text_param = NULL, *iv = NULL, *value = NULL, *mac = NULL, *_0 = NULL, *_1 = NULL, *_3 = NULL, *_4; zval *text = NULL; ZEPHIR_MM_GROW(); @@ -90,29 +90,29 @@ PHP_METHOD(Ice_Crypt, encrypt) { zephir_get_strval(text, text_param); - ZEPHIR_CALL_METHOD(&iv, this_ptr, "generateinputvector", NULL); + ZEPHIR_CALL_METHOD(&iv, this_ptr, "generateinputvector", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_0, "serialize", &_1, text); + ZEPHIR_CALL_FUNCTION(&_0, "serialize", NULL, 14, text); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, this_ptr, "addpadding", NULL, _0); + ZEPHIR_CALL_METHOD(&value, this_ptr, "addpadding", NULL, 0, _0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "_encrypt", NULL, value, iv); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "doencrypt", NULL, 0, value, iv); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&value, "base64_encode", &_3, _2); + ZEPHIR_CALL_FUNCTION(&value, "base64_encode", &_2, 15, _1); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_4, "base64_encode", &_3, iv); + ZEPHIR_CALL_FUNCTION(&_3, "base64_encode", &_2, 15, iv); zephir_check_call_status(); - ZEPHIR_CPY_WRT(iv, _4); - ZEPHIR_CALL_METHOD(&mac, this_ptr, "hash", NULL, value); + ZEPHIR_CPY_WRT(iv, _3); + ZEPHIR_CALL_METHOD(&mac, this_ptr, "hash", NULL, 0, value); zephir_check_call_status(); + ZEPHIR_INIT_VAR(_4); ZEPHIR_INIT_VAR(_5); - ZEPHIR_INIT_VAR(_6); - array_init_size(_6, 4); - zephir_array_update_string(&_6, SL("iv"), &iv, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_6, SL("value"), &value, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_6, SL("mac"), &mac, PH_COPY | PH_SEPARATE); - zephir_json_encode(_5, &(_5), _6, 0 TSRMLS_CC); - ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", &_3, _5); + zephir_create_array(_5, 3, 0 TSRMLS_CC); + zephir_array_update_string(&_5, SL("iv"), &iv, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_5, SL("value"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_5, SL("mac"), &mac, PH_COPY | PH_SEPARATE); + zephir_json_encode(_4, &(_4), _5, 0 TSRMLS_CC); + ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", &_2, 15, _4); zephir_check_call_status(); RETURN_MM(); @@ -130,9 +130,9 @@ PHP_METHOD(Ice_Crypt, generateInputVector) { ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getivsize", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getivsize", NULL, 0); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("openssl_random_pseudo_bytes", NULL, _0); + ZEPHIR_RETURN_CALL_FUNCTION("openssl_random_pseudo_bytes", NULL, 64, _0); zephir_check_call_status(); RETURN_MM(); @@ -145,7 +145,7 @@ PHP_METHOD(Ice_Crypt, generateInputVector) { * @param string iv * @return string */ -PHP_METHOD(Ice_Crypt, _encrypt) { +PHP_METHOD(Ice_Crypt, doEncrypt) { int ZEPHIR_LAST_CALL_STATUS; zval *value_param = NULL, *iv_param = NULL, *_0, *_1, *_2, *_3, _4; @@ -158,14 +158,14 @@ PHP_METHOD(Ice_Crypt, _encrypt) { zephir_get_strval(iv, iv_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cipher"), PH_NOISY_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_mode"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("cipher"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("mode"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VSV(_2, _0, "-", _1); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_key"), PH_NOISY_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("key"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 1); - ZEPHIR_RETURN_CALL_FUNCTION("openssl_encrypt", NULL, value, _2, _3, &_4, iv); + ZEPHIR_RETURN_CALL_FUNCTION("openssl_encrypt", NULL, 65, value, _2, _3, &_4, iv); zephir_check_call_status(); RETURN_MM(); @@ -179,7 +179,7 @@ PHP_METHOD(Ice_Crypt, _encrypt) { */ PHP_METHOD(Ice_Crypt, decrypt) { - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_5 = NULL; + zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *text_param = NULL, *value = NULL, *payload = NULL, *iv = NULL, *_0, *_2, *_3 = NULL, *_4 = NULL; zval *text = NULL; @@ -190,19 +190,19 @@ PHP_METHOD(Ice_Crypt, decrypt) { zephir_get_strval(text, text_param); - ZEPHIR_CALL_METHOD(&payload, this_ptr, "getjsonpayload", NULL, text); + ZEPHIR_CALL_METHOD(&payload, this_ptr, "getjsonpayload", NULL, 0, text); zephir_check_call_status(); zephir_array_fetch_string(&_0, payload, SL("value"), PH_NOISY | PH_READONLY, "ice/crypt.zep", 97 TSRMLS_CC); - ZEPHIR_CALL_FUNCTION(&value, "base64_decode", &_1, _0); + ZEPHIR_CALL_FUNCTION(&value, "base64_decode", &_1, 16, _0); zephir_check_call_status(); zephir_array_fetch_string(&_2, payload, SL("iv"), PH_NOISY | PH_READONLY, "ice/crypt.zep", 98 TSRMLS_CC); - ZEPHIR_CALL_FUNCTION(&iv, "base64_decode", &_1, _2); + ZEPHIR_CALL_FUNCTION(&iv, "base64_decode", &_1, 16, _2); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "_decrypt", NULL, value, iv); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "dodecrypt", NULL, 0, value, iv); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "strippadding", NULL, _4); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "strippadding", NULL, 0, _4); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("unserialize", &_5, _3); + ZEPHIR_RETURN_CALL_FUNCTION("unserialize", NULL, 17, _3); zephir_check_call_status(); RETURN_MM(); @@ -215,7 +215,7 @@ PHP_METHOD(Ice_Crypt, decrypt) { * @param string iv * @return string */ -PHP_METHOD(Ice_Crypt, _decrypt) { +PHP_METHOD(Ice_Crypt, doDecrypt) { int ZEPHIR_LAST_CALL_STATUS; zval *value_param = NULL, *iv_param = NULL, *_0, *_1, *_2, *_3, _4; @@ -228,14 +228,14 @@ PHP_METHOD(Ice_Crypt, _decrypt) { zephir_get_strval(iv, iv_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cipher"), PH_NOISY_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_mode"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("cipher"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("mode"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VSV(_2, _0, "-", _1); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_key"), PH_NOISY_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("key"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 1); - ZEPHIR_RETURN_CALL_FUNCTION("openssl_decrypt", NULL, value, _2, _3, &_4, iv); + ZEPHIR_RETURN_CALL_FUNCTION("openssl_decrypt", NULL, 66, value, _2, _3, &_4, iv); zephir_check_call_status(); RETURN_MM(); @@ -249,10 +249,9 @@ PHP_METHOD(Ice_Crypt, _decrypt) { */ PHP_METHOD(Ice_Crypt, getJsonPayload) { - zend_bool _2; + zend_bool _1; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; - zval *text_param = NULL, *payload = NULL, *_0 = NULL, *_3 = NULL, *_4, *_5 = NULL, *_6; + zval *text_param = NULL, *payload = NULL, *_0 = NULL, *_2 = NULL, *_3, *_4 = NULL, *_5; zval *text = NULL; ZEPHIR_MM_GROW(); @@ -263,25 +262,25 @@ PHP_METHOD(Ice_Crypt, getJsonPayload) { ZEPHIR_INIT_VAR(payload); array_init(payload); - ZEPHIR_INIT_NVAR(payload); - ZEPHIR_CALL_FUNCTION(&_0, "base64_decode", &_1, text); + ZEPHIR_CALL_FUNCTION(&_0, "base64_decode", NULL, 16, text); zephir_check_call_status(); + ZEPHIR_INIT_NVAR(payload); zephir_json_decode(payload, &(payload), _0, zephir_get_intval(ZEPHIR_GLOBAL(global_true)) TSRMLS_CC); - _2 = !zephir_is_true(payload); - if (!(_2)) { - ZEPHIR_CALL_METHOD(&_3, this_ptr, "invalidpayload", NULL, payload); + _1 = !zephir_is_true(payload); + if (!(_1)) { + ZEPHIR_CALL_METHOD(&_2, this_ptr, "invalidpayload", NULL, 0, payload); zephir_check_call_status(); - _2 = zephir_is_true(_3); + _1 = zephir_is_true(_2); } - if (_2) { + if (_1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Invalid data passed to encrypter.", "ice/crypt.zep", 132); return; } - zephir_array_fetch_string(&_4, payload, SL("mac"), PH_NOISY | PH_READONLY, "ice/crypt.zep", 135 TSRMLS_CC); - zephir_array_fetch_string(&_6, payload, SL("value"), PH_NOISY | PH_READONLY, "ice/crypt.zep", 135 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "hash", NULL, _6); + zephir_array_fetch_string(&_3, payload, SL("mac"), PH_NOISY | PH_READONLY, "ice/crypt.zep", 135 TSRMLS_CC); + zephir_array_fetch_string(&_5, payload, SL("value"), PH_NOISY | PH_READONLY, "ice/crypt.zep", 135 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "hash", NULL, 0, _5); zephir_check_call_status(); - if (!ZEPHIR_IS_EQUAL(_4, _5)) { + if (!ZEPHIR_IS_EQUAL(_3, _4)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "MAC for payload is invalid.", "ice/crypt.zep", 136); return; } @@ -307,10 +306,10 @@ PHP_METHOD(Ice_Crypt, hash) { zephir_get_strval(value, value_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_key"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("key"), PH_NOISY_CC); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "sha256", 0); - ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac", NULL, &_1, value, _0); + ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac", NULL, 25, &_1, value, _0); zephir_check_call_status(); RETURN_MM(); @@ -325,8 +324,7 @@ PHP_METHOD(Ice_Crypt, hash) { PHP_METHOD(Ice_Crypt, addPadding) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; - zval *value_param = NULL, *pad, *len, *_0, *_1, *_2, *_3 = NULL, *_5 = NULL; + zval *value_param = NULL, *pad = NULL, *len = NULL, *_0, *_1, *_2, *_3 = NULL, *_4 = NULL; zval *value = NULL; ZEPHIR_MM_GROW(); @@ -337,17 +335,17 @@ PHP_METHOD(Ice_Crypt, addPadding) { ZEPHIR_INIT_VAR(len); ZVAL_LONG(len, zephir_fast_strlen_ev(value)); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_block"), PH_NOISY_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_block"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("block"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("block"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); mod_function(_2, len, _1 TSRMLS_CC); ZEPHIR_INIT_VAR(pad); - sub_function(pad, _0, _2 TSRMLS_CC); - ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, pad); + zephir_sub_function(pad, _0, _2); + ZEPHIR_CALL_FUNCTION(&_3, "chr", NULL, 67, pad); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_5, "str_repeat", &_6, _3, pad); + ZEPHIR_CALL_FUNCTION(&_4, "str_repeat", NULL, 68, _3, pad); zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, value, _5); + ZEPHIR_CONCAT_VV(return_value, value, _4); RETURN_MM(); } @@ -360,10 +358,9 @@ PHP_METHOD(Ice_Crypt, addPadding) { */ PHP_METHOD(Ice_Crypt, stripPadding) { - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL; unsigned char _0; - int pad, len, ZEPHIR_LAST_CALL_STATUS; - zval *value_param = NULL, _1 = zval_used_for_init, *_2 = NULL, *_4 = NULL, *_5 = NULL, *_6, _7; + int pad = 0, len = 0, ZEPHIR_LAST_CALL_STATUS; + zval *value_param = NULL, _1 = zval_used_for_init, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5, _6; zval *value = NULL; ZEPHIR_MM_GROW(); @@ -376,24 +373,24 @@ PHP_METHOD(Ice_Crypt, stripPadding) { _0 = ZEPHIR_STRING_OFFSET(value, (len - 1)); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, _0); - ZEPHIR_CALL_FUNCTION(&_2, "ord", &_3, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "ord", NULL, 69, &_1); zephir_check_call_status(); pad = zephir_get_intval(_2); - ZEPHIR_INIT_VAR(_4); - ZEPHIR_INIT_VAR(_6); - ZVAL_LONG(_6, pad); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "paddingisvalid", NULL, _6, value); + ZEPHIR_INIT_VAR(_3); + ZEPHIR_INIT_VAR(_5); + ZVAL_LONG(_5, pad); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "paddingisvalid", NULL, 0, _5, value); zephir_check_call_status(); - if (zephir_is_true(_5)) { + if (zephir_is_true(_4)) { ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 0); - ZEPHIR_SINIT_VAR(_7); - ZVAL_LONG(&_7, (len - pad)); - zephir_substr(_4, value, 0 , zephir_get_intval(&_7), 0); + ZEPHIR_SINIT_VAR(_6); + ZVAL_LONG(&_6, (len - pad)); + zephir_substr(_3, value, 0 , zephir_get_intval(&_6), 0); } else { - ZEPHIR_CPY_WRT(_4, value); + ZEPHIR_CPY_WRT(_3, value); } - RETURN_CCTOR(_4); + RETURN_CCTOR(_3); } @@ -406,9 +403,8 @@ PHP_METHOD(Ice_Crypt, stripPadding) { */ PHP_METHOD(Ice_Crypt, paddingIsValid) { - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL; zval *value = NULL; - zval *pad_param = NULL, *value_param = NULL, *beforePad, *_0, _1, *_2, _3, *_4 = NULL; + zval *pad_param = NULL, *value_param = NULL, *beforePad = NULL, *_0, _1, *_2, _3, *_4 = NULL; int pad, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); @@ -428,7 +424,7 @@ PHP_METHOD(Ice_Crypt, paddingIsValid) { zephir_substr(_2, value, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); ZEPHIR_SINIT_VAR(_3); ZVAL_LONG(&_3, pad); - ZEPHIR_CALL_FUNCTION(&_4, "str_repeat", &_5, _2, &_3); + ZEPHIR_CALL_FUNCTION(&_4, "str_repeat", NULL, 68, _2, &_3); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(_0, _4)); @@ -476,11 +472,11 @@ PHP_METHOD(Ice_Crypt, getIvSize) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cipher"), PH_NOISY_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_mode"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("cipher"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("mode"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZEPHIR_CONCAT_VSV(_2, _0, "-", _1); - ZEPHIR_RETURN_CALL_FUNCTION("openssl_cipher_iv_length", NULL, _2); + ZEPHIR_RETURN_CALL_FUNCTION("openssl_cipher_iv_length", NULL, 70, _2); zephir_check_call_status(); RETURN_MM(); @@ -503,7 +499,7 @@ PHP_METHOD(Ice_Crypt, setKey) { zephir_get_strval(key, key_param); - zephir_update_property_this(this_ptr, SL("_key"), key TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("key"), key TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -525,7 +521,7 @@ PHP_METHOD(Ice_Crypt, setCipher) { zephir_get_strval(cipher, cipher_param); - zephir_update_property_this(this_ptr, SL("_cipher"), cipher TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("cipher"), cipher TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -547,7 +543,7 @@ PHP_METHOD(Ice_Crypt, setMode) { zephir_get_strval(mode, mode_param); - zephir_update_property_this(this_ptr, SL("_mode"), mode TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("mode"), mode TSRMLS_CC); ZEPHIR_MM_RESTORE(); } diff --git a/ext/ice/crypt.zep.h b/ext/ice/crypt.zep.h index 8d9389f5..862e10e9 100644 --- a/ext/ice/crypt.zep.h +++ b/ext/ice/crypt.zep.h @@ -6,9 +6,9 @@ ZEPHIR_INIT_CLASS(Ice_Crypt); PHP_METHOD(Ice_Crypt, __construct); PHP_METHOD(Ice_Crypt, encrypt); PHP_METHOD(Ice_Crypt, generateInputVector); -PHP_METHOD(Ice_Crypt, _encrypt); +PHP_METHOD(Ice_Crypt, doEncrypt); PHP_METHOD(Ice_Crypt, decrypt); -PHP_METHOD(Ice_Crypt, _decrypt); +PHP_METHOD(Ice_Crypt, doDecrypt); PHP_METHOD(Ice_Crypt, getJsonPayload); PHP_METHOD(Ice_Crypt, hash); PHP_METHOD(Ice_Crypt, addPadding); @@ -28,7 +28,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_crypt_encrypt, 0, 0, 1) ZEND_ARG_INFO(0, text) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_crypt__encrypt, 0, 0, 2) +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_crypt_doencrypt, 0, 0, 2) ZEND_ARG_INFO(0, value) ZEND_ARG_INFO(0, iv) ZEND_END_ARG_INFO() @@ -37,7 +37,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_crypt_decrypt, 0, 0, 1) ZEND_ARG_INFO(0, text) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_crypt__decrypt, 0, 0, 2) +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_crypt_dodecrypt, 0, 0, 2) ZEND_ARG_INFO(0, value) ZEND_ARG_INFO(0, iv) ZEND_END_ARG_INFO() @@ -83,9 +83,9 @@ ZEPHIR_INIT_FUNCS(ice_crypt_method_entry) { PHP_ME(Ice_Crypt, __construct, arginfo_ice_crypt___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Crypt, encrypt, arginfo_ice_crypt_encrypt, ZEND_ACC_PUBLIC) PHP_ME(Ice_Crypt, generateInputVector, NULL, ZEND_ACC_PROTECTED) - PHP_ME(Ice_Crypt, _encrypt, arginfo_ice_crypt__encrypt, ZEND_ACC_PROTECTED) + PHP_ME(Ice_Crypt, doEncrypt, arginfo_ice_crypt_doencrypt, ZEND_ACC_PROTECTED) PHP_ME(Ice_Crypt, decrypt, arginfo_ice_crypt_decrypt, ZEND_ACC_PUBLIC) - PHP_ME(Ice_Crypt, _decrypt, arginfo_ice_crypt__decrypt, ZEND_ACC_PROTECTED) + PHP_ME(Ice_Crypt, doDecrypt, arginfo_ice_crypt_dodecrypt, ZEND_ACC_PROTECTED) PHP_ME(Ice_Crypt, getJsonPayload, arginfo_ice_crypt_getjsonpayload, ZEND_ACC_PROTECTED) PHP_ME(Ice_Crypt, hash, arginfo_ice_crypt_hash, ZEND_ACC_PROTECTED) PHP_ME(Ice_Crypt, addPadding, arginfo_ice_crypt_addpadding, ZEND_ACC_PROTECTED) @@ -96,5 +96,5 @@ ZEPHIR_INIT_FUNCS(ice_crypt_method_entry) { PHP_ME(Ice_Crypt, setKey, arginfo_ice_crypt_setkey, ZEND_ACC_PUBLIC) PHP_ME(Ice_Crypt, setCipher, arginfo_ice_crypt_setcipher, ZEND_ACC_PUBLIC) PHP_ME(Ice_Crypt, setMode, arginfo_ice_crypt_setmode, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/db.zep.c b/ext/ice/db.zep.c index 27cefcb4..1e98b669 100644 --- a/ext/ice/db.zep.c +++ b/ext/ice/db.zep.c @@ -14,9 +14,10 @@ #include "kernel/main.h" #include "kernel/object.h" #include "kernel/memory.h" -#include "kernel/array.h" -#include "kernel/fcall.h" #include "kernel/operators.h" +#include "kernel/fcall.h" +#include "kernel/concat.h" +#include "kernel/array.h" /** @@ -32,7 +33,7 @@ ZEPHIR_INIT_CLASS(Ice_Db) { ZEPHIR_REGISTER_CLASS(Ice, Db, ice, db, ice_db_method_entry, 0); - zend_declare_property_null(ice_db_ce, SL("_driver"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_db_ce, SL("driver"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -41,24 +42,103 @@ ZEPHIR_INIT_CLASS(Ice_Db) { PHP_METHOD(Ice_Db, getDriver) { - RETURN_MEMBER(this_ptr, "_driver"); + RETURN_MEMBER(this_ptr, "driver"); + +} + +PHP_METHOD(Ice_Db, setDriver) { + + zval *driver; + + zephir_fetch_params(0, 1, 0, &driver); + + + + zephir_update_property_this(this_ptr, SL("driver"), driver TSRMLS_CC); } /** * 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 */ PHP_METHOD(Ice_Db, __construct) { - zval *driver; + zend_bool _0; + int port, ZEPHIR_LAST_CALL_STATUS; + zval *host = NULL, *name = NULL, *user = NULL, *password = NULL; + zval *driver, *host_param = NULL, *port_param = NULL, *name_param = NULL, *user_param = NULL, *password_param = NULL, *_1 = NULL, _2 = zval_used_for_init, *_3 = NULL; - zephir_fetch_params(0, 1, 0, &driver); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 5, &driver, &host_param, &port_param, &name_param, &user_param, &password_param); + if (!host_param) { + ZEPHIR_INIT_VAR(host); + ZVAL_EMPTY_STRING(host); + } else { + zephir_get_strval(host, host_param); + } + if (!port_param) { + port = 0; + } else { + port = zephir_get_intval(port_param); + } + if (!name_param) { + ZEPHIR_INIT_VAR(name); + ZVAL_EMPTY_STRING(name); + } else { + zephir_get_strval(name, name_param); + } + if (!user_param) { + ZEPHIR_INIT_VAR(user); + ZVAL_EMPTY_STRING(user); + } else { + zephir_get_strval(user, user_param); + } + if (!password_param) { + ZEPHIR_INIT_VAR(password); + ZVAL_EMPTY_STRING(password); + } else { + zephir_get_strval(password, password_param); + } - zephir_update_property_this(this_ptr, SL("_driver"), driver TSRMLS_CC); + _0 = Z_TYPE_P(driver) == IS_OBJECT; + if (_0) { + _0 = (zephir_instance_of_ev(driver, ice_db_dbinterface_ce TSRMLS_CC)); + } + if (_0) { + zephir_update_property_this(this_ptr, SL("driver"), driver TSRMLS_CC); + } else if (Z_TYPE_P(driver) == IS_STRING) { + if (ZEPHIR_IS_STRING(driver, "mongodb")) { + ZEPHIR_INIT_VAR(_1); + object_init_ex(_1, ice_db_driver_mongo_ce); + ZEPHIR_SINIT_VAR(_2); + ZVAL_LONG(&_2, port); + ZEPHIR_INIT_VAR(_3); + ZEPHIR_CONCAT_VSVSVSVSVSV(_3, driver, "://", user, ":", password, "@", host, ":", &_2, "/", name); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 71, _3, name); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("driver"), _1 TSRMLS_CC); + } else { + ZEPHIR_INIT_NVAR(_1); + object_init_ex(_1, ice_db_driver_pdo_ce); + ZEPHIR_SINIT_NVAR(_2); + ZVAL_LONG(&_2, port); + ZEPHIR_INIT_LNVAR(_3); + ZEPHIR_CONCAT_VSVSVSV(_3, driver, ":host=", host, ";port=", &_2, ";dbname=", name); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 72, _3, user, password); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("driver"), _1 TSRMLS_CC); + } + } + ZEPHIR_MM_RESTORE(); } @@ -82,9 +162,9 @@ PHP_METHOD(Ice_Db, __call) { ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_driver"), PH_NOISY_CC); + zephir_read_property_this(&_1, this_ptr, SL("driver"), PH_NOISY_CC); zephir_array_fast_append(_0, _1); zephir_array_fast_append(_0, method); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _0, arguments); diff --git a/ext/ice/db.zep.h b/ext/ice/db.zep.h index 217a5765..b818ef05 100644 --- a/ext/ice/db.zep.h +++ b/ext/ice/db.zep.h @@ -4,11 +4,21 @@ extern zend_class_entry *ice_db_ce; ZEPHIR_INIT_CLASS(Ice_Db); PHP_METHOD(Ice_Db, getDriver); +PHP_METHOD(Ice_Db, setDriver); PHP_METHOD(Ice_Db, __construct); PHP_METHOD(Ice_Db, __call); +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_db_setdriver, 0, 0, 1) + ZEND_ARG_INFO(0, driver) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_db___construct, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, driver, Ice\\Db\\DbInterface, 0) + ZEND_ARG_INFO(0, driver) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, port) + ZEND_ARG_INFO(0, name) + ZEND_ARG_INFO(0, user) + ZEND_ARG_INFO(0, password) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_db___call, 0, 0, 1) @@ -18,7 +28,8 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_db_method_entry) { PHP_ME(Ice_Db, getDriver, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Db, setDriver, arginfo_ice_db_setdriver, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db, __construct, arginfo_ice_db___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Db, __call, arginfo_ice_db___call, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/db/dbinterface.zep.h b/ext/ice/db/dbinterface.zep.h index 1717b9b5..642dece9 100644 --- a/ext/ice/db/dbinterface.zep.h +++ b/ext/ice/db/dbinterface.zep.h @@ -47,5 +47,5 @@ ZEPHIR_INIT_FUNCS(ice_db_dbinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Db_DbInterface, insert, arginfo_ice_db_dbinterface_insert) PHP_ABSTRACT_ME(Ice_Db_DbInterface, update, arginfo_ice_db_dbinterface_update) PHP_ABSTRACT_ME(Ice_Db_DbInterface, remove, arginfo_ice_db_dbinterface_remove) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/db/driver/mongo.zep.c b/ext/ice/db/driver/mongo.zep.c index 325f2fd2..fc711975 100644 --- a/ext/ice/db/driver/mongo.zep.c +++ b/ext/ice/db/driver/mongo.zep.c @@ -34,15 +34,15 @@ ZEPHIR_INIT_CLASS(Ice_Db_Driver_Mongo) { ZEPHIR_REGISTER_CLASS(Ice\\Db\\Driver, Mongo, ice, db_driver_mongo, ice_db_driver_mongo_method_entry, 0); - zend_declare_property_string(ice_db_driver_mongo_ce, SL("_id"), "_id", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_db_driver_mongo_ce, SL("id"), "_id", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_db_driver_mongo_ce, SL("_type"), "NOSQL", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_db_driver_mongo_ce, SL("type"), "NOSQL", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_db_driver_mongo_ce, SL("_error"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_db_driver_mongo_ce, SL("error"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_db_driver_mongo_ce, SL("_client"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_db_driver_mongo_ce, SL("client"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_db_driver_mongo_ce, SL("_lastInsertId"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_db_driver_mongo_ce, SL("lastInsertId"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(ice_db_driver_mongo_ce TSRMLS_CC, 1, ice_db_dbinterface_ce); return SUCCESS; @@ -52,28 +52,28 @@ ZEPHIR_INIT_CLASS(Ice_Db_Driver_Mongo) { PHP_METHOD(Ice_Db_Driver_Mongo, getId) { - RETURN_MEMBER(this_ptr, "_id"); + RETURN_MEMBER(this_ptr, "id"); } PHP_METHOD(Ice_Db_Driver_Mongo, getType) { - RETURN_MEMBER(this_ptr, "_type"); + RETURN_MEMBER(this_ptr, "type"); } PHP_METHOD(Ice_Db_Driver_Mongo, getClient) { - RETURN_MEMBER(this_ptr, "_client"); + RETURN_MEMBER(this_ptr, "client"); } PHP_METHOD(Ice_Db_Driver_Mongo, getLastInsertId) { - RETURN_MEMBER(this_ptr, "_lastInsertId"); + RETURN_MEMBER(this_ptr, "lastInsertId"); } @@ -113,15 +113,40 @@ PHP_METHOD(Ice_Db_Driver_Mongo, __construct) { object_init_ex(_0, zephir_get_internal_ce(SS("mongodb") TSRMLS_CC)); ZEPHIR_INIT_VAR(_1); object_init_ex(_1, zephir_get_internal_ce(SS("mongoclient") TSRMLS_CC)); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, dsn, options); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 0, dsn, options); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1, dbname); + ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 0, _1, dbname); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_client"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("client"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } +/** + * Get the id value. + * + * @param string id + * @return object + */ +PHP_METHOD(Ice_Db_Driver_Mongo, getIdValue) { + + int ZEPHIR_LAST_CALL_STATUS; + zval *id_param = NULL; + zval *id = NULL; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &id_param); + + zephir_get_strval(id, id_param); + + + object_init_ex(return_value, zephir_get_internal_ce(SS("mongoid") TSRMLS_CC)); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0, id); + zephir_check_call_status(); + RETURN_MM(); + +} + /** * Find one document that match criteria. * @@ -145,7 +170,6 @@ PHP_METHOD(Ice_Db_Driver_Mongo, findOne) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -173,16 +197,16 @@ PHP_METHOD(Ice_Db_Driver_Mongo, findOne) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 1); zephir_array_update_string(&options, SL("limit"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&result, this_ptr, "select", NULL, from, filters, options, fields); + ZEPHIR_CALL_METHOD(&result, this_ptr, "select", NULL, 0, from, filters, options, fields); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); - ZEPHIR_CALL_METHOD(&_2, result, "count", NULL); + ZEPHIR_CALL_METHOD(&_2, result, "count", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_2)) { object_init_ex(_1, ice_arr_ce); - ZEPHIR_CALL_METHOD(&_3, result, "getnext", NULL); + ZEPHIR_CALL_METHOD(&_3, result, "getnext", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, _3); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 6, _3); zephir_check_call_status(); } else { ZVAL_BOOL(_1, 0); @@ -220,7 +244,6 @@ PHP_METHOD(Ice_Db_Driver_Mongo, find) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -245,12 +268,12 @@ PHP_METHOD(Ice_Db_Driver_Mongo, find) { } - ZEPHIR_CALL_METHOD(&result, this_ptr, "select", NULL, from, filters, options, fields); + ZEPHIR_CALL_METHOD(&result, this_ptr, "select", NULL, 0, from, filters, options, fields); zephir_check_call_status(); object_init_ex(return_value, ice_arr_ce); - ZEPHIR_CALL_FUNCTION(&_0, "iterator_to_array", NULL, result); + ZEPHIR_CALL_FUNCTION(&_0, "iterator_to_array", NULL, 73, result); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _0); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 6, _0); zephir_check_call_status(); RETURN_MM(); @@ -268,7 +291,7 @@ PHP_METHOD(Ice_Db_Driver_Mongo, select) { int ZEPHIR_LAST_CALL_STATUS; zval *options = NULL, *fields = NULL; - zval *from_param = NULL, *filters = NULL, *options_param = NULL, *fields_param = NULL, *filtered = NULL, *collection = NULL, *result = NULL, *tmp = NULL, *_0, *_1, *_2, *_3, *_4, *_5, *_6 = NULL; + zval *from_param = NULL, *filters = NULL, *options_param = NULL, *fields_param = NULL, *filtered = NULL, *collection = NULL, *result = NULL, *tmp = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3, *_4, *_5; zval *from = NULL; ZEPHIR_MM_GROW(); @@ -278,7 +301,6 @@ PHP_METHOD(Ice_Db_Driver_Mongo, select) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -306,18 +328,29 @@ PHP_METHOD(Ice_Db_Driver_Mongo, select) { ZEPHIR_INIT_VAR(_0); zephir_gettype(_0, filters TSRMLS_CC); do { + if (ZEPHIR_IS_STRING(_0, "object")) { + if (zephir_instance_of_ev(filters, zephir_get_internal_ce(SS("mongoid") TSRMLS_CC) TSRMLS_CC)) { + ZEPHIR_INIT_VAR(filtered); + zephir_create_array(filtered, 1, 0 TSRMLS_CC); + ZEPHIR_OBS_VAR(_1); + zephir_read_property_this(&_1, this_ptr, SL("id"), PH_NOISY_CC); + zephir_array_update_zval(&filtered, _1, &filters, PH_COPY); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Object must be an MongoId instance", "ice/db/driver/mongo.zep", 110); + return; + } + break; + } if (ZEPHIR_IS_STRING(_0, "array")) { ZEPHIR_CPY_WRT(filtered, filters); break; } if (ZEPHIR_IS_STRING(_0, "integer") || ZEPHIR_IS_STRING(_0, "string")) { ZEPHIR_INIT_NVAR(filtered); - array_init_size(filtered, 2); - ZEPHIR_OBS_VAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_id"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_2); - object_init_ex(_2, zephir_get_internal_ce(SS("mongoid") TSRMLS_CC)); - ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, filters); + zephir_create_array(filtered, 1, 0 TSRMLS_CC); + ZEPHIR_OBS_NVAR(_1); + zephir_read_property_this(&_1, this_ptr, SL("id"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getidvalue", NULL, 0, filters); zephir_check_call_status(); zephir_array_update_zval(&filtered, _1, &_2, PH_COPY); break; @@ -327,33 +360,33 @@ PHP_METHOD(Ice_Db_Driver_Mongo, select) { break; } while(0); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&collection, _3, "selectcollection", NULL, from); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&collection, _3, "selectcollection", NULL, 0, from); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, collection, "find", NULL, filtered, fields); + ZEPHIR_CALL_METHOD(&result, collection, "find", NULL, 0, filtered, fields); zephir_check_call_status(); if (zephir_array_isset_string(options, SS("order"))) { ZEPHIR_CPY_WRT(tmp, result); - zephir_array_fetch_string(&_4, options, SL("order"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 113 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&result, tmp, "sort", NULL, _4); + zephir_array_fetch_string(&_4, options, SL("order"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 133 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&result, tmp, "sort", NULL, 0, _4); zephir_check_call_status(); } if (zephir_array_isset_string(options, SS("limit"))) { ZEPHIR_CPY_WRT(tmp, result); - zephir_array_fetch_string(&_4, options, SL("limit"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 117 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&result, tmp, "limit", NULL, _4); + zephir_array_fetch_string(&_4, options, SL("limit"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 137 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&result, tmp, "limit", NULL, 0, _4); zephir_check_call_status(); } if (zephir_array_isset_string(options, SS("offset"))) { ZEPHIR_CPY_WRT(tmp, result); - zephir_array_fetch_string(&_4, options, SL("offset"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 121 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&result, tmp, "skip", NULL, _4); + zephir_array_fetch_string(&_4, options, SL("offset"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 141 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&result, tmp, "skip", NULL, 0, _4); zephir_check_call_status(); } - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_6, _5, "lasterror", NULL); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_2, _5, "lasterror", NULL, 0); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_error"), _6 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("error"), _2 TSRMLS_CC); RETURN_CCTOR(result); } @@ -378,7 +411,6 @@ PHP_METHOD(Ice_Db_Driver_Mongo, insert) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -393,18 +425,18 @@ PHP_METHOD(Ice_Db_Driver_Mongo, insert) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&collection, _0, "selectcollection", NULL, from); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&collection, _0, "selectcollection", NULL, 0, from); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, collection, "insert", NULL, fields); + ZEPHIR_CALL_METHOD(&status, collection, "insert", NULL, 0, fields); zephir_check_call_status(); ZEPHIR_OBS_VAR(_2); - zephir_read_property_this(&_2, this_ptr, SL("_id"), PH_NOISY_CC); - zephir_array_fetch(&_1, fields, _2, PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 141 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_lastInsertId"), _1 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_error"), status TSRMLS_CC); + zephir_read_property_this(&_2, this_ptr, SL("id"), PH_NOISY_CC); + zephir_array_fetch(&_1, fields, _2, PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 161 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("lastInsertId"), _1 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("error"), status TSRMLS_CC); ZEPHIR_INIT_VAR(_3); - zephir_array_fetch_string(&_4, status, SL("err"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 144 TSRMLS_CC); + zephir_array_fetch_string(&_4, status, SL("err"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 164 TSRMLS_CC); if (Z_TYPE_P(_4) == IS_NULL) { ZVAL_BOOL(_3, 1); } else { @@ -435,7 +467,6 @@ PHP_METHOD(Ice_Db_Driver_Mongo, update) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -454,14 +485,14 @@ PHP_METHOD(Ice_Db_Driver_Mongo, update) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&collection, _0, "selectcollection", NULL, from); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&collection, _0, "selectcollection", NULL, 0, from); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, collection, "update", NULL, filters, fields); + ZEPHIR_CALL_METHOD(&status, collection, "update", NULL, 0, filters, fields); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_error"), status TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("error"), status TSRMLS_CC); ZEPHIR_INIT_VAR(_1); - zephir_array_fetch_string(&_2, status, SL("err"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 162 TSRMLS_CC); + zephir_array_fetch_string(&_2, status, SL("err"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 182 TSRMLS_CC); if (Z_TYPE_P(_2) == IS_NULL) { ZVAL_BOOL(_1, 1); } else { @@ -490,7 +521,6 @@ PHP_METHOD(Ice_Db_Driver_Mongo, remove) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -503,14 +533,14 @@ PHP_METHOD(Ice_Db_Driver_Mongo, remove) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&collection, _0, "selectcollection", NULL, from); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&collection, _0, "selectcollection", NULL, 0, from); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, collection, "remove", NULL, filters); + ZEPHIR_CALL_METHOD(&status, collection, "remove", NULL, 0, filters); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_error"), status TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("error"), status TSRMLS_CC); ZEPHIR_INIT_VAR(_1); - zephir_array_fetch_string(&_2, status, SL("err"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 179 TSRMLS_CC); + zephir_array_fetch_string(&_2, status, SL("err"), PH_NOISY | PH_READONLY, "ice/db/driver/mongo.zep", 199 TSRMLS_CC); if (Z_TYPE_P(_2) == IS_NULL) { ZVAL_BOOL(_1, 1); } else { @@ -527,10 +557,10 @@ PHP_METHOD(Ice_Db_Driver_Mongo, remove) { */ PHP_METHOD(Ice_Db_Driver_Mongo, getError) { - zval *error, *_0; + zval *error = NULL, *_0; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_error"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("error"), PH_NOISY_CC); zephir_array_isset_string_fetch(&error, _0, SS("err"), 1 TSRMLS_CC); RETURN_CTORW(error); diff --git a/ext/ice/db/driver/mongo.zep.h b/ext/ice/db/driver/mongo.zep.h index 944594b4..5cbdd02e 100644 --- a/ext/ice/db/driver/mongo.zep.h +++ b/ext/ice/db/driver/mongo.zep.h @@ -8,6 +8,7 @@ PHP_METHOD(Ice_Db_Driver_Mongo, getType); PHP_METHOD(Ice_Db_Driver_Mongo, getClient); PHP_METHOD(Ice_Db_Driver_Mongo, getLastInsertId); PHP_METHOD(Ice_Db_Driver_Mongo, __construct); +PHP_METHOD(Ice_Db_Driver_Mongo, getIdValue); PHP_METHOD(Ice_Db_Driver_Mongo, findOne); PHP_METHOD(Ice_Db_Driver_Mongo, find); PHP_METHOD(Ice_Db_Driver_Mongo, select); @@ -22,6 +23,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_db_driver_mongo___construct, 0, 0, 1) ZEND_ARG_ARRAY_INFO(0, options, 1) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_db_driver_mongo_getidvalue, 0, 0, 1) + ZEND_ARG_INFO(0, id) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_db_driver_mongo_findone, 0, 0, 1) ZEND_ARG_INFO(0, from) ZEND_ARG_INFO(0, filters) @@ -65,6 +70,7 @@ ZEPHIR_INIT_FUNCS(ice_db_driver_mongo_method_entry) { PHP_ME(Ice_Db_Driver_Mongo, getClient, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Mongo, getLastInsertId, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Mongo, __construct, arginfo_ice_db_driver_mongo___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_ME(Ice_Db_Driver_Mongo, getIdValue, arginfo_ice_db_driver_mongo_getidvalue, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Mongo, findOne, arginfo_ice_db_driver_mongo_findone, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Mongo, find, arginfo_ice_db_driver_mongo_find, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Mongo, select, arginfo_ice_db_driver_mongo_select, ZEND_ACC_PUBLIC) @@ -72,5 +78,5 @@ ZEPHIR_INIT_FUNCS(ice_db_driver_mongo_method_entry) { PHP_ME(Ice_Db_Driver_Mongo, update, arginfo_ice_db_driver_mongo_update, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Mongo, remove, arginfo_ice_db_driver_mongo_remove, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Mongo, getError, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/db/driver/pdo.zep.c b/ext/ice/db/driver/pdo.zep.c index 96082bbc..fdd2747f 100644 --- a/ext/ice/db/driver/pdo.zep.c +++ b/ext/ice/db/driver/pdo.zep.c @@ -14,15 +14,15 @@ #include "kernel/main.h" #include "kernel/object.h" #include "kernel/memory.h" -#include "kernel/fcall.h" +#include "kernel/string.h" #include "kernel/array.h" +#include "kernel/fcall.h" #include "kernel/operators.h" #include "ext/pdo/php_pdo_driver.h" #include "ext/spl/spl_exceptions.h" #include "kernel/exception.h" #include "kernel/hash.h" #include "kernel/concat.h" -#include "kernel/string.h" /** @@ -38,13 +38,13 @@ ZEPHIR_INIT_CLASS(Ice_Db_Driver_Pdo) { ZEPHIR_REGISTER_CLASS(Ice\\Db\\Driver, Pdo, ice, db_driver_pdo, ice_db_driver_pdo_method_entry, 0); - zend_declare_property_string(ice_db_driver_pdo_ce, SL("_id"), "id", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_db_driver_pdo_ce, SL("id"), "id", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_db_driver_pdo_ce, SL("_type"), "SQL", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_db_driver_pdo_ce, SL("type"), "SQL", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_db_driver_pdo_ce, SL("_error"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_db_driver_pdo_ce, SL("error"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_db_driver_pdo_ce, SL("_client"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_db_driver_pdo_ce, SL("client"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(ice_db_driver_pdo_ce TSRMLS_CC, 1, ice_db_dbinterface_ce); return SUCCESS; @@ -54,21 +54,21 @@ ZEPHIR_INIT_CLASS(Ice_Db_Driver_Pdo) { PHP_METHOD(Ice_Db_Driver_Pdo, getId) { - RETURN_MEMBER(this_ptr, "_id"); + RETURN_MEMBER(this_ptr, "id"); } PHP_METHOD(Ice_Db_Driver_Pdo, getType) { - RETURN_MEMBER(this_ptr, "_type"); + RETURN_MEMBER(this_ptr, "type"); } PHP_METHOD(Ice_Db_Driver_Pdo, getClient) { - RETURN_MEMBER(this_ptr, "_client"); + RETURN_MEMBER(this_ptr, "client"); } @@ -82,11 +82,10 @@ PHP_METHOD(Ice_Db_Driver_Pdo, getClient) { */ PHP_METHOD(Ice_Db_Driver_Pdo, __construct) { - zend_bool _2; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_6 = NULL; + zend_bool _2; zval *options = NULL; - zval *dsn_param = NULL, *user_param = NULL, *password_param = NULL, *options_param = NULL, *parts, *_0 = NULL, *_3, _4, *_5 = NULL, *_7; + zval *dsn_param = NULL, *user_param = NULL, *password_param = NULL, *options_param = NULL, *parts = NULL, *_0, _1, *_3, _4, *_5 = NULL, *_6 = NULL; zval *dsn = NULL, *user = NULL, *password = NULL; ZEPHIR_MM_GROW(); @@ -116,35 +115,50 @@ PHP_METHOD(Ice_Db_Driver_Pdo, __construct) { ZEPHIR_INIT_VAR(parts); array_init(parts); ZEPHIR_INIT_VAR(_0); - ZVAL_STRING(_0, "/^.+?(?:dbname|database)=(.+?)(?=;|$)/i", ZEPHIR_TEMP_PARAM_COPY); - Z_SET_ISREF_P(parts); - ZEPHIR_CALL_FUNCTION(NULL, "preg_match", &_1, _0, dsn, parts); - zephir_check_temp_parameter(_0); - Z_UNSET_ISREF_P(parts); - zephir_check_call_status(); + ZEPHIR_SINIT_VAR(_1); + ZVAL_STRING(&_1, "/^.+?(?:dbname|database)=(.+?)(?=;|$)/i", 0); + zephir_preg_match(_0, &_1, dsn, parts, 0, 0 , 0 TSRMLS_CC); _2 = zephir_array_isset_long(parts, 0); if (_2) { zephir_array_fetch_long(&_3, parts, 0, PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 40 TSRMLS_CC); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, ":", 0); - ZEPHIR_CALL_FUNCTION(&_5, "strstr", &_6, _3, &_4, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_CALL_FUNCTION(&_5, "strstr", NULL, 74, _3, &_4, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); _2 = ZEPHIR_IS_STRING(_5, "mysql"); } if (_2) { - ZEPHIR_INIT_NVAR(_0); - ZVAL_STRING(_0, "SET NAMES utf8;", 1); - zephir_array_update_long(&options, 1002, &_0, PH_COPY | PH_SEPARATE, "ice/db/driver/pdo.zep", 41); + ZEPHIR_INIT_VAR(_6); + ZVAL_STRING(_6, "SET NAMES utf8;", 1); + zephir_array_update_long(&options, 1002, &_6, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } - ZEPHIR_INIT_VAR(_7); - object_init_ex(_7, php_pdo_get_dbh_ce()); - ZEPHIR_CALL_METHOD(NULL, _7, "__construct", NULL, dsn, user, password, options); + ZEPHIR_INIT_NVAR(_6); + object_init_ex(_6, php_pdo_get_dbh_ce()); + ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, 0, dsn, user, password, options); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_client"), _7 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("client"), _6 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } +/** + * Get the id value. + * + * @param string id + * @return int + */ +PHP_METHOD(Ice_Db_Driver_Pdo, getIdValue) { + + zval *id; + + zephir_fetch_params(0, 1, 0, &id); + + + + RETURN_LONG(zephir_get_intval(id)); + +} + /** * Find one row that match criteria. * @@ -168,7 +182,6 @@ PHP_METHOD(Ice_Db_Driver_Pdo, findOne) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -196,18 +209,18 @@ PHP_METHOD(Ice_Db_Driver_Pdo, findOne) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, 1); zephir_array_update_string(&options, SL("limit"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&result, this_ptr, "select", NULL, from, filters, options, fields); + ZEPHIR_CALL_METHOD(&result, this_ptr, "select", NULL, 0, from, filters, options, fields); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); - ZEPHIR_CALL_METHOD(&_2, result, "rowcount", NULL); + ZEPHIR_CALL_METHOD(&_2, result, "rowcount", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_2)) { object_init_ex(_1, ice_arr_ce); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, 2); - ZEPHIR_CALL_METHOD(&_3, result, "fetch", NULL, _4); + ZEPHIR_CALL_METHOD(&_3, result, "fetch", NULL, 0, _4); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, _3); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 6, _3); zephir_check_call_status(); } else { ZVAL_BOOL(_1, 0); @@ -250,7 +263,6 @@ PHP_METHOD(Ice_Db_Driver_Pdo, find) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -275,14 +287,14 @@ PHP_METHOD(Ice_Db_Driver_Pdo, find) { } - ZEPHIR_CALL_METHOD(&result, this_ptr, "select", NULL, from, filters, options, fields); + ZEPHIR_CALL_METHOD(&result, this_ptr, "select", NULL, 0, from, filters, options, fields); zephir_check_call_status(); object_init_ex(return_value, ice_arr_ce); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, 2); - ZEPHIR_CALL_METHOD(&_0, result, "fetchall", NULL, _1); + ZEPHIR_CALL_METHOD(&_0, result, "fetchall", NULL, 0, _1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _0); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 6, _0); zephir_check_call_status(); RETURN_MM(); @@ -296,12 +308,12 @@ PHP_METHOD(Ice_Db_Driver_Pdo, find) { */ PHP_METHOD(Ice_Db_Driver_Pdo, where) { - zephir_nts_static zephir_fcall_cache_entry *_8 = NULL, *_9 = NULL; + zephir_fcall_cache_entry *_8 = NULL, *_9 = NULL; HashTable *_3, *_6, *_15; HashPosition _2, _5, _14; int _0, ZEPHIR_LAST_CALL_STATUS; zval *values = NULL; - zval *filters = NULL, *values_param = NULL, *and, *data = NULL, *operator = NULL, *key = NULL, *item = NULL, *value = NULL, *or = NULL, *is = NULL, *index = NULL, *i = NULL, *sql, *_1, **_4, **_7, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, **_16; + zval *filters = NULL, *values_param = NULL, *and = NULL, *data = NULL, *operator = NULL, *key = NULL, *item = NULL, *value = NULL, *or = NULL, *is = NULL, *index = NULL, *i = NULL, *sql = NULL, *_1, **_4, **_7, *_10 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, **_16; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &filters, &values_param); @@ -335,7 +347,7 @@ PHP_METHOD(Ice_Db_Driver_Pdo, where) { zephir_gettype(_1, filters TSRMLS_CC); do { if (ZEPHIR_IS_STRING(_1, "array")) { - zephir_is_iterable(filters, &_3, &_2, 0, 0, "ice/db/driver/pdo.zep", 187); + zephir_is_iterable(filters, &_3, &_2, 0, 0, "ice/db/driver/pdo.zep", 198); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) @@ -346,28 +358,28 @@ PHP_METHOD(Ice_Db_Driver_Pdo, where) { if (ZEPHIR_IS_STRING(operator, "OR") || ZEPHIR_IS_STRING(operator, "or") || ZEPHIR_IS_STRING(operator, "$or")) { ZEPHIR_INIT_NVAR(or); array_init(or); - zephir_is_iterable(data, &_6, &_5, 0, 0, "ice/db/driver/pdo.zep", 140); + zephir_is_iterable(data, &_6, &_5, 0, 0, "ice/db/driver/pdo.zep", 151); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(item, _7); - Z_SET_ISREF_P(item); - ZEPHIR_CALL_FUNCTION(&key, "key", &_8, item); - Z_UNSET_ISREF_P(item); + ZEPHIR_MAKE_REF(item); + ZEPHIR_CALL_FUNCTION(&key, "key", &_8, 75, item); + ZEPHIR_UNREF(item); zephir_check_call_status(); - Z_SET_ISREF_P(item); - ZEPHIR_CALL_FUNCTION(&value, "current", &_9, item); - Z_UNSET_ISREF_P(item); + ZEPHIR_MAKE_REF(item); + ZEPHIR_CALL_FUNCTION(&value, "current", &_9, 76, item); + ZEPHIR_UNREF(item); zephir_check_call_status(); if (Z_TYPE_P(value) == IS_ARRAY) { - Z_SET_ISREF_P(value); - ZEPHIR_CALL_FUNCTION(&is, "key", &_8, value); - Z_UNSET_ISREF_P(value); + ZEPHIR_MAKE_REF(value); + ZEPHIR_CALL_FUNCTION(&is, "key", &_8, 75, value); + ZEPHIR_UNREF(value); zephir_check_call_status(); - Z_SET_ISREF_P(value); - ZEPHIR_CALL_FUNCTION(&_10, "current", &_9, value); - Z_UNSET_ISREF_P(value); + ZEPHIR_MAKE_REF(value); + ZEPHIR_CALL_FUNCTION(&_10, "current", &_9, 76, value); + ZEPHIR_UNREF(value); zephir_check_call_status(); ZEPHIR_CPY_WRT(value, _10); } else { @@ -389,39 +401,39 @@ PHP_METHOD(Ice_Db_Driver_Pdo, where) { } while (zephir_array_isset(values, index)); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVSVSV(_11, "`", key, "` ", is, " ", index); - zephir_array_append(&or, _11, PH_SEPARATE, "ice/db/driver/pdo.zep", 137); + zephir_array_append(&or, _11, PH_SEPARATE, "ice/db/driver/pdo.zep", 148); zephir_array_update_zval(&values, index, &value, PH_COPY | PH_SEPARATE); } ZEPHIR_INIT_NVAR(_12); zephir_fast_join_str(_12, SL(" OR "), or TSRMLS_CC); ZEPHIR_INIT_LNVAR(_13); ZEPHIR_CONCAT_SVS(_13, "(", _12, ")"); - zephir_array_append(&and, _13, PH_SEPARATE, "ice/db/driver/pdo.zep", 140); + zephir_array_append(&and, _13, PH_SEPARATE, "ice/db/driver/pdo.zep", 151); break; } if (ZEPHIR_IS_STRING(operator, "AND") || ZEPHIR_IS_STRING(operator, "and") || ZEPHIR_IS_STRING(operator, "$and")) { - zephir_is_iterable(data, &_15, &_14, 0, 0, "ice/db/driver/pdo.zep", 164); + zephir_is_iterable(data, &_15, &_14, 0, 0, "ice/db/driver/pdo.zep", 175); for ( ; zephir_hash_get_current_data_ex(_15, (void**) &_16, &_14) == SUCCESS ; zephir_hash_move_forward_ex(_15, &_14) ) { ZEPHIR_GET_HVALUE(item, _16); - Z_SET_ISREF_P(item); - ZEPHIR_CALL_FUNCTION(&key, "key", &_8, item); - Z_UNSET_ISREF_P(item); + ZEPHIR_MAKE_REF(item); + ZEPHIR_CALL_FUNCTION(&key, "key", &_8, 75, item); + ZEPHIR_UNREF(item); zephir_check_call_status(); - Z_SET_ISREF_P(item); - ZEPHIR_CALL_FUNCTION(&value, "current", &_9, item); - Z_UNSET_ISREF_P(item); + ZEPHIR_MAKE_REF(item); + ZEPHIR_CALL_FUNCTION(&value, "current", &_9, 76, item); + ZEPHIR_UNREF(item); zephir_check_call_status(); if (Z_TYPE_P(value) == IS_ARRAY) { - Z_SET_ISREF_P(value); - ZEPHIR_CALL_FUNCTION(&is, "key", &_8, value); - Z_UNSET_ISREF_P(value); + ZEPHIR_MAKE_REF(value); + ZEPHIR_CALL_FUNCTION(&is, "key", &_8, 75, value); + ZEPHIR_UNREF(value); zephir_check_call_status(); - Z_SET_ISREF_P(value); - ZEPHIR_CALL_FUNCTION(&_10, "current", &_9, value); - Z_UNSET_ISREF_P(value); + ZEPHIR_MAKE_REF(value); + ZEPHIR_CALL_FUNCTION(&_10, "current", &_9, 76, value); + ZEPHIR_UNREF(value); zephir_check_call_status(); ZEPHIR_CPY_WRT(value, _10); } else { @@ -443,7 +455,7 @@ PHP_METHOD(Ice_Db_Driver_Pdo, where) { } while (zephir_array_isset(values, index)); ZEPHIR_INIT_LNVAR(_11); ZEPHIR_CONCAT_SVSVSV(_11, "`", key, "` ", is, " ", index); - zephir_array_append(&and, _11, PH_SEPARATE, "ice/db/driver/pdo.zep", 161); + zephir_array_append(&and, _11, PH_SEPARATE, "ice/db/driver/pdo.zep", 172); zephir_array_update_zval(&values, index, &value, PH_COPY | PH_SEPARATE); } break; @@ -451,13 +463,13 @@ PHP_METHOD(Ice_Db_Driver_Pdo, where) { ZEPHIR_CPY_WRT(key, operator); ZEPHIR_CPY_WRT(value, data); if (Z_TYPE_P(value) == IS_ARRAY) { - Z_SET_ISREF_P(value); - ZEPHIR_CALL_FUNCTION(&is, "key", &_8, value); - Z_UNSET_ISREF_P(value); + ZEPHIR_MAKE_REF(value); + ZEPHIR_CALL_FUNCTION(&is, "key", &_8, 75, value); + ZEPHIR_UNREF(value); zephir_check_call_status(); - Z_SET_ISREF_P(value); - ZEPHIR_CALL_FUNCTION(&_10, "current", &_9, value); - Z_UNSET_ISREF_P(value); + ZEPHIR_MAKE_REF(value); + ZEPHIR_CALL_FUNCTION(&_10, "current", &_9, 76, value); + ZEPHIR_UNREF(value); zephir_check_call_status(); ZEPHIR_CPY_WRT(value, _10); } else { @@ -479,7 +491,7 @@ PHP_METHOD(Ice_Db_Driver_Pdo, where) { } while (zephir_array_isset(values, index)); ZEPHIR_INIT_LNVAR(_13); ZEPHIR_CONCAT_SVSVSV(_13, "`", key, "` ", is, " ", index); - zephir_array_append(&and, _13, PH_SEPARATE, "ice/db/driver/pdo.zep", 182); + zephir_array_append(&and, _13, PH_SEPARATE, "ice/db/driver/pdo.zep", 193); zephir_array_update_zval(&values, index, &value, PH_COPY | PH_SEPARATE); break; } while(0); @@ -504,7 +516,7 @@ PHP_METHOD(Ice_Db_Driver_Pdo, where) { break; } while(0); - array_init_size(return_value, 3); + zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, sql); zephir_array_fast_append(return_value, values); RETURN_MM(); @@ -521,10 +533,9 @@ PHP_METHOD(Ice_Db_Driver_Pdo, where) { */ PHP_METHOD(Ice_Db_Driver_Pdo, select) { - zephir_nts_static zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *options = NULL, *fields = NULL; - zval *from_param = NULL, *filters = NULL, *options_param = NULL, *fields_param = NULL, *columns = NULL, *sql, *filtered = NULL, *values, *query = NULL, *_1, *_2 = NULL, *_3, *_4 = NULL, *_5, *_6 = NULL; + zval *from_param = NULL, *filters = NULL, *options_param = NULL, *fields_param = NULL, *columns = NULL, *sql = NULL, *filtered = NULL, *values = NULL, *query = NULL, *_0, *_1 = NULL, *_2, *_3 = NULL, *_4, *_5 = NULL; zval *from = NULL; ZEPHIR_MM_GROW(); @@ -534,7 +545,6 @@ PHP_METHOD(Ice_Db_Driver_Pdo, select) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -566,49 +576,49 @@ PHP_METHOD(Ice_Db_Driver_Pdo, select) { ZEPHIR_INIT_NVAR(columns); ZVAL_STRING(columns, "*", 1); } - ZEPHIR_CALL_METHOD(&filtered, this_ptr, "where", &_0, filters); + ZEPHIR_CALL_METHOD(&filtered, this_ptr, "where", NULL, 77, filters); zephir_check_call_status(); - zephir_array_fetch_long(&_1, filtered, 0, PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 222 TSRMLS_CC); + zephir_array_fetch_long(&_0, filtered, 0, PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 233 TSRMLS_CC); ZEPHIR_INIT_VAR(sql); - ZEPHIR_CONCAT_SVSVSV(sql, "SELECT ", columns, " FROM `", from, "` WHERE ", _1); + ZEPHIR_CONCAT_SVSVSV(sql, "SELECT ", columns, " FROM `", from, "` WHERE ", _0); ZEPHIR_OBS_VAR(values); - zephir_array_fetch_long(&values, filtered, 1, PH_NOISY, "ice/db/driver/pdo.zep", 223 TSRMLS_CC); + zephir_array_fetch_long(&values, filtered, 1, PH_NOISY, "ice/db/driver/pdo.zep", 234 TSRMLS_CC); if (zephir_array_isset_string(options, SS("group"))) { - ZEPHIR_INIT_VAR(_2); - zephir_array_fetch_string(&_3, options, SL("group"), PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 226 TSRMLS_CC); - zephir_fast_join_str(_2, SL(", "), _3 TSRMLS_CC); - ZEPHIR_INIT_VAR(_4); - ZEPHIR_CONCAT_SV(_4, " GROUP BY ", _2); - zephir_concat_self(&sql, _4 TSRMLS_CC); + ZEPHIR_INIT_VAR(_1); + zephir_array_fetch_string(&_2, options, SL("group"), PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 237 TSRMLS_CC); + zephir_fast_join_str(_1, SL(", "), _2 TSRMLS_CC); + ZEPHIR_INIT_VAR(_3); + ZEPHIR_CONCAT_SV(_3, " GROUP BY ", _1); + zephir_concat_self(&sql, _3 TSRMLS_CC); } if (zephir_array_isset_string(options, SS("order"))) { - ZEPHIR_INIT_NVAR(_2); - zephir_array_fetch_string(&_3, options, SL("order"), PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 229 TSRMLS_CC); - zephir_fast_join_str(_2, SL(", "), _3 TSRMLS_CC); - ZEPHIR_INIT_LNVAR(_4); - ZEPHIR_CONCAT_SV(_4, " ORDER BY ", _2); - zephir_concat_self(&sql, _4 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_1); + zephir_array_fetch_string(&_2, options, SL("order"), PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 240 TSRMLS_CC); + zephir_fast_join_str(_1, SL(", "), _2 TSRMLS_CC); + ZEPHIR_INIT_LNVAR(_3); + ZEPHIR_CONCAT_SV(_3, " ORDER BY ", _1); + zephir_concat_self(&sql, _3 TSRMLS_CC); } if (zephir_array_isset_string(options, SS("limit"))) { - zephir_array_fetch_string(&_3, options, SL("limit"), PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 232 TSRMLS_CC); - ZEPHIR_INIT_LNVAR(_4); - ZEPHIR_CONCAT_SV(_4, " LIMIT ", _3); - zephir_concat_self(&sql, _4 TSRMLS_CC); + zephir_array_fetch_string(&_2, options, SL("limit"), PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 243 TSRMLS_CC); + ZEPHIR_INIT_LNVAR(_3); + ZEPHIR_CONCAT_SV(_3, " LIMIT ", _2); + zephir_concat_self(&sql, _3 TSRMLS_CC); } if (zephir_array_isset_string(options, SS("offset"))) { - zephir_array_fetch_string(&_3, options, SL("offset"), PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 235 TSRMLS_CC); - ZEPHIR_INIT_LNVAR(_4); - ZEPHIR_CONCAT_SV(_4, " OFFSET ", _3); - zephir_concat_self(&sql, _4 TSRMLS_CC); + zephir_array_fetch_string(&_2, options, SL("offset"), PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 246 TSRMLS_CC); + ZEPHIR_INIT_LNVAR(_3); + ZEPHIR_CONCAT_SV(_3, " OFFSET ", _2); + zephir_concat_self(&sql, _3 TSRMLS_CC); } - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&query, _5, "prepare", NULL, sql); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&query, _4, "prepare", NULL, 0, sql); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, query, "execute", NULL, values); + ZEPHIR_CALL_METHOD(NULL, query, "execute", NULL, 0, values); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6, query, "errorinfo", NULL); + ZEPHIR_CALL_METHOD(&_5, query, "errorinfo", NULL, 0); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_error"), _6 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("error"), _5 TSRMLS_CC); RETURN_CCTOR(query); } @@ -625,7 +635,7 @@ PHP_METHOD(Ice_Db_Driver_Pdo, insert) { HashTable *_1; HashPosition _0; zval *fields = NULL; - zval *from_param = NULL, *fields_param = NULL, *key = NULL, *value = NULL, *columns, *values, *sql, *query = NULL, *status = NULL, **_2, *_3 = NULL, *_4 = NULL, *_5, *_6, *_7, *_8, *_9 = NULL; + zval *from_param = NULL, *fields_param = NULL, *key = NULL, *value = NULL, *columns = NULL, *values = NULL, *sql = NULL, *query = NULL, *status = NULL, **_2, *_3 = NULL, *_4 = NULL, *_5, *_6, *_7, *_8, *_9 = NULL; zval *from = NULL; ZEPHIR_MM_GROW(); @@ -635,7 +645,6 @@ PHP_METHOD(Ice_Db_Driver_Pdo, insert) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -654,7 +663,7 @@ PHP_METHOD(Ice_Db_Driver_Pdo, insert) { array_init(columns); ZEPHIR_INIT_VAR(values); array_init(values); - zephir_is_iterable(fields, &_1, &_0, 0, 0, "ice/db/driver/pdo.zep", 265); + zephir_is_iterable(fields, &_1, &_0, 0, 0, "ice/db/driver/pdo.zep", 276); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) @@ -663,7 +672,7 @@ PHP_METHOD(Ice_Db_Driver_Pdo, insert) { ZEPHIR_GET_HVALUE(value, _2); ZEPHIR_INIT_LNVAR(_3); ZEPHIR_CONCAT_SVS(_3, "`", key, "`"); - zephir_array_append(&columns, _3, PH_SEPARATE, "ice/db/driver/pdo.zep", 261); + zephir_array_append(&columns, _3, PH_SEPARATE, "ice/db/driver/pdo.zep", 272); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SV(_4, ":", key); zephir_array_update_zval(&values, _4, &value, PH_COPY | PH_SEPARATE); @@ -676,14 +685,14 @@ PHP_METHOD(Ice_Db_Driver_Pdo, insert) { zephir_fast_join_str(_6, SL(", "), _7 TSRMLS_CC); ZEPHIR_INIT_VAR(sql); ZEPHIR_CONCAT_SVSVSVS(sql, "INSERT INTO `", from, "` (", _5, ") VALUES (", _6, ")"); - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&query, _8, "prepare", NULL, sql); + _8 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&query, _8, "prepare", NULL, 0, sql); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, query, "execute", NULL, values); + ZEPHIR_CALL_METHOD(&status, query, "execute", NULL, 0, values); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_9, query, "errorinfo", NULL); + ZEPHIR_CALL_METHOD(&_9, query, "errorinfo", NULL, 0); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_error"), _9 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("error"), _9 TSRMLS_CC); RETURN_CCTOR(status); } @@ -697,12 +706,11 @@ PHP_METHOD(Ice_Db_Driver_Pdo, insert) { */ PHP_METHOD(Ice_Db_Driver_Pdo, update) { - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_1; HashPosition _0; zval *fields = NULL; - zval *from_param = NULL, *filters = NULL, *fields_param = NULL, *key = NULL, *value = NULL, *columns, *values = NULL, *filtered = NULL, *sql, *query = NULL, *status = NULL, **_2, *_3 = NULL, *_4 = NULL, *_6, *_7, *_8, *_9, *_10, *_11 = NULL; + zval *from_param = NULL, *filters = NULL, *fields_param = NULL, *key = NULL, *value = NULL, *columns = NULL, *values = NULL, *filtered = NULL, *sql = NULL, *query = NULL, *status = NULL, **_2, *_3 = NULL, *_4 = NULL, *_5, *_6, *_7, *_8, *_9, *_10 = NULL; zval *from = NULL; ZEPHIR_MM_GROW(); @@ -712,7 +720,6 @@ PHP_METHOD(Ice_Db_Driver_Pdo, update) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -735,7 +742,7 @@ PHP_METHOD(Ice_Db_Driver_Pdo, update) { array_init(columns); ZEPHIR_INIT_VAR(values); array_init(values); - zephir_is_iterable(fields, &_1, &_0, 0, 0, "ice/db/driver/pdo.zep", 292); + zephir_is_iterable(fields, &_1, &_0, 0, 0, "ice/db/driver/pdo.zep", 303); for ( ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS ; zephir_hash_move_forward_ex(_1, &_0) @@ -747,27 +754,27 @@ PHP_METHOD(Ice_Db_Driver_Pdo, update) { zephir_array_update_zval(&values, _3, &value, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_LNVAR(_4); ZEPHIR_CONCAT_SVSV(_4, "`", key, "` = :", key); - zephir_array_append(&columns, _4, PH_SEPARATE, "ice/db/driver/pdo.zep", 289); + zephir_array_append(&columns, _4, PH_SEPARATE, "ice/db/driver/pdo.zep", 300); } - ZEPHIR_CALL_METHOD(&filtered, this_ptr, "where", &_5, filters, values); + ZEPHIR_CALL_METHOD(&filtered, this_ptr, "where", NULL, 77, filters, values); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_6); - zephir_fast_join_str(_6, SL(", "), columns TSRMLS_CC); - zephir_array_fetch_long(&_7, filtered, 0, PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 293 TSRMLS_CC); + ZEPHIR_INIT_VAR(_5); + zephir_fast_join_str(_5, SL(", "), columns TSRMLS_CC); + zephir_array_fetch_long(&_6, filtered, 0, PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 304 TSRMLS_CC); ZEPHIR_INIT_VAR(sql); - ZEPHIR_CONCAT_SVSVSV(sql, "UPDATE `", from, "` SET ", _6, " WHERE ", _7); - ZEPHIR_INIT_VAR(_8); - zephir_array_fetch_long(&_9, filtered, 1, PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 294 TSRMLS_CC); - zephir_fast_array_merge(_8, &(values), &(_9) TSRMLS_CC); - ZEPHIR_CPY_WRT(values, _8); - _10 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&query, _10, "prepare", NULL, sql); + ZEPHIR_CONCAT_SVSVSV(sql, "UPDATE `", from, "` SET ", _5, " WHERE ", _6); + ZEPHIR_INIT_VAR(_7); + zephir_array_fetch_long(&_8, filtered, 1, PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 305 TSRMLS_CC); + zephir_fast_array_merge(_7, &(values), &(_8) TSRMLS_CC); + ZEPHIR_CPY_WRT(values, _7); + _9 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&query, _9, "prepare", NULL, 0, sql); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, query, "execute", NULL, values); + ZEPHIR_CALL_METHOD(&status, query, "execute", NULL, 0, values); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_11, query, "errorinfo", NULL); + ZEPHIR_CALL_METHOD(&_10, query, "errorinfo", NULL, 0); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_error"), _11 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("error"), _10 TSRMLS_CC); RETURN_CCTOR(status); } @@ -780,9 +787,8 @@ PHP_METHOD(Ice_Db_Driver_Pdo, update) { */ PHP_METHOD(Ice_Db_Driver_Pdo, remove) { - zephir_nts_static zephir_fcall_cache_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *from_param = NULL, *filters = NULL, *filtered = NULL, *sql, *values, *query = NULL, *status = NULL, *_1, *_2, *_3 = NULL; + zval *from_param = NULL, *filters = NULL, *filtered = NULL, *sql = NULL, *values = NULL, *query = NULL, *status = NULL, *_0, *_1, *_2 = NULL; zval *from = NULL; ZEPHIR_MM_GROW(); @@ -792,7 +798,6 @@ PHP_METHOD(Ice_Db_Driver_Pdo, remove) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(from_param) == IS_STRING)) { zephir_get_strval(from, from_param); } else { @@ -805,21 +810,21 @@ PHP_METHOD(Ice_Db_Driver_Pdo, remove) { } - ZEPHIR_CALL_METHOD(&filtered, this_ptr, "where", &_0, filters); + ZEPHIR_CALL_METHOD(&filtered, this_ptr, "where", NULL, 77, filters); zephir_check_call_status(); - zephir_array_fetch_long(&_1, filtered, 0, PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 313 TSRMLS_CC); + zephir_array_fetch_long(&_0, filtered, 0, PH_NOISY | PH_READONLY, "ice/db/driver/pdo.zep", 324 TSRMLS_CC); ZEPHIR_INIT_VAR(sql); - ZEPHIR_CONCAT_SVSV(sql, "DELETE FROM `", from, "` WHERE ", _1); + ZEPHIR_CONCAT_SVSV(sql, "DELETE FROM `", from, "` WHERE ", _0); ZEPHIR_OBS_VAR(values); - zephir_array_fetch_long(&values, filtered, 1, PH_NOISY, "ice/db/driver/pdo.zep", 314 TSRMLS_CC); - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&query, _2, "prepare", NULL, sql); + zephir_array_fetch_long(&values, filtered, 1, PH_NOISY, "ice/db/driver/pdo.zep", 325 TSRMLS_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&query, _1, "prepare", NULL, 0, sql); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, query, "execute", NULL, values); + ZEPHIR_CALL_METHOD(&status, query, "execute", NULL, 0, values); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, query, "errorinfo", NULL); + ZEPHIR_CALL_METHOD(&_2, query, "errorinfo", NULL, 0); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_error"), _3 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("error"), _2 TSRMLS_CC); RETURN_CCTOR(status); } @@ -836,8 +841,8 @@ PHP_METHOD(Ice_Db_Driver_Pdo, getLastInsertId) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_client"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_1, _0, "lastinsertid", NULL); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("client"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_1, _0, "lastinsertid", NULL, 0); zephir_check_call_status(); RETURN_MM_LONG(zephir_get_intval(_1)); @@ -850,10 +855,10 @@ PHP_METHOD(Ice_Db_Driver_Pdo, getLastInsertId) { */ PHP_METHOD(Ice_Db_Driver_Pdo, getError) { - zval *error, *_0; + zval *error = NULL, *_0; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_error"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("error"), PH_NOISY_CC); zephir_array_isset_long_fetch(&error, _0, 0, 1 TSRMLS_CC); RETURN_CTORW(error); diff --git a/ext/ice/db/driver/pdo.zep.h b/ext/ice/db/driver/pdo.zep.h index 1afe2973..67040da3 100644 --- a/ext/ice/db/driver/pdo.zep.h +++ b/ext/ice/db/driver/pdo.zep.h @@ -7,6 +7,7 @@ PHP_METHOD(Ice_Db_Driver_Pdo, getId); PHP_METHOD(Ice_Db_Driver_Pdo, getType); PHP_METHOD(Ice_Db_Driver_Pdo, getClient); PHP_METHOD(Ice_Db_Driver_Pdo, __construct); +PHP_METHOD(Ice_Db_Driver_Pdo, getIdValue); PHP_METHOD(Ice_Db_Driver_Pdo, findOne); PHP_METHOD(Ice_Db_Driver_Pdo, find); PHP_METHOD(Ice_Db_Driver_Pdo, where); @@ -24,6 +25,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_db_driver_pdo___construct, 0, 0, 1) ZEND_ARG_ARRAY_INFO(0, options, 1) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_db_driver_pdo_getidvalue, 0, 0, 1) + ZEND_ARG_INFO(0, id) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_db_driver_pdo_findone, 0, 0, 1) ZEND_ARG_INFO(0, from) ZEND_ARG_INFO(0, filters) @@ -71,6 +76,7 @@ ZEPHIR_INIT_FUNCS(ice_db_driver_pdo_method_entry) { PHP_ME(Ice_Db_Driver_Pdo, getType, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Pdo, getClient, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Pdo, __construct, arginfo_ice_db_driver_pdo___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_ME(Ice_Db_Driver_Pdo, getIdValue, arginfo_ice_db_driver_pdo_getidvalue, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Pdo, findOne, arginfo_ice_db_driver_pdo_findone, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Pdo, find, arginfo_ice_db_driver_pdo_find, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Pdo, where, arginfo_ice_db_driver_pdo_where, ZEND_ACC_PRIVATE) @@ -80,5 +86,5 @@ ZEPHIR_INIT_FUNCS(ice_db_driver_pdo_method_entry) { PHP_ME(Ice_Db_Driver_Pdo, remove, arginfo_ice_db_driver_pdo_remove, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Pdo, getLastInsertId, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Db_Driver_Pdo, getError, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/di.zep.c b/ext/ice/di.zep.c index 683507df..92773656 100644 --- a/ext/ice/di.zep.c +++ b/ext/ice/di.zep.c @@ -13,9 +13,9 @@ #include "kernel/main.h" #include "kernel/memory.h" -#include "kernel/object.h" #include "kernel/fcall.h" #include "kernel/operators.h" +#include "kernel/object.h" #include "Zend/zend_closures.h" #include "kernel/array.h" #include "kernel/exception.h" @@ -24,28 +24,39 @@ #include "kernel/concat.h" #include "ext/spl/spl_exceptions.h" + +/** + * Component that implements Dependency Injection and a container for the services. + * + * @package Ice/Di + * @category Component + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Di) { ZEPHIR_REGISTER_CLASS_EX(Ice, Di, ice, di, ice_arr_ce, ice_di_method_entry, 0); - zend_declare_property_null(ice_di_ce, SL("_di"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); + zend_declare_property_null(ice_di_ce, SL("di"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); - zend_declare_property_null(ice_di_ce, SL("_hooks"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_di_ce, SL("hooks"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_di_ce->create_object = zephir_init_properties_Ice_Di; return SUCCESS; } /** - * Di constructor. + * Di constructor. Sets root path. * * @param array data Array of services */ PHP_METHOD(Ice_Di, __construct) { + zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; - zval *data_param = NULL, *_0; + zval *data_param = NULL, _0 = zval_used_for_init, *_1 = NULL, *_2 = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); @@ -59,12 +70,23 @@ PHP_METHOD(Ice_Di, __construct) { } - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_hooks"), _0 TSRMLS_CC); - ZEPHIR_CALL_PARENT(NULL, ice_di_ce, this_ptr, "__construct", &_1, data); + ZEPHIR_SINIT_VAR(_0); + ZVAL_STRING(&_0, "__ROOT__", 0); + ZEPHIR_CALL_FUNCTION(&_1, "defined", NULL, 78, &_0); zephir_check_call_status(); - zephir_update_static_property_ce(ice_di_ce, SL("_di"), &this_ptr TSRMLS_CC); + if (!(zephir_is_true(_1))) { + ZEPHIR_SINIT_NVAR(_0); + ZVAL_STRING(&_0, "../", 0); + ZEPHIR_CALL_FUNCTION(&_2, "realpath", NULL, 79, &_0); + zephir_check_call_status(); + ZEPHIR_SINIT_NVAR(_0); + ZVAL_STRING(&_0, "__ROOT__", 0); + ZEPHIR_CALL_FUNCTION(NULL, "define", NULL, 80, &_0, _2, ZEPHIR_GLOBAL(global_false)); + zephir_check_call_status(); + } + ZEPHIR_CALL_PARENT(NULL, ice_di_ce, this_ptr, "__construct", &_3, 6, data); + zephir_check_call_status(); + zephir_update_static_property_ce(ice_di_ce, SL("di"), &this_ptr TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -79,7 +101,7 @@ PHP_METHOD(Ice_Di, fetch) { zval *_0; - _0 = zephir_fetch_static_property_ce(ice_di_ce, SL("_di") TSRMLS_CC); + _0 = zephir_fetch_static_property_ce(ice_di_ce, SL("di") TSRMLS_CC); RETURN_CTORW(_0); } @@ -102,9 +124,9 @@ PHP_METHOD(Ice_Di, set) { zephir_get_strval(key, key_param); - ZEPHIR_CALL_METHOD(&service, this_ptr, "resolve", NULL, value); + ZEPHIR_CALL_METHOD(&service, this_ptr, "resolve", NULL, 0, value); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("_data"), key, service TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("data"), key, service TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -117,9 +139,8 @@ PHP_METHOD(Ice_Di, set) { */ PHP_METHOD(Ice_Di, resolve) { - zephir_nts_static zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *service = NULL, *params, *_0 = NULL, *_1, _2, *_3 = NULL; + zval *service = NULL, *params = NULL, *_0 = NULL, *_1, _2, *_3 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &service); @@ -147,13 +168,13 @@ PHP_METHOD(Ice_Di, resolve) { ZEPHIR_OBS_VAR(params); zephir_array_isset_long_fetch(¶ms, service, 1, 0 TSRMLS_CC); if (Z_TYPE_P(params) == IS_ARRAY) { + zephir_array_fetch_long(&_1, service, 0, PH_NOISY | PH_READONLY, "ice/di.zep", 83 TSRMLS_CC); ZEPHIR_INIT_NVAR(service); - zephir_array_fetch_long(&_1, service, 0, PH_NOISY | PH_READONLY, "ice/di.zep", 78 TSRMLS_CC); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(service, _1, params TSRMLS_CC); zephir_check_call_status(); } else { + zephir_array_fetch_long(&_1, service, 0, PH_NOISY | PH_READONLY, "ice/di.zep", 85 TSRMLS_CC); ZEPHIR_INIT_NVAR(service); - zephir_array_fetch_long(&_1, service, 0, PH_NOISY | PH_READONLY, "ice/di.zep", 80 TSRMLS_CC); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(service, _1 TSRMLS_CC); zephir_check_call_status(); } @@ -165,11 +186,11 @@ PHP_METHOD(Ice_Di, resolve) { object_init_ex(_0, ice_exception_ce); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "Service '%s' cannot be resolved", 0); - ZEPHIR_CALL_FUNCTION(&_3, "sprintf", &_4, &_2, service); + ZEPHIR_CALL_FUNCTION(&_3, "sprintf", NULL, 1, &_2, service); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _3); + ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 2, _3); zephir_check_call_status(); - zephir_throw_exception_debug(_0, "ice/di.zep", 87 TSRMLS_CC); + zephir_throw_exception_debug(_0, "ice/di.zep", 92 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } @@ -188,8 +209,7 @@ PHP_METHOD(Ice_Di, resolve) { PHP_METHOD(Ice_Di, errors) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_4 = NULL, *_6 = NULL; - zval *_0, *_3, *_5; + zval *_0, *_2, *_3; zval *className_param = NULL, *_1 = NULL; zval *className = NULL; @@ -205,28 +225,28 @@ PHP_METHOD(Ice_Di, errors) { ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, className); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "handler", 1); zephir_array_fast_append(_0, _1); - ZEPHIR_CALL_FUNCTION(NULL, "set_exception_handler", &_2, _0); + ZEPHIR_CALL_FUNCTION(NULL, "set_exception_handler", NULL, 81, _0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_3); - array_init_size(_3, 3); - zephir_array_fast_append(_3, className); + ZEPHIR_INIT_VAR(_2); + zephir_create_array(_2, 2, 0 TSRMLS_CC); + zephir_array_fast_append(_2, className); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "errorHandler", 1); - zephir_array_fast_append(_3, _1); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", &_4, _3); + zephir_array_fast_append(_2, _1); + ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 82, _2); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_5); - array_init_size(_5, 3); - zephir_array_fast_append(_5, className); + ZEPHIR_INIT_VAR(_3); + zephir_create_array(_3, 2, 0 TSRMLS_CC); + zephir_array_fast_append(_3, className); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "shutdownHandler", 1); - zephir_array_fast_append(_5, _1); - ZEPHIR_CALL_FUNCTION(NULL, "register_shutdown_function", &_6, _5); + zephir_array_fast_append(_3, _1); + ZEPHIR_CALL_FUNCTION(NULL, "register_shutdown_function", NULL, 83, _3); zephir_check_call_status(); RETURN_THIS(); @@ -257,17 +277,17 @@ PHP_METHOD(Ice_Di, hook) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_hooks"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("hooks"), PH_NOISY_CC); if (!(zephir_array_isset(_0, name))) { ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 2); + zephir_create_array(_1, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); array_init(_2); zephir_array_fast_append(_1, _2); - zephir_update_property_array(this_ptr, SL("_hooks"), name, _1 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("hooks"), name, _1 TSRMLS_CC); } if (zephir_is_callable(callback TSRMLS_CC) == 1) { - zephir_update_property_array_multi(this_ptr, SL("_hooks"), &callback TSRMLS_CC, SL("zla"), 2, name, priority); + zephir_update_property_array_multi(this_ptr, SL("hooks"), &callback TSRMLS_CC, SL("zla"), 3, name, priority); } ZEPHIR_MM_RESTORE(); @@ -293,35 +313,35 @@ PHP_METHOD(Ice_Di, applyHook) { zephir_get_strval(name, name_param); if (!args_param) { - ZEPHIR_INIT_VAR(args); - array_init(args); + ZEPHIR_INIT_VAR(args); + array_init(args); } else { zephir_get_arrval(args, args_param); } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_hooks"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("hooks"), PH_NOISY_CC); if (!(zephir_array_isset(_0, name))) { ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 2); + zephir_create_array(_1, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); array_init(_2); zephir_array_fast_append(_1, _2); - zephir_update_property_array(this_ptr, SL("_hooks"), name, _1 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("hooks"), name, _1 TSRMLS_CC); } - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_hooks"), PH_NOISY_CC); - zephir_array_fetch(&_4, _3, name, PH_NOISY | PH_READONLY, "ice/di.zep", 145 TSRMLS_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("hooks"), PH_NOISY_CC); + zephir_array_fetch(&_4, _3, name, PH_NOISY | PH_READONLY, "ice/di.zep", 150 TSRMLS_CC); if (!(ZEPHIR_IS_EMPTY(_4))) { - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_hooks"), PH_NOISY_CC); - zephir_array_fetch(&_6, _5, name, PH_NOISY | PH_READONLY, "ice/di.zep", 151 TSRMLS_CC); - zephir_is_iterable(_6, &_8, &_7, 0, 0, "ice/di.zep", 158); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("hooks"), PH_NOISY_CC); + zephir_array_fetch(&_6, _5, name, PH_NOISY | PH_READONLY, "ice/di.zep", 156 TSRMLS_CC); + zephir_is_iterable(_6, &_8, &_7, 0, 0, "ice/di.zep", 163); for ( ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS ; zephir_hash_move_forward_ex(_8, &_7) ) { ZEPHIR_GET_HVALUE(priority, _9); if (!(ZEPHIR_IS_EMPTY(priority))) { - zephir_is_iterable(priority, &_11, &_10, 0, 0, "ice/di.zep", 156); + zephir_is_iterable(priority, &_11, &_10, 0, 0, "ice/di.zep", 161); for ( ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS ; zephir_hash_move_forward_ex(_11, &_10) @@ -363,18 +383,18 @@ PHP_METHOD(Ice_Di, getHooks) { } - if (name && Z_STRLEN_P(name)) { + if (!(!name) && Z_STRLEN_P(name)) { ZEPHIR_INIT_VAR(_0); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_hooks"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("hooks"), PH_NOISY_CC); if (zephir_array_isset(_1, name)) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_hooks"), PH_NOISY_CC); - zephir_array_fetch(&_0, _2, name, PH_NOISY, "ice/di.zep", 172 TSRMLS_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("hooks"), PH_NOISY_CC); + zephir_array_fetch(&_0, _2, name, PH_NOISY, "ice/di.zep", 177 TSRMLS_CC); } else { ZVAL_NULL(_0); } RETURN_CCTOR(_0); } else { - RETURN_MM_MEMBER(this_ptr, "_hooks"); + RETURN_MM_MEMBER(this_ptr, "hooks"); } } @@ -408,32 +428,32 @@ PHP_METHOD(Ice_Di, clearHooks) { _0 = zephir_is_true(name); if (_0) { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_hooks"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("hooks"), PH_NOISY_CC); _0 = zephir_array_isset(_1, name); } if (_0) { ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 2); + zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); array_init(_3); zephir_array_fast_append(_2, _3); - zephir_update_property_array(this_ptr, SL("_hooks"), name, _2 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("hooks"), name, _2 TSRMLS_CC); } else { ZEPHIR_INIT_NVAR(_3); - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_hooks"), PH_NOISY_CC); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("hooks"), PH_NOISY_CC); zephir_array_keys(_3, _4 TSRMLS_CC); - zephir_is_iterable(_3, &_6, &_5, 0, 0, "ice/di.zep", 194); + zephir_is_iterable(_3, &_6, &_5, 0, 0, "ice/di.zep", 199); for ( ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS ; zephir_hash_move_forward_ex(_6, &_5) ) { ZEPHIR_GET_HVALUE(key, _7); ZEPHIR_INIT_NVAR(_2); - array_init_size(_2, 2); + zephir_create_array(_2, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_8); array_init(_8); zephir_array_fast_append(_2, _8); - zephir_update_property_array(this_ptr, SL("_hooks"), key, _2 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("hooks"), key, _2 TSRMLS_CC); } } ZEPHIR_MM_RESTORE(); @@ -449,11 +469,10 @@ PHP_METHOD(Ice_Di, clearHooks) { */ PHP_METHOD(Ice_Di, __call) { - zephir_fcall_cache_entry *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL, *_7 = NULL; + zephir_fcall_cache_entry *_2 = NULL, *_7 = NULL; zval *method_param = NULL, *arguments = NULL, *service = NULL, *value = NULL, _0 = zval_used_for_init, *_1 = NULL, *_3 = NULL, *_4, _5, *_6 = NULL; - zval *method = NULL, *_9; + zval *method = NULL, *_8; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &method_param, &arguments); @@ -462,7 +481,6 @@ PHP_METHOD(Ice_Di, __call) { 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 { @@ -479,14 +497,14 @@ PHP_METHOD(Ice_Di, __call) { ZVAL_LONG(&_0, 3); ZEPHIR_INIT_VAR(_1); zephir_substr(_1, method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CALL_FUNCTION(&service, "lcfirst", &_2, _1); + ZEPHIR_CALL_FUNCTION(&service, "lcfirst", &_2, 18, _1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, service); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "has", NULL, 0, service); zephir_check_call_status(); if (zephir_is_true(_3)) { ZEPHIR_OBS_VAR(value); zephir_array_isset_long_fetch(&value, arguments, 0, 0 TSRMLS_CC); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, service, value); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, service, value); zephir_check_call_status(); RETURN_MM(); } else { @@ -494,11 +512,11 @@ PHP_METHOD(Ice_Di, __call) { object_init_ex(_4, ice_exception_ce); ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "The '%s' service is required", 0); - ZEPHIR_CALL_FUNCTION(&_6, "sprintf", &_7, &_5, service); + ZEPHIR_CALL_FUNCTION(&_6, "sprintf", NULL, 1, &_5, service); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_8, _6); + ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_7, 2, _6); zephir_check_call_status(); - zephir_throw_exception_debug(_4, "ice/di.zep", 217 TSRMLS_CC); + zephir_throw_exception_debug(_4, "ice/di.zep", 222 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } @@ -510,21 +528,48 @@ PHP_METHOD(Ice_Di, __call) { ZVAL_LONG(&_0, 3); ZEPHIR_INIT_NVAR(_1); zephir_substr(_1, method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CALL_FUNCTION(&_3, "lcfirst", &_2, _1); + ZEPHIR_CALL_FUNCTION(&_3, "lcfirst", &_2, 18, _1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, _3, value); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, _3, value); zephir_check_call_status(); RETURN_MM_NULL(); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, ice_exception_ce); - ZEPHIR_INIT_VAR(_9); - ZEPHIR_CONCAT_SVS(_9, "Call to undefined method or service '", method, "'"); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_8, _9); + ZEPHIR_INIT_VAR(_8); + ZEPHIR_CONCAT_SVS(_8, "Call to undefined method or service '", method, "'"); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_7, 2, _8); zephir_check_call_status(); - zephir_throw_exception_debug(_1, "ice/di.zep", 229 TSRMLS_CC); + zephir_throw_exception_debug(_1, "ice/di.zep", 234 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } +static zend_object_value zephir_init_properties_Ice_Di(zend_class_entry *class_type TSRMLS_DC) { + + zval *_0, *_1 = NULL, *_2; + + ZEPHIR_MM_GROW(); + + { + zval *this_ptr = NULL; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("data"), _1 TSRMLS_CC); + } + _2 = zephir_fetch_nproperty_this(this_ptr, SL("hooks"), PH_NOISY_CC); + if (Z_TYPE_P(_2) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("hooks"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } + +} + diff --git a/ext/ice/di.zep.h b/ext/ice/di.zep.h index 2cb7f602..390760f6 100644 --- a/ext/ice/di.zep.h +++ b/ext/ice/di.zep.h @@ -13,6 +13,7 @@ PHP_METHOD(Ice_Di, applyHook); PHP_METHOD(Ice_Di, getHooks); PHP_METHOD(Ice_Di, clearHooks); PHP_METHOD(Ice_Di, __call); +static zend_object_value zephir_init_properties_Ice_Di(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_di___construct, 0, 0, 0) ZEND_ARG_ARRAY_INFO(0, data, 1) @@ -66,5 +67,5 @@ ZEPHIR_INIT_FUNCS(ice_di_method_entry) { PHP_ME(Ice_Di, getHooks, arginfo_ice_di_gethooks, ZEND_ACC_PUBLIC) PHP_ME(Ice_Di, clearHooks, arginfo_ice_di_clearhooks, ZEND_ACC_PUBLIC) PHP_ME(Ice_Di, __call, arginfo_ice_di___call, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/di/access.zep.c b/ext/ice/di/access.zep.c index 9f9e6989..74bdfaa7 100644 --- a/ext/ice/di/access.zep.c +++ b/ext/ice/di/access.zep.c @@ -32,7 +32,7 @@ ZEPHIR_INIT_CLASS(Ice_Di_Access) { ZEPHIR_REGISTER_CLASS(Ice\\Di, Access, ice, di_access, ice_di_access_method_entry, 0); - zend_declare_property_null(ice_di_access_ce, SL("_di"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_di_access_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -46,7 +46,7 @@ ZEPHIR_INIT_CLASS(Ice_Di_Access) { PHP_METHOD(Ice_Di_Access, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL; zval *di = NULL, *_0 = NULL; ZEPHIR_MM_GROW(); @@ -58,11 +58,11 @@ PHP_METHOD(Ice_Di_Access, __construct) { if (!(zephir_is_true(di))) { - 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); } else { - zephir_update_property_this(this_ptr, SL("_di"), di TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("di"), di TSRMLS_CC); } ZEPHIR_MM_RESTORE(); @@ -74,7 +74,7 @@ PHP_METHOD(Ice_Di_Access, __construct) { PHP_METHOD(Ice_Di_Access, __get) { int ZEPHIR_LAST_CALL_STATUS; - zval *property_param = NULL, *di, *service = NULL, *_0 = NULL; + zval *property_param = NULL, *di = NULL, *service = NULL, *_0, *_1 = NULL; zval *property = NULL; ZEPHIR_MM_GROW(); @@ -83,16 +83,16 @@ PHP_METHOD(Ice_Di_Access, __get) { zephir_get_strval(property, property_param); - ZEPHIR_OBS_VAR(di); - zephir_read_property_this(&di, this_ptr, SL("_di"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(di, _0); if (ZEPHIR_IS_STRING(property, "di")) { - zephir_update_property_zval(this_ptr, SL("di"), di TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("di"), di TSRMLS_CC); RETURN_CCTOR(di); } - ZEPHIR_CALL_METHOD(&_0, di, "has", NULL, property); + ZEPHIR_CALL_METHOD(&_1, di, "has", NULL, 0, property); zephir_check_call_status(); - if (zephir_is_true(_0)) { - ZEPHIR_CALL_METHOD(&service, di, "get", NULL, property); + if (zephir_is_true(_1)) { + ZEPHIR_CALL_METHOD(&service, di, "get", NULL, 0, property); zephir_check_call_status(); zephir_update_property_zval_zval(this_ptr, property, service TSRMLS_CC); RETURN_CCTOR(service); diff --git a/ext/ice/di/access.zep.h b/ext/ice/di/access.zep.h index ef1fb851..37ce094e 100644 --- a/ext/ice/di/access.zep.h +++ b/ext/ice/di/access.zep.h @@ -17,5 +17,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_di_access_method_entry) { PHP_ME(Ice_Di_Access, __construct, arginfo_ice_di_access___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Di_Access, __get, arginfo_ice_di_access___get, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/dispatcher.zep.c b/ext/ice/dispatcher.zep.c index e957c71a..f4cb976c 100644 --- a/ext/ice/dispatcher.zep.c +++ b/ext/ice/dispatcher.zep.c @@ -16,55 +16,69 @@ #include "kernel/memory.h" #include "kernel/fcall.h" #include "kernel/array.h" -#include "kernel/concat.h" #include "kernel/operators.h" +#include "kernel/concat.h" #include "kernel/exception.h" #include "kernel/file.h" #include "kernel/string.h" #include "ext/spl/spl_exceptions.h" + +/** + * The base class for Ice\Mvc\Dispatcher and Ice\CLI\Dispatcher. + * For the response from router and in the specified module, create instance of handler with action and params. + * + * @package Ice/Dispatcher + * @category Component + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Dispatcher) { ZEPHIR_REGISTER_CLASS(Ice, Dispatcher, ice, dispatcher, ice_dispatcher_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(ice_dispatcher_ce, SL("_di"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_defaultNamespace"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("defaultNamespace"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_activeHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("activeHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_lastHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("lastHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_finished"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_long(ice_dispatcher_ce, SL("loops"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_bool(ice_dispatcher_ce, SL("_forwarded"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("finished"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_bool(ice_dispatcher_ce, SL("_silent"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(ice_dispatcher_ce, SL("forwarded"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_modules"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(ice_dispatcher_ce, SL("silent"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_module"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("modules"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_namespace"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("module"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_handler"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("namespace"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_action"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("handler"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_params"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("action"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_returnedValue"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("params"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_dispatcher_ce, SL("_handlerSuffix"), "Handler", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("returnedValue"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_dispatcher_ce, SL("_actionSuffix"), "Action", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_dispatcher_ce, SL("handlerSuffix"), "Handler", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_previousModule"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_dispatcher_ce, SL("actionSuffix"), "Action", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_previousHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("previousModule"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dispatcher_ce, SL("_previousAction"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("previousHandler"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dispatcher_ce, SL("previousAction"), ZEND_ACC_PROTECTED TSRMLS_CC); + + ice_dispatcher_ce->create_object = zephir_init_properties_Ice_Dispatcher; zend_declare_class_constant_long(ice_dispatcher_ce, SL("DISPATCH_CYCLIC"), 1 TSRMLS_CC); zend_declare_class_constant_long(ice_dispatcher_ce, SL("HANDLER_NOT_FOUND"), 2 TSRMLS_CC); @@ -80,7 +94,7 @@ ZEPHIR_INIT_CLASS(Ice_Dispatcher) { PHP_METHOD(Ice_Dispatcher, getDefaultNamespace) { - RETURN_MEMBER(this_ptr, "_defaultNamespace"); + RETURN_MEMBER(this_ptr, "defaultNamespace"); } @@ -92,35 +106,42 @@ PHP_METHOD(Ice_Dispatcher, setDefaultNamespace) { - zephir_update_property_this(this_ptr, SL("_defaultNamespace"), defaultNamespace TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultNamespace"), defaultNamespace TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getActiveHandler) { - RETURN_MEMBER(this_ptr, "_activeHandler"); + RETURN_MEMBER(this_ptr, "activeHandler"); } PHP_METHOD(Ice_Dispatcher, getLastHandler) { - RETURN_MEMBER(this_ptr, "_lastHandler"); + RETURN_MEMBER(this_ptr, "lastHandler"); + +} + +PHP_METHOD(Ice_Dispatcher, getLoops) { + + + RETURN_MEMBER(this_ptr, "loops"); } PHP_METHOD(Ice_Dispatcher, getFinished) { - RETURN_MEMBER(this_ptr, "_finished"); + RETURN_MEMBER(this_ptr, "finished"); } PHP_METHOD(Ice_Dispatcher, getForwarded) { - RETURN_MEMBER(this_ptr, "_forwarded"); + RETURN_MEMBER(this_ptr, "forwarded"); } @@ -132,14 +153,14 @@ PHP_METHOD(Ice_Dispatcher, setSilent) { - zephir_update_property_this(this_ptr, SL("_silent"), silent TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("silent"), silent TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getModules) { - RETURN_MEMBER(this_ptr, "_modules"); + RETURN_MEMBER(this_ptr, "modules"); } @@ -151,14 +172,14 @@ PHP_METHOD(Ice_Dispatcher, setModules) { - zephir_update_property_this(this_ptr, SL("_modules"), modules TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("modules"), modules TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getModule) { - RETURN_MEMBER(this_ptr, "_module"); + RETURN_MEMBER(this_ptr, "module"); } @@ -170,14 +191,14 @@ PHP_METHOD(Ice_Dispatcher, setModule) { - zephir_update_property_this(this_ptr, SL("_module"), module TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("module"), module TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getNamespace) { - RETURN_MEMBER(this_ptr, "_namespace"); + RETURN_MEMBER(this_ptr, "namespace"); } @@ -189,14 +210,14 @@ PHP_METHOD(Ice_Dispatcher, setNamespace) { - zephir_update_property_this(this_ptr, SL("_namespace"), namespace TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("namespace"), namespace TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getHandler) { - RETURN_MEMBER(this_ptr, "_handler"); + RETURN_MEMBER(this_ptr, "handler"); } @@ -208,14 +229,14 @@ PHP_METHOD(Ice_Dispatcher, setHandler) { - zephir_update_property_this(this_ptr, SL("_handler"), handler TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("handler"), handler TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getAction) { - RETURN_MEMBER(this_ptr, "_action"); + RETURN_MEMBER(this_ptr, "action"); } @@ -227,14 +248,14 @@ PHP_METHOD(Ice_Dispatcher, setAction) { - zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("action"), action TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getParams) { - RETURN_MEMBER(this_ptr, "_params"); + RETURN_MEMBER(this_ptr, "params"); } @@ -246,14 +267,14 @@ PHP_METHOD(Ice_Dispatcher, setParams) { - zephir_update_property_this(this_ptr, SL("_params"), params TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("params"), params TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getReturnedValue) { - RETURN_MEMBER(this_ptr, "_returnedValue"); + RETURN_MEMBER(this_ptr, "returnedValue"); } @@ -265,14 +286,14 @@ PHP_METHOD(Ice_Dispatcher, setReturnedValue) { - zephir_update_property_this(this_ptr, SL("_returnedValue"), returnedValue TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("returnedValue"), returnedValue TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getHandlerSuffix) { - RETURN_MEMBER(this_ptr, "_handlerSuffix"); + RETURN_MEMBER(this_ptr, "handlerSuffix"); } @@ -284,14 +305,14 @@ PHP_METHOD(Ice_Dispatcher, setHandlerSuffix) { - zephir_update_property_this(this_ptr, SL("_handlerSuffix"), handlerSuffix TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("handlerSuffix"), handlerSuffix TSRMLS_CC); } PHP_METHOD(Ice_Dispatcher, getActionSuffix) { - RETURN_MEMBER(this_ptr, "_actionSuffix"); + RETURN_MEMBER(this_ptr, "actionSuffix"); } @@ -303,7 +324,7 @@ PHP_METHOD(Ice_Dispatcher, setActionSuffix) { - zephir_update_property_this(this_ptr, SL("_actionSuffix"), actionSuffix TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("actionSuffix"), actionSuffix TSRMLS_CC); } @@ -313,24 +334,40 @@ PHP_METHOD(Ice_Dispatcher, setActionSuffix) { PHP_METHOD(Ice_Dispatcher, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL; - zval *_0, *_1, *_2 = NULL; + zephir_fcall_cache_entry *_1 = NULL; + zval *_0 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_params"), _0 TSRMLS_CC); - ZEPHIR_INIT_VAR(_1); - array_init(_1); - zephir_update_property_this(this_ptr, SL("_modules"), _1 TSRMLS_CC); - ZEPHIR_CALL_CE_STATIC(&_2, ice_di_ce, "fetch", &_3); + ZEPHIR_CALL_CE_STATIC(&_0, ice_di_ce, "fetch", &_1, 8); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_di"), _2 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("di"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } +/** + * Whether or not an param exists by key. + * + * @param string key The param key + * @return boolean + */ +PHP_METHOD(Ice_Dispatcher, hasParam) { + + zval *key_param = NULL, *_0; + zval *key = NULL; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &key_param); + + zephir_get_strval(key, key_param); + + + _0 = zephir_fetch_nproperty_this(this_ptr, SL("params"), PH_NOISY_CC); + RETURN_MM_BOOL(zephir_array_isset(_0, key)); + +} + /** * Set a param by its name or numeric index. * @@ -345,34 +382,102 @@ PHP_METHOD(Ice_Dispatcher, setParam) { - zephir_update_property_array(this_ptr, SL("_params"), param, value TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("params"), param, value TSRMLS_CC); } /** - * 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 */ PHP_METHOD(Ice_Dispatcher, getParam) { - zval *param, *defaultValue = NULL, *value, *_0; + zephir_fcall_cache_entry *_2 = NULL; + int ZEPHIR_LAST_CALL_STATUS; + zend_bool allowEmpty, _7, _8; + zval *key_param = NULL, *filters = NULL, *defaultValue = NULL, *allowEmpty_param = NULL, *params = NULL, *value = NULL, *filter = NULL, *_0, *_1 = NULL, *_3, *_4, *_5, *_6 = NULL; + zval *key = NULL; - zephir_fetch_params(0, 1, 1, ¶m, &defaultValue); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 4, &key_param, &filters, &defaultValue, &allowEmpty_param); + if (!key_param) { + ZEPHIR_INIT_VAR(key); + ZVAL_EMPTY_STRING(key); + } else { + zephir_get_strval(key, key_param); + } + if (!filters) { + filters = ZEPHIR_GLOBAL(global_null); + } if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } + if (!allowEmpty_param) { + allowEmpty = 0; + } else { + allowEmpty = zephir_get_boolval(allowEmpty_param); + } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC); - if (zephir_array_isset_fetch(&value, _0, param, 1 TSRMLS_CC)) { - RETURN_CTORW(value); + ZEPHIR_INIT_VAR(params); + object_init_ex(params, ice_arr_ce); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("params"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, params, "__construct", NULL, 6, _0); + zephir_check_call_status(); + if (!(!(!key) && Z_STRLEN_P(key))) { + RETURN_CCTOR(params); + } else { + ZEPHIR_CALL_METHOD(&value, params, "get", NULL, 27, key, defaultValue); + zephir_check_call_status(); + if (zephir_is_true(filters)) { + ZEPHIR_CALL_CE_STATIC(&_1, ice_di_ce, "fetch", &_2, 8); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(_3); + ZVAL_STRING(_3, "filter", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_4); + ZVAL_NULL(_4); + ZEPHIR_INIT_VAR(_5); + ZVAL_BOOL(_5, 1); + ZEPHIR_CALL_METHOD(&filter, _1, "get", NULL, 27, _3, _4, _5); + zephir_check_temp_parameter(_3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6, filter, "sanitize", NULL, 0, value, filters); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(value, _6); + } + _7 = ZEPHIR_IS_STRING_IDENTICAL(value, ""); + if (!(_7)) { + _7 = Z_TYPE_P(value) == IS_NULL; + } + _8 = _7; + if (_8) { + _8 = allowEmpty == 0; + } + if (_8) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + RETURN_CCTOR(value); } - RETVAL_ZVAL(defaultValue, 1, 0); - return; + ZEPHIR_MM_RESTORE(); } @@ -386,8 +491,8 @@ PHP_METHOD(Ice_Dispatcher, getActiveMethod) { zval *_0, *_1; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_action"), PH_NOISY_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_actionSuffix"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("action"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("actionSuffix"), PH_NOISY_CC); ZEPHIR_CONCAT_VV(return_value, _0, _1); return; @@ -400,88 +505,95 @@ PHP_METHOD(Ice_Dispatcher, getActiveMethod) { */ PHP_METHOD(Ice_Dispatcher, dispatch) { - zend_class_entry *_24; - zval *_11 = NULL, *_29 = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_7 = NULL, *_10 = NULL, *_13 = NULL, *_17 = NULL, *_18 = NULL, *_19 = NULL, *_20 = NULL, *_21 = NULL, *_25 = NULL, *_26 = NULL, *_27 = NULL, *_28 = NULL; - int i = 0, ZEPHIR_LAST_CALL_STATUS; - zend_bool fresh; - zval *handler = NULL, *response = NULL, *handlerName = NULL, *actionName = NULL, *params = NULL, *handlerSuffix, *actionSuffix, *handlerClass = NULL, *actionMethod = NULL, *module = NULL, *modules = NULL, *moduleNamespace = NULL, *path = NULL, *moduleClass = NULL, *loader = NULL, *_0, *_1 = NULL, *_2, *_3, *_5 = NULL, *_8 = NULL, *_9 = NULL, *_12 = NULL, *_14 = NULL, *_15, *_16 = NULL, *_22 = NULL, *_23 = NULL; + zend_class_entry *_25; + zval *_12 = NULL, *_30 = NULL; + zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_8 = NULL, *_11 = NULL, *_14 = NULL, *_18 = NULL, *_19 = NULL, *_20 = NULL, *_21 = NULL, *_22 = NULL, *_26 = NULL, *_27 = NULL, *_28 = NULL, *_29 = NULL; + int ZEPHIR_LAST_CALL_STATUS; + zend_bool fresh = 0; + zval *handler = NULL, *response = NULL, *handlerName = NULL, *actionName = NULL, *params = NULL, *handlerSuffix = NULL, *handlerClass = NULL, *actionMethod = NULL, *module = NULL, *modules = NULL, *moduleNamespace = NULL, *path = NULL, *moduleClass = NULL, *loader = NULL, *_0, *_1 = NULL, *_2, *_3, *_4, *_6 = NULL, *_9 = NULL, *_10 = NULL, *_13 = NULL, *_15 = NULL, *_16, *_17 = NULL, *_23 = NULL, *_24 = NULL; ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "response", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&response, _0, "get", NULL, _1); + ZEPHIR_CALL_METHOD(&response, _0, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); fresh = 1; ZEPHIR_INIT_VAR(handler); ZVAL_NULL(handler); - ZEPHIR_OBS_VAR(handlerSuffix); - zephir_read_property_this(&handlerSuffix, this_ptr, SL("_handlerSuffix"), PH_NOISY_CC); - ZEPHIR_OBS_VAR(actionSuffix); - zephir_read_property_this(&actionSuffix, this_ptr, SL("_actionSuffix"), PH_NOISY_CC); - zephir_update_property_this(this_ptr, SL("_finished"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("handlerSuffix"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(handlerSuffix, _2); + if (0) { + zephir_update_property_this(this_ptr, SL("finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); + } else { + zephir_update_property_this(this_ptr, SL("finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); + } while (1) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("finished"), PH_NOISY_CC); if (!(!(zephir_is_true(_2)))) { break; } - i++; - if (i == 16) { - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_silent"), PH_NOISY_CC); - if (zephir_is_true(_3)) { + RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("loops") TSRMLS_CC)); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("loops"), PH_NOISY_CC); + if (ZEPHIR_GT_LONG(_3, 16)) { + _4 = zephir_fetch_nproperty_this(this_ptr, SL("silent"), PH_NOISY_CC); + if (zephir_is_true(_4)) { ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 508); - ZEPHIR_CALL_METHOD(NULL, response, "setstatus", &_4, _1); + ZEPHIR_CALL_METHOD(NULL, response, "setstatus", &_5, 0, _1); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); ZVAL_LONG(_1, 508); - ZEPHIR_CALL_METHOD(&_5, response, "getmessage", &_6, _1); + ZEPHIR_CALL_METHOD(&_6, response, "getmessage", &_7, 0, _1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, response, "setbody", &_7, _5); + ZEPHIR_CALL_METHOD(NULL, response, "setbody", &_8, 0, _6); zephir_check_call_status(); RETURN_CCTOR(response); } ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, ice_exception_ce); - ZEPHIR_INIT_NVAR(_8); - ZVAL_STRING(_8, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_9); - ZVAL_LONG(_9, 1); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_10, _8, _9); - zephir_check_temp_parameter(_8); + ZVAL_STRING(_9, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_10); + ZVAL_LONG(_10, 1); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_11, 2, _9, _10); + zephir_check_temp_parameter(_9); zephir_check_call_status(); - zephir_throw_exception_debug(_1, "ice/dispatcher.zep", 125 TSRMLS_CC); + zephir_throw_exception_debug(_1, "ice/dispatcher.zep", 163 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } - zephir_update_property_this(this_ptr, SL("_finished"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); - ZEPHIR_OBS_NVAR(modules); - zephir_read_property_this(&modules, this_ptr, SL("_modules"), PH_NOISY_CC); + if (1) { + zephir_update_property_this(this_ptr, SL("finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); + } else { + zephir_update_property_this(this_ptr, SL("finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); + } + _4 = zephir_fetch_nproperty_this(this_ptr, SL("modules"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(modules, _4); if (zephir_is_true(modules)) { ZEPHIR_OBS_NVAR(module); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_module"), PH_NOISY_CC); - if (!(zephir_array_isset_fetch(&module, modules, _3, 0 TSRMLS_CC))) { + _4 = zephir_fetch_nproperty_this(this_ptr, SL("module"), PH_NOISY_CC); + if (!(zephir_array_isset_fetch(&module, modules, _4, 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, ice_exception_ce); - ZEPHIR_INIT_NVAR(_11); - array_init_size(_11, 3); - ZEPHIR_INIT_NVAR(_8); - ZVAL_STRING(_8, "Module '%s' isn't registered in the application container", 1); - zephir_array_fast_append(_11, _8); - ZEPHIR_OBS_NVAR(_12); - zephir_read_property_this(&_12, this_ptr, SL("_module"), PH_NOISY_CC); - zephir_array_fast_append(_11, _12); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_10, _11); + ZEPHIR_INIT_NVAR(_12); + zephir_create_array(_12, 2, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_9); + ZVAL_STRING(_9, "Module '%s' isn't registered in the application container", 1); + zephir_array_fast_append(_12, _9); + ZEPHIR_OBS_NVAR(_13); + zephir_read_property_this(&_13, this_ptr, SL("module"), PH_NOISY_CC); + zephir_array_fast_append(_12, _13); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_11, 2, _12); zephir_check_call_status(); - zephir_throw_exception_debug(_1, "ice/dispatcher.zep", 133 TSRMLS_CC); + zephir_throw_exception_debug(_1, "ice/dispatcher.zep", 171 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (Z_TYPE_P(module) != IS_ARRAY) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Module definition must be an array", "ice/dispatcher.zep", 137); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Module definition must be an array", "ice/dispatcher.zep", 175); return; } ZEPHIR_OBS_NVAR(path); @@ -489,15 +601,15 @@ PHP_METHOD(Ice_Dispatcher, dispatch) { if (!((zephir_file_exists(path TSRMLS_CC) == SUCCESS))) { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, ice_exception_ce); - ZEPHIR_INIT_NVAR(_11); - array_init_size(_11, 3); - ZEPHIR_INIT_NVAR(_8); - ZVAL_STRING(_8, "Module definition path '%s' doesn't exist", 1); - zephir_array_fast_append(_11, _8); - zephir_array_fast_append(_11, path); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_10, _11); + ZEPHIR_INIT_NVAR(_12); + zephir_create_array(_12, 2, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_9); + ZVAL_STRING(_9, "Module definition path '%s' doesn't exist", 1); + zephir_array_fast_append(_12, _9); + zephir_array_fast_append(_12, path); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_11, 2, _12); zephir_check_call_status(); - zephir_throw_exception_debug(_1, "ice/dispatcher.zep", 142 TSRMLS_CC); + zephir_throw_exception_debug(_1, "ice/dispatcher.zep", 180 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } @@ -514,174 +626,174 @@ PHP_METHOD(Ice_Dispatcher, dispatch) { ZEPHIR_INIT_NVAR(loader); object_init_ex(loader, ice_loader_ce); if (zephir_has_constructor(loader TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, loader, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, loader, "__construct", NULL, 0); zephir_check_call_status(); } - zephir_update_property_this(this_ptr, SL("_namespace"), moduleNamespace TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_5, loader, "addnamespace", &_13, moduleNamespace, path); + zephir_update_property_this(this_ptr, SL("namespace"), moduleNamespace TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_6, loader, "addnamespace", &_14, 28, moduleNamespace, path); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _5, "register", NULL); + ZEPHIR_CALL_METHOD(NULL, _6, "register", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_1); - ZEPHIR_INIT_LNVAR(_14); - ZEPHIR_CONCAT_VSV(_14, moduleNamespace, "\\", moduleClass); - ZEPHIR_INIT_NVAR(_11); - array_init_size(_11, 2); - ZEPHIR_OBS_NVAR(_12); - zephir_read_property_this(&_12, this_ptr, SL("_di"), PH_NOISY_CC); - zephir_array_fast_append(_11, _12); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(_1, _14, _11 TSRMLS_CC); + ZEPHIR_INIT_LNVAR(_15); + ZEPHIR_CONCAT_VSV(_15, moduleNamespace, "\\", moduleClass); + ZEPHIR_INIT_NVAR(_12); + zephir_create_array(_12, 1, 0 TSRMLS_CC); + ZEPHIR_OBS_NVAR(_13); + zephir_read_property_this(&_13, this_ptr, SL("di"), PH_NOISY_CC); + zephir_array_fast_append(_12, _13); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(_1, _15, _12 TSRMLS_CC); zephir_check_call_status(); ZEPHIR_CPY_WRT(module, _1); - ZEPHIR_CALL_METHOD(NULL, module, "registerautoloaders", NULL); + ZEPHIR_CALL_METHOD(NULL, module, "registerautoloaders", NULL, 0); zephir_check_call_status(); - _15 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, module, "registerservices", NULL, _15); + _16 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, module, "registerservices", NULL, 0, _16); zephir_check_call_status(); } - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); - if (!(zephir_is_true(_3))) { - _15 = zephir_fetch_nproperty_this(this_ptr, SL("_namespace"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_16, this_ptr, "gethandlersuffix", &_17); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("defaultNamespace"), PH_NOISY_CC); + if (!(zephir_is_true(_4))) { + _16 = zephir_fetch_nproperty_this(this_ptr, SL("namespace"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_17, this_ptr, "gethandlersuffix", &_18, 0); zephir_check_call_status(); - ZEPHIR_INIT_LNVAR(_14); - ZEPHIR_CONCAT_VSV(_14, _15, "\\", _16); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdefaultnamespace", &_18, _14); + ZEPHIR_INIT_LNVAR(_15); + ZEPHIR_CONCAT_VSV(_15, _16, "\\", _17); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdefaultnamespace", &_19, 0, _15); zephir_check_call_status(); } ZEPHIR_OBS_NVAR(handlerName); - zephir_read_property_this(&handlerName, this_ptr, SL("_handler"), PH_NOISY_CC); + zephir_read_property_this(&handlerName, this_ptr, SL("handler"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(actionName); - zephir_read_property_this(&actionName, this_ptr, SL("_action"), PH_NOISY_CC); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC); + zephir_read_property_this(&actionName, this_ptr, SL("action"), PH_NOISY_CC); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("defaultNamespace"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); - ZEPHIR_INIT_NVAR(_8); - zephir_camelize(_8, handlerName); - zephir_ucfirst(_1, _8); + ZEPHIR_INIT_NVAR(_9); + zephir_camelize(_9, handlerName); + zephir_ucfirst(_1, _9); ZEPHIR_INIT_NVAR(handlerClass); - ZEPHIR_CONCAT_VSVV(handlerClass, _3, "\\", _1, handlerSuffix); + ZEPHIR_CONCAT_VSVV(handlerClass, _4, "\\", _1, handlerSuffix); if (!(zephir_class_exists(handlerClass, 1 TSRMLS_CC))) { - _15 = zephir_fetch_nproperty_this(this_ptr, SL("_silent"), PH_NOISY_CC); - if (zephir_is_true(_15)) { - ZEPHIR_INIT_NVAR(_9); - ZVAL_LONG(_9, 404); - ZEPHIR_CALL_METHOD(NULL, response, "setstatus", &_19, _9); + _16 = zephir_fetch_nproperty_this(this_ptr, SL("silent"), PH_NOISY_CC); + if (zephir_is_true(_16)) { + ZEPHIR_INIT_NVAR(_10); + ZVAL_LONG(_10, 404); + ZEPHIR_CALL_METHOD(NULL, response, "setstatus", &_20, 0, _10); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_9); - ZVAL_LONG(_9, 404); - ZEPHIR_CALL_METHOD(&_16, response, "getmessage", &_20, _9); + ZEPHIR_INIT_NVAR(_10); + ZVAL_LONG(_10, 404); + ZEPHIR_CALL_METHOD(&_17, response, "getmessage", &_21, 0, _10); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, response, "setbody", &_21, _16); + ZEPHIR_CALL_METHOD(NULL, response, "setbody", &_22, 0, _17); zephir_check_call_status(); RETURN_CCTOR(response); } - ZEPHIR_INIT_NVAR(_9); - object_init_ex(_9, ice_exception_ce); - ZEPHIR_INIT_NVAR(_11); - array_init_size(_11, 3); - ZEPHIR_INIT_NVAR(_22); - ZVAL_STRING(_22, "%s handler class cannot be loaded", 1); - zephir_array_fast_append(_11, _22); - zephir_array_fast_append(_11, handlerClass); - ZEPHIR_INIT_NVAR(_22); - ZVAL_LONG(_22, 2); - ZEPHIR_CALL_METHOD(NULL, _9, "__construct", &_10, _11, _22); + ZEPHIR_INIT_NVAR(_10); + object_init_ex(_10, ice_exception_ce); + ZEPHIR_INIT_NVAR(_12); + zephir_create_array(_12, 2, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_23); + ZVAL_STRING(_23, "%s handler class cannot be loaded", 1); + zephir_array_fast_append(_12, _23); + zephir_array_fast_append(_12, handlerClass); + ZEPHIR_INIT_NVAR(_23); + ZVAL_LONG(_23, 2); + ZEPHIR_CALL_METHOD(NULL, _10, "__construct", &_11, 2, _12, _23); zephir_check_call_status(); - zephir_throw_exception_debug(_9, "ice/dispatcher.zep", 181 TSRMLS_CC); + zephir_throw_exception_debug(_10, "ice/dispatcher.zep", 219 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } - zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("lastHandler"), handler TSRMLS_CC); ZEPHIR_INIT_NVAR(handler); - zephir_fetch_safe_class(_23, handlerClass); - _24 = zend_fetch_class(Z_STRVAL_P(_23), Z_STRLEN_P(_23), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); - object_init_ex(handler, _24); + zephir_fetch_safe_class(_24, handlerClass); + _25 = zend_fetch_class(Z_STRVAL_P(_24), Z_STRLEN_P(_24), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); + object_init_ex(handler, _25); if (zephir_has_constructor(handler TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, handler, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, handler, "__construct", NULL, 0); zephir_check_call_status(); } - zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC); - ZEPHIR_CALL_METHOD(&actionMethod, this_ptr, "getactivemethod", &_25); + zephir_update_property_this(this_ptr, SL("activeHandler"), handler TSRMLS_CC); + ZEPHIR_CALL_METHOD(&actionMethod, this_ptr, "getactivemethod", &_26, 0); zephir_check_call_status(); if ((zephir_method_exists_ex(handler, SS("before") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, handler, "before", NULL); + ZEPHIR_CALL_METHOD(NULL, handler, "before", NULL, 0); zephir_check_call_status(); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); - if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { + _4 = zephir_fetch_nproperty_this(this_ptr, SL("finished"), PH_NOISY_CC); + if (ZEPHIR_IS_FALSE_IDENTICAL(_4)) { continue; } } if (fresh == 1) { if ((zephir_method_exists_ex(handler, SS("initialize") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL); + ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL, 0); zephir_check_call_status(); } } if (!((zephir_method_exists(handler, actionMethod TSRMLS_CC) == SUCCESS))) { - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_silent"), PH_NOISY_CC); - if (zephir_is_true(_3)) { - ZEPHIR_INIT_NVAR(_8); - ZVAL_LONG(_8, 404); - ZEPHIR_CALL_METHOD(NULL, response, "setstatus", &_26, _8); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("silent"), PH_NOISY_CC); + if (zephir_is_true(_4)) { + ZEPHIR_INIT_NVAR(_9); + ZVAL_LONG(_9, 404); + ZEPHIR_CALL_METHOD(NULL, response, "setstatus", &_27, 0, _9); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_8); - ZVAL_LONG(_8, 404); - ZEPHIR_CALL_METHOD(&_5, response, "getmessage", &_27, _8); + ZEPHIR_INIT_NVAR(_9); + ZVAL_LONG(_9, 404); + ZEPHIR_CALL_METHOD(&_6, response, "getmessage", &_28, 0, _9); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, response, "setbody", &_28, _5); + ZEPHIR_CALL_METHOD(NULL, response, "setbody", &_29, 0, _6); zephir_check_call_status(); RETURN_CCTOR(response); } - ZEPHIR_INIT_NVAR(_8); - object_init_ex(_8, ice_exception_ce); - ZEPHIR_INIT_NVAR(_11); - array_init_size(_11, 4); ZEPHIR_INIT_NVAR(_9); - ZVAL_STRING(_9, "Action '%s' was not found on handler '%s'", 1); - zephir_array_fast_append(_11, _9); - zephir_array_fast_append(_11, actionName); - zephir_array_fast_append(_11, handlerName); - ZEPHIR_INIT_NVAR(_9); - ZVAL_LONG(_9, 3); - ZEPHIR_CALL_METHOD(NULL, _8, "__construct", &_10, _11, _9); + object_init_ex(_9, ice_exception_ce); + ZEPHIR_INIT_NVAR(_12); + zephir_create_array(_12, 3, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_10); + ZVAL_STRING(_10, "Action '%s' was not found on handler '%s'", 1); + zephir_array_fast_append(_12, _10); + zephir_array_fast_append(_12, actionName); + zephir_array_fast_append(_12, handlerName); + ZEPHIR_INIT_NVAR(_10); + ZVAL_LONG(_10, 3); + ZEPHIR_CALL_METHOD(NULL, _9, "__construct", &_11, 2, _12, _10); zephir_check_call_status(); - zephir_throw_exception_debug(_8, "ice/dispatcher.zep", 214 TSRMLS_CC); + zephir_throw_exception_debug(_9, "ice/dispatcher.zep", 251 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } - ZEPHIR_OBS_NVAR(params); - zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("params"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(params, _4); if (Z_TYPE_P(params) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(_8); - object_init_ex(_8, ice_exception_ce); ZEPHIR_INIT_NVAR(_9); - ZVAL_STRING(_9, "Action parameters must be an array", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_INIT_NVAR(_22); - ZVAL_LONG(_22, 4); - ZEPHIR_CALL_METHOD(NULL, _8, "__construct", &_10, _9, _22); - zephir_check_temp_parameter(_9); + object_init_ex(_9, ice_exception_ce); + ZEPHIR_INIT_NVAR(_10); + ZVAL_STRING(_10, "Action parameters must be an array", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_23); + ZVAL_LONG(_23, 4); + ZEPHIR_CALL_METHOD(NULL, _9, "__construct", &_11, 2, _10, _23); + zephir_check_temp_parameter(_10); zephir_check_call_status(); - zephir_throw_exception_debug(_8, "ice/dispatcher.zep", 219 TSRMLS_CC); + zephir_throw_exception_debug(_9, "ice/dispatcher.zep", 256 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } - ZEPHIR_INIT_NVAR(_8); - ZEPHIR_INIT_NVAR(_29); - array_init_size(_29, 3); - zephir_array_fast_append(_29, handler); - zephir_array_fast_append(_29, actionMethod); - ZEPHIR_CALL_USER_FUNC_ARRAY(_8, _29, params); + ZEPHIR_INIT_NVAR(_9); + ZEPHIR_INIT_NVAR(_30); + zephir_create_array(_30, 2, 0 TSRMLS_CC); + zephir_array_fast_append(_30, handler); + zephir_array_fast_append(_30, actionMethod); + ZEPHIR_CALL_USER_FUNC_ARRAY(_9, _30, params); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_returnedValue"), _8 TSRMLS_CC); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); - if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { + zephir_update_property_this(this_ptr, SL("returnedValue"), _9 TSRMLS_CC); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("finished"), PH_NOISY_CC); + if (ZEPHIR_IS_FALSE_IDENTICAL(_4)) { continue; } if ((zephir_method_exists_ex(handler, SS("after") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, handler, "after", NULL); + ZEPHIR_CALL_METHOD(NULL, handler, "after", NULL, 0); zephir_check_call_status(); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); - if (ZEPHIR_IS_FALSE_IDENTICAL(_3)) { + _4 = zephir_fetch_nproperty_this(this_ptr, SL("finished"), PH_NOISY_CC); + if (ZEPHIR_IS_FALSE_IDENTICAL(_4)) { continue; } } @@ -695,38 +807,90 @@ PHP_METHOD(Ice_Dispatcher, dispatch) { * Forwards the execution flow to another module/controller/action. * * @param array forward + * @param boolean force */ PHP_METHOD(Ice_Dispatcher, forward) { - zval *forward_param = NULL, *module, *handler, *action, *params, *_0; + int ZEPHIR_LAST_CALL_STATUS; + zend_bool force; + zval *forward_param = NULL, *force_param = NULL, *module = NULL, *handler = NULL, *action = NULL, *params = NULL, *_0; zval *forward = NULL; - zephir_fetch_params(0, 1, 0, &forward_param); + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 1, &forward_param, &force_param); forward = forward_param; + if (!force_param) { + force = 0; + } else { + force = zephir_get_boolval(force_param); + } - - if (zephir_array_isset_string_fetch(&module, forward, SS("module"), 1 TSRMLS_CC)) { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_module"), PH_NOISY_CC); - zephir_update_property_this(this_ptr, SL("_previousModule"), _0 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_module"), module TSRMLS_CC); + ZEPHIR_OBS_VAR(module); + if (zephir_array_isset_string_fetch(&module, forward, SS("module"), 0 TSRMLS_CC)) { + _0 = zephir_fetch_nproperty_this(this_ptr, SL("module"), PH_NOISY_CC); + zephir_update_property_this(this_ptr, SL("previousModule"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("module"), module TSRMLS_CC); + } + ZEPHIR_OBS_VAR(handler); + if (zephir_array_isset_string_fetch(&handler, forward, SS("handler"), 0 TSRMLS_CC)) { + _0 = zephir_fetch_nproperty_this(this_ptr, SL("handler"), PH_NOISY_CC); + zephir_update_property_this(this_ptr, SL("previousHandler"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("handler"), handler TSRMLS_CC); + } + ZEPHIR_OBS_VAR(action); + if (zephir_array_isset_string_fetch(&action, forward, SS("action"), 0 TSRMLS_CC)) { + _0 = zephir_fetch_nproperty_this(this_ptr, SL("action"), PH_NOISY_CC); + zephir_update_property_this(this_ptr, SL("previousAction"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("action"), action TSRMLS_CC); + } + ZEPHIR_OBS_VAR(params); + if (zephir_array_isset_string_fetch(¶ms, forward, SS("params"), 0 TSRMLS_CC)) { + zephir_update_property_this(this_ptr, SL("params"), params TSRMLS_CC); + } + if (0) { + zephir_update_property_this(this_ptr, SL("finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); + } else { + zephir_update_property_this(this_ptr, SL("finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } - if (zephir_array_isset_string_fetch(&handler, forward, SS("handler"), 1 TSRMLS_CC)) { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_handler"), PH_NOISY_CC); - zephir_update_property_this(this_ptr, SL("_previousHandler"), _0 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_handler"), handler TSRMLS_CC); + if (1) { + zephir_update_property_this(this_ptr, SL("forwarded"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); + } else { + zephir_update_property_this(this_ptr, SL("forwarded"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } - if (zephir_array_isset_string_fetch(&action, forward, SS("action"), 1 TSRMLS_CC)) { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_action"), PH_NOISY_CC); - zephir_update_property_this(this_ptr, SL("_previousAction"), _0 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC); + if (force) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "dispatch", NULL, 0); + zephir_check_call_status(); } - if (zephir_array_isset_string_fetch(¶ms, forward, SS("params"), 1 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_params"), params TSRMLS_CC); + ZEPHIR_MM_RESTORE(); + +} + +static zend_object_value zephir_init_properties_Ice_Dispatcher(zend_class_entry *class_type TSRMLS_DC) { + + zval *_0, *_1 = NULL, *_2; + + ZEPHIR_MM_GROW(); + + { + zval *this_ptr = NULL; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("params"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("params"), _1 TSRMLS_CC); + } + _2 = zephir_fetch_nproperty_this(this_ptr, SL("modules"), PH_NOISY_CC); + if (Z_TYPE_P(_2) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("modules"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); } - zephir_update_property_this(this_ptr, SL("_finished"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_forwarded"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } diff --git a/ext/ice/dispatcher.zep.h b/ext/ice/dispatcher.zep.h index f2dd26ed..b86bac1a 100644 --- a/ext/ice/dispatcher.zep.h +++ b/ext/ice/dispatcher.zep.h @@ -7,6 +7,7 @@ PHP_METHOD(Ice_Dispatcher, getDefaultNamespace); PHP_METHOD(Ice_Dispatcher, setDefaultNamespace); PHP_METHOD(Ice_Dispatcher, getActiveHandler); PHP_METHOD(Ice_Dispatcher, getLastHandler); +PHP_METHOD(Ice_Dispatcher, getLoops); PHP_METHOD(Ice_Dispatcher, getFinished); PHP_METHOD(Ice_Dispatcher, getForwarded); PHP_METHOD(Ice_Dispatcher, setSilent); @@ -29,11 +30,13 @@ PHP_METHOD(Ice_Dispatcher, setHandlerSuffix); PHP_METHOD(Ice_Dispatcher, getActionSuffix); PHP_METHOD(Ice_Dispatcher, setActionSuffix); PHP_METHOD(Ice_Dispatcher, __construct); +PHP_METHOD(Ice_Dispatcher, hasParam); PHP_METHOD(Ice_Dispatcher, setParam); PHP_METHOD(Ice_Dispatcher, getParam); PHP_METHOD(Ice_Dispatcher, getActiveMethod); PHP_METHOD(Ice_Dispatcher, dispatch); PHP_METHOD(Ice_Dispatcher, forward); +static zend_object_value zephir_init_properties_Ice_Dispatcher(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_dispatcher_setdefaultnamespace, 0, 0, 1) ZEND_ARG_INFO(0, defaultNamespace) @@ -79,18 +82,25 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_dispatcher_setactionsuffix, 0, 0, 1) ZEND_ARG_INFO(0, actionSuffix) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_dispatcher_hasparam, 0, 0, 1) + ZEND_ARG_INFO(0, key) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_dispatcher_setparam, 0, 0, 2) ZEND_ARG_INFO(0, param) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_dispatcher_getparam, 0, 0, 1) - ZEND_ARG_INFO(0, param) +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_dispatcher_getparam, 0, 0, 0) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, filters) ZEND_ARG_INFO(0, defaultValue) + ZEND_ARG_INFO(0, allowEmpty) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_dispatcher_forward, 0, 0, 1) ZEND_ARG_ARRAY_INFO(0, forward, 0) + ZEND_ARG_INFO(0, force) ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_dispatcher_method_entry) { @@ -98,6 +108,7 @@ ZEPHIR_INIT_FUNCS(ice_dispatcher_method_entry) { PHP_ME(Ice_Dispatcher, setDefaultNamespace, arginfo_ice_dispatcher_setdefaultnamespace, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, getActiveHandler, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, getLastHandler, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Dispatcher, getLoops, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, getFinished, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, getForwarded, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, setSilent, arginfo_ice_dispatcher_setsilent, ZEND_ACC_PUBLIC) @@ -120,10 +131,11 @@ ZEPHIR_INIT_FUNCS(ice_dispatcher_method_entry) { PHP_ME(Ice_Dispatcher, getActionSuffix, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, setActionSuffix, arginfo_ice_dispatcher_setactionsuffix, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_ME(Ice_Dispatcher, hasParam, arginfo_ice_dispatcher_hasparam, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, setParam, arginfo_ice_dispatcher_setparam, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, getParam, arginfo_ice_dispatcher_getparam, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, getActiveMethod, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, dispatch, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dispatcher, forward, arginfo_ice_dispatcher_forward, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/dump.zep.c b/ext/ice/dump.zep.c index e7bf7caa..60b6be2d 100644 --- a/ext/ice/dump.zep.c +++ b/ext/ice/dump.zep.c @@ -23,16 +23,44 @@ #include "kernel/hash.h" #include "kernel/string.h" + +/** + * Dumps information about a variable(s) + * + * @package Ice/Dump + * @category Helper + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + * + *

+ *  $foo = 123;
+ *  echo (new \Ice\Dump())->variable($foo, "foo");
+ * 
+ * + *

+ *  $foo = "string";
+ *  $bar = ["key" => "value"];
+ *  $baz = new stdClass();
+ *  echo (new \Ice\Dump())->vars($foo, $bar, $baz);
+ * 
+ * + * Sleet usage: + *

+ *  {{ dump('str', 1, 2.5, true, null, ['key': 'value']) }}
+ * 
+ */ ZEPHIR_INIT_CLASS(Ice_Dump) { ZEPHIR_REGISTER_CLASS(Ice, Dump, ice, dump, ice_dump_method_entry, 0); - zend_declare_property_bool(ice_dump_ce, SL("_detailed"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(ice_dump_ce, SL("detailed"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dump_ce, SL("_methods"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dump_ce, SL("methods"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_dump_ce, SL("_styles"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_dump_ce, SL("styles"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_dump_ce->create_object = zephir_init_properties_Ice_Dump; return SUCCESS; } @@ -40,7 +68,7 @@ ZEPHIR_INIT_CLASS(Ice_Dump) { PHP_METHOD(Ice_Dump, getDetailed) { - RETURN_MEMBER(this_ptr, "_detailed"); + RETURN_MEMBER(this_ptr, "detailed"); } @@ -52,7 +80,7 @@ PHP_METHOD(Ice_Dump, setDetailed) { - zephir_update_property_this(this_ptr, SL("_detailed"), detailed TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("detailed"), detailed TSRMLS_CC); } @@ -66,7 +94,7 @@ PHP_METHOD(Ice_Dump, __construct) { int ZEPHIR_LAST_CALL_STATUS; zval *styles = NULL; - zval *detailed_param = NULL, *styles_param = NULL, *_0, *_1; + zval *detailed_param = NULL, *styles_param = NULL; zend_bool detailed; ZEPHIR_MM_GROW(); @@ -85,19 +113,17 @@ PHP_METHOD(Ice_Dump, __construct) { } - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_styles"), _0 TSRMLS_CC); - ZEPHIR_INIT_VAR(_1); - array_init(_1); - zephir_update_property_this(this_ptr, SL("_methods"), _1 TSRMLS_CC); if (1 != 1) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "The styles must be an array", "ice/dump.zep", 46); return; } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstyles", NULL, styles); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstyles", NULL, 0, styles); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_detailed"), detailed ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC); + if (detailed) { + zephir_update_property_this(this_ptr, SL("detailed"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); + } else { + zephir_update_property_this(this_ptr, SL("detailed"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); + } ZEPHIR_MM_RESTORE(); } @@ -115,7 +141,6 @@ PHP_METHOD(Ice_Dump, __construct) { */ PHP_METHOD(Ice_Dump, all) { - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL; zval *_1, *_2 = NULL; zval *_0; int ZEPHIR_LAST_CALL_STATUS; @@ -123,12 +148,12 @@ PHP_METHOD(Ice_Dump, all) { ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, this_ptr); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "vars", 1); zephir_array_fast_append(_0, _1); - ZEPHIR_CALL_FUNCTION(&_2, "func_get_args", &_3); + ZEPHIR_CALL_FUNCTION(&_2, "func_get_args", NULL, 84); zephir_check_call_status(); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _0, _2); zephir_check_call_status(); @@ -144,7 +169,7 @@ PHP_METHOD(Ice_Dump, all) { */ PHP_METHOD(Ice_Dump, getStyle) { - zval *type_param = NULL, *style, *_0; + zval *type_param = NULL, *style = NULL, *_0; zval *type = NULL; ZEPHIR_MM_GROW(); @@ -154,7 +179,6 @@ PHP_METHOD(Ice_Dump, getStyle) { 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 { @@ -163,7 +187,7 @@ PHP_METHOD(Ice_Dump, getStyle) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_styles"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("styles"), PH_NOISY_CC); if (zephir_array_isset_fetch(&style, _0, type, 1 TSRMLS_CC)) { RETURN_CTOR(style); } else { @@ -181,7 +205,7 @@ PHP_METHOD(Ice_Dump, getStyle) { */ PHP_METHOD(Ice_Dump, setStyles) { - zval *styles_param = NULL, *defaultStyles, *_0; + zval *styles_param = NULL, *defaultStyles = NULL, *_0; zval *styles = NULL; ZEPHIR_MM_GROW(); @@ -200,7 +224,7 @@ PHP_METHOD(Ice_Dump, setStyles) { return; } ZEPHIR_INIT_VAR(defaultStyles); - array_init_size(defaultStyles, 14); + zephir_create_array(defaultStyles, 11, 0 TSRMLS_CC); add_assoc_stringl_ex(defaultStyles, SS("pre"), SL("background-color:#f9f9f9; font-size:11px; padding:10px; border:1px solid #ccc; text-align:left; color:#333"), 1); add_assoc_stringl_ex(defaultStyles, SS("arr"), SL("color:red"), 1); add_assoc_stringl_ex(defaultStyles, SS("bool"), SL("color:green"), 1); @@ -214,8 +238,8 @@ PHP_METHOD(Ice_Dump, setStyles) { add_assoc_stringl_ex(defaultStyles, SS("str"), SL("color:teal"), 1); ZEPHIR_INIT_VAR(_0); zephir_fast_array_merge(_0, &(defaultStyles), &(styles) TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_styles"), _0 TSRMLS_CC); - RETURN_MM_MEMBER(this_ptr, "_styles"); + zephir_update_property_this(this_ptr, SL("styles"), _0 TSRMLS_CC); + RETURN_MM_MEMBER(this_ptr, "styles"); } @@ -247,7 +271,7 @@ PHP_METHOD(Ice_Dump, one) { } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "variable", NULL, variable, name); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "variable", NULL, 0, variable, name); zephir_check_call_status(); RETURN_MM(); @@ -264,13 +288,12 @@ PHP_METHOD(Ice_Dump, one) { PHP_METHOD(Ice_Dump, output) { zend_bool _14, _15, _16; - zephir_fcall_cache_entry *_12 = NULL, *_19 = NULL; - HashTable *_6, *_25, *_37; - HashPosition _5, _24, _36; - zephir_nts_static zephir_fcall_cache_entry *_4 = NULL, *_9 = NULL, *_21 = NULL, *_23 = NULL, *_29 = NULL, *_30 = NULL, *_31 = NULL, *_33 = NULL, *_34 = NULL, *_42 = NULL, *_44 = NULL, *_45 = NULL; + HashTable *_7, *_24, *_34; + HashPosition _6, _23, _33; + zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL, *_10 = NULL, *_19 = NULL, *_21 = NULL, *_28 = NULL, *_29 = NULL, *_31 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *_0 = NULL, *_10 = NULL, *_40 = NULL; - zval *variable, *name = NULL, *tab = NULL, *key = NULL, *value = NULL, *output = NULL, *space, *type = NULL, *attr = NULL, *_1 = NULL, *_2 = NULL, _3 = zval_used_for_init, **_7, *_8 = NULL, *_11 = NULL, *_13 = NULL, *_17 = NULL, *_18 = NULL, *_20 = NULL, *className, *_22, **_26, *_27 = NULL, *_28 = NULL, *_32, *_35, **_38, *_39, *_41 = NULL, _43; + zval *_0 = NULL, *_11 = NULL, *_37 = NULL; + zval *variable, *name = NULL, *tab = NULL, *key = NULL, *value = NULL, *output = NULL, *space = NULL, *type = NULL, *attr = NULL, *_1 = NULL, *_2 = NULL, _4 = zval_used_for_init, **_8, *_9 = NULL, *_12 = NULL, *_13 = NULL, *_17 = NULL, *_18 = NULL, *_20 = NULL, *className = NULL, *_22, **_25, *_26 = NULL, *_27 = NULL, *_30, *_32, **_35, *_36, *_38 = NULL, _39; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &variable, &name, &tab); @@ -294,43 +317,43 @@ PHP_METHOD(Ice_Dump, output) { } if (Z_TYPE_P(variable) == IS_ARRAY) { ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "arr", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", NULL, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_0, SS(":count"), zephir_fast_count_int(variable TSRMLS_CC)); - ZEPHIR_SINIT_VAR(_3); - ZVAL_STRING(&_3, "array (:count) (\n", 0); - ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_4, &_3, _0); + ZEPHIR_SINIT_VAR(_4); + ZVAL_STRING(&_4, "array (:count) (\n", 0); + ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_5, 85, &_4, _0); zephir_check_call_status(); zephir_concat_self(&output, _1 TSRMLS_CC); - zephir_is_iterable(variable, &_6, &_5, 0, 0, "ice/dump.zep", 165); + zephir_is_iterable(variable, &_7, &_6, 0, 0, "ice/dump.zep", 166); for ( - ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS - ; zephir_hash_move_forward_ex(_6, &_5) + ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS + ; zephir_hash_move_forward_ex(_7, &_6) ) { - ZEPHIR_GET_HMKEY(key, _6, _5); - ZEPHIR_GET_HVALUE(value, _7); - ZEPHIR_CALL_FUNCTION(&_8, "str_repeat", &_9, space, tab); + ZEPHIR_GET_HMKEY(key, _7, _6); + ZEPHIR_GET_HVALUE(value, _8); + ZEPHIR_CALL_FUNCTION(&_9, "str_repeat", &_10, 68, space, tab); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_10); - array_init_size(_10, 3); + ZEPHIR_INIT_NVAR(_11); + zephir_create_array(_11, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "arr", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_11, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_12, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_array_update_string(&_10, SL(":style"), &_11, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10, SL(":key"), &key, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "[:key] => ", 0); - ZEPHIR_CALL_FUNCTION(&_11, "strtr", &_4, &_3, _10); + zephir_array_update_string(&_11, SL(":style"), &_12, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_11, SL(":key"), &key, PH_COPY | PH_SEPARATE); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "[:key] => ", 0); + ZEPHIR_CALL_FUNCTION(&_12, "strtr", &_5, 85, &_4, _11); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_13); - ZEPHIR_CONCAT_VV(_13, _8, _11); + ZEPHIR_CONCAT_VV(_13, _9, _12); zephir_concat_self(&output, _13 TSRMLS_CC); _14 = ZEPHIR_IS_LONG(tab, 1); if (_14) { @@ -351,7 +374,7 @@ PHP_METHOD(Ice_Dump, output) { ZVAL_STRING(_2, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_18); ZVAL_LONG(_18, (zephir_get_numberval(tab) + 1)); - ZEPHIR_CALL_METHOD(&_17, this_ptr, "output", &_19, value, _2, _18); + ZEPHIR_CALL_METHOD(&_17, this_ptr, "output", &_19, 86, value, _2, _18); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_20); @@ -359,345 +382,349 @@ PHP_METHOD(Ice_Dump, output) { zephir_concat_self(&output, _20 TSRMLS_CC); } } - ZEPHIR_SINIT_NVAR(_3); - ZVAL_LONG(&_3, (zephir_get_numberval(tab) - 1)); - ZEPHIR_CALL_FUNCTION(&_8, "str_repeat", &_9, space, &_3); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_LONG(&_4, (zephir_get_numberval(tab) - 1)); + ZEPHIR_CALL_FUNCTION(&_9, "str_repeat", &_10, 68, space, &_4); zephir_check_call_status(); - ZEPHIR_CONCAT_VVS(return_value, output, _8, ")"); + ZEPHIR_CONCAT_VVS(return_value, output, _9, ")"); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_OBJECT) { ZEPHIR_INIT_VAR(className); zephir_get_class(className, variable, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "obj", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL(":class"), &className, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "object :class", 0); - ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_4, &_3, _0); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "object :class", 0); + ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_5, 85, &_4, _0); zephir_check_call_status(); zephir_concat_self(&output, _1 TSRMLS_CC); - ZEPHIR_CALL_FUNCTION(&_11, "get_parent_class", &_21, variable); + ZEPHIR_CALL_FUNCTION(&_12, "get_parent_class", &_21, 87, variable); zephir_check_call_status(); - if (zephir_is_true(_11)) { - ZEPHIR_INIT_NVAR(_10); - array_init_size(_10, 3); + if (zephir_is_true(_12)) { + ZEPHIR_INIT_NVAR(_11); + zephir_create_array(_11, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "obj", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_17, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_17, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_array_update_string(&_10, SL(":style"), &_17, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_FUNCTION(&_17, "get_parent_class", &_21, variable); + zephir_array_update_string(&_11, SL(":style"), &_17, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_FUNCTION(&_17, "get_parent_class", &_21, 87, variable); zephir_check_call_status(); - zephir_array_update_string(&_10, SL(":parent"), &_17, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, " extends :parent", 0); - ZEPHIR_CALL_FUNCTION(&_17, "strtr", &_4, &_3, _10); + zephir_array_update_string(&_11, SL(":parent"), &_17, PH_COPY | PH_SEPARATE); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, " extends :parent", 0); + ZEPHIR_CALL_FUNCTION(&_17, "strtr", &_5, 85, &_4, _11); zephir_check_call_status(); zephir_concat_self(&output, _17 TSRMLS_CC); } zephir_concat_self_str(&output, SL(" (\n") TSRMLS_CC); - _22 = zephir_fetch_nproperty_this(this_ptr, SL("_detailed"), PH_NOISY_CC); - if (!(zephir_is_true(_22))) { - ZEPHIR_CALL_FUNCTION(&_8, "get_object_vars", &_23, variable); + _22 = zephir_fetch_nproperty_this(this_ptr, SL("detailed"), PH_NOISY_CC); + if (zephir_instance_of_ev(variable, ice_di_ce TSRMLS_CC)) { + ZEPHIR_CALL_FUNCTION(&_9, "str_repeat", &_10, 68, space, tab); zephir_check_call_status(); - zephir_is_iterable(_8, &_25, &_24, 0, 0, "ice/dump.zep", 184); + ZEPHIR_INIT_LNVAR(_13); + ZEPHIR_CONCAT_VS(_13, _9, "[skipped]\n"); + zephir_concat_self(&output, _13 TSRMLS_CC); + } else if (!(zephir_is_true(_22))) { + ZEPHIR_CALL_FUNCTION(&_9, "get_object_vars", NULL, 88, variable); + zephir_check_call_status(); + zephir_is_iterable(_9, &_24, &_23, 0, 0, "ice/dump.zep", 189); for ( - ; zephir_hash_get_current_data_ex(_25, (void**) &_26, &_24) == SUCCESS - ; zephir_hash_move_forward_ex(_25, &_24) + ; zephir_hash_get_current_data_ex(_24, (void**) &_25, &_23) == SUCCESS + ; zephir_hash_move_forward_ex(_24, &_23) ) { - ZEPHIR_GET_HMKEY(key, _25, _24); - ZEPHIR_GET_HVALUE(value, _26); - ZEPHIR_CALL_FUNCTION(&_11, "str_repeat", &_9, space, tab); + ZEPHIR_GET_HMKEY(key, _24, _23); + ZEPHIR_GET_HVALUE(value, _25); + ZEPHIR_CALL_FUNCTION(&_12, "str_repeat", &_10, 68, space, tab); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_10); - array_init_size(_10, 4); + ZEPHIR_INIT_NVAR(_11); + zephir_create_array(_11, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "obj", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_27, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_26, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_array_update_string(&_10, SL(":style"), &_27, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10, SL(":key"), &key, PH_COPY | PH_SEPARATE); - add_assoc_stringl_ex(_10, SS(":type"), SL("public"), 1); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "->:key (:type) = ", 0); - ZEPHIR_CALL_FUNCTION(&_27, "strtr", &_4, &_3, _10); + zephir_array_update_string(&_11, SL(":style"), &_26, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_11, SL(":key"), &key, PH_COPY | PH_SEPARATE); + add_assoc_stringl_ex(_11, SS(":type"), SL("public"), 1); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "->:key (:type) = ", 0); + ZEPHIR_CALL_FUNCTION(&_26, "strtr", &_5, 85, &_4, _11); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_13); - ZEPHIR_CONCAT_VV(_13, _11, _27); + ZEPHIR_CONCAT_VV(_13, _12, _26); zephir_concat_self(&output, _13 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_18); ZVAL_LONG(_18, (zephir_get_numberval(tab) + 1)); - ZEPHIR_CALL_METHOD(&_28, this_ptr, "output", &_19, value, _2, _18); + ZEPHIR_CALL_METHOD(&_27, this_ptr, "output", &_19, 86, value, _2, _18); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_20); - ZEPHIR_CONCAT_VS(_20, _28, "\n"); + ZEPHIR_CONCAT_VS(_20, _27, "\n"); zephir_concat_self(&output, _20 TSRMLS_CC); } } else { do { - Z_SET_ISREF_P(variable); - ZEPHIR_CALL_FUNCTION(&attr, "each", &_29, variable); - Z_UNSET_ISREF_P(variable); + ZEPHIR_MAKE_REF(variable); + ZEPHIR_CALL_FUNCTION(&attr, "each", &_28, 89, variable); + ZEPHIR_UNREF(variable); zephir_check_call_status(); if (!(zephir_is_true(attr))) { continue; } ZEPHIR_OBS_NVAR(key); - zephir_array_fetch_string(&key, attr, SL("key"), PH_NOISY, "ice/dump.zep", 191 TSRMLS_CC); + zephir_array_fetch_string(&key, attr, SL("key"), PH_NOISY, "ice/dump.zep", 197 TSRMLS_CC); ZEPHIR_OBS_NVAR(value); - zephir_array_fetch_string(&value, attr, SL("value"), PH_NOISY, "ice/dump.zep", 192 TSRMLS_CC); + zephir_array_fetch_string(&value, attr, SL("value"), PH_NOISY, "ice/dump.zep", 198 TSRMLS_CC); if (!(zephir_is_true(key))) { continue; } ZEPHIR_INIT_NVAR(_2); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "\\x00", 0); - ZEPHIR_CALL_FUNCTION(&_8, "ord", &_30, &_3); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_11, "chr", &_31, _8); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_LONG(&_4, 0); + ZEPHIR_CALL_FUNCTION(&_9, "chr", &_29, 67, &_4); zephir_check_call_status(); - zephir_fast_explode(_2, _11, key, LONG_MAX TSRMLS_CC); + zephir_fast_explode(_2, _9, key, LONG_MAX TSRMLS_CC); ZEPHIR_CPY_WRT(key, _2); ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "public", 1); if (zephir_array_isset_long(key, 1)) { ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "private", 1); - zephir_array_fetch_long(&_32, key, 1, PH_NOISY | PH_READONLY, "ice/dump.zep", 203 TSRMLS_CC); - if (ZEPHIR_IS_STRING(_32, "*")) { + zephir_array_fetch_long(&_30, key, 1, PH_NOISY | PH_READONLY, "ice/dump.zep", 211 TSRMLS_CC); + if (ZEPHIR_IS_STRING(_30, "*")) { ZEPHIR_INIT_NVAR(type); ZVAL_STRING(type, "protected", 1); } } - ZEPHIR_CALL_FUNCTION(&_17, "str_repeat", &_9, space, tab); + ZEPHIR_CALL_FUNCTION(&_12, "str_repeat", &_10, 68, space, tab); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_10); - array_init_size(_10, 4); + ZEPHIR_INIT_NVAR(_11); + zephir_create_array(_11, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "obj", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_27, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_17, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_array_update_string(&_10, SL(":style"), &_27, PH_COPY | PH_SEPARATE); - Z_SET_ISREF_P(key); - ZEPHIR_CALL_FUNCTION(&_27, "end", &_33, key); - Z_UNSET_ISREF_P(key); + zephir_array_update_string(&_11, SL(":style"), &_17, PH_COPY | PH_SEPARATE); + ZEPHIR_MAKE_REF(key); + ZEPHIR_CALL_FUNCTION(&_17, "end", &_31, 90, key); + ZEPHIR_UNREF(key); zephir_check_call_status(); - zephir_array_update_string(&_10, SL(":key"), &_27, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10, SL(":type"), &type, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "->:key (:type) = ", 0); - ZEPHIR_CALL_FUNCTION(&_27, "strtr", &_4, &_3, _10); + zephir_array_update_string(&_11, SL(":key"), &_17, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_11, SL(":type"), &type, PH_COPY | PH_SEPARATE); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "->:key (:type) = ", 0); + ZEPHIR_CALL_FUNCTION(&_17, "strtr", &_5, 85, &_4, _11); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_13); - ZEPHIR_CONCAT_VV(_13, _17, _27); + ZEPHIR_CONCAT_VV(_13, _12, _17); zephir_concat_self(&output, _13 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_18); ZVAL_LONG(_18, (zephir_get_numberval(tab) + 1)); - ZEPHIR_CALL_METHOD(&_28, this_ptr, "output", &_19, value, _2, _18); + ZEPHIR_CALL_METHOD(&_26, this_ptr, "output", &_19, 86, value, _2, _18); zephir_check_temp_parameter(_2); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_20); - ZEPHIR_CONCAT_VS(_20, _28, "\n"); + ZEPHIR_CONCAT_VS(_20, _26, "\n"); zephir_concat_self(&output, _20 TSRMLS_CC); } while (zephir_is_true(attr)); } - ZEPHIR_CALL_FUNCTION(&attr, "get_class_methods", &_34, variable); + ZEPHIR_CALL_FUNCTION(&attr, "get_class_methods", NULL, 91, variable); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_8, "str_repeat", &_9, space, tab); + ZEPHIR_CALL_FUNCTION(&_9, "str_repeat", &_10, 68, space, tab); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_10); - array_init_size(_10, 4); + ZEPHIR_INIT_NVAR(_11); + zephir_create_array(_11, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "obj", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_11, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_12, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_array_update_string(&_10, SL(":style"), &_11, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10, SL(":class"), &className, PH_COPY | PH_SEPARATE); - add_assoc_long_ex(_10, SS(":count"), zephir_fast_count_int(attr TSRMLS_CC)); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, ":class methods: (:count) (\n", 0); - ZEPHIR_CALL_FUNCTION(&_11, "strtr", &_4, &_3, _10); + zephir_array_update_string(&_11, SL(":style"), &_12, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_11, SL(":class"), &className, PH_COPY | PH_SEPARATE); + add_assoc_long_ex(_11, SS(":count"), zephir_fast_count_int(attr TSRMLS_CC)); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, ":class methods: (:count) (\n", 0); + ZEPHIR_CALL_FUNCTION(&_12, "strtr", &_5, 85, &_4, _11); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_13); - ZEPHIR_CONCAT_VV(_13, _8, _11); + ZEPHIR_CONCAT_VV(_13, _9, _12); zephir_concat_self(&output, _13 TSRMLS_CC); - _35 = zephir_fetch_nproperty_this(this_ptr, SL("_methods"), PH_NOISY_CC); - if (zephir_fast_in_array(className, _35 TSRMLS_CC)) { - ZEPHIR_CALL_FUNCTION(&_17, "str_repeat", &_9, space, tab); + _32 = zephir_fetch_nproperty_this(this_ptr, SL("methods"), PH_NOISY_CC); + if (zephir_fast_in_array(className, _32 TSRMLS_CC)) { + ZEPHIR_CALL_FUNCTION(&_17, "str_repeat", &_10, 68, space, tab); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_20); ZEPHIR_CONCAT_VS(_20, _17, "[already listed]\n"); zephir_concat_self(&output, _20 TSRMLS_CC); } else { - zephir_is_iterable(attr, &_37, &_36, 0, 0, "ice/dump.zep", 228); + zephir_is_iterable(attr, &_34, &_33, 0, 0, "ice/dump.zep", 236); for ( - ; zephir_hash_get_current_data_ex(_37, (void**) &_38, &_36) == SUCCESS - ; zephir_hash_move_forward_ex(_37, &_36) + ; zephir_hash_get_current_data_ex(_34, (void**) &_35, &_33) == SUCCESS + ; zephir_hash_move_forward_ex(_34, &_33) ) { - ZEPHIR_GET_HVALUE(value, _38); - _39 = zephir_fetch_nproperty_this(this_ptr, SL("_methods"), PH_NOISY_CC); - if (!(zephir_fast_in_array(className, _39 TSRMLS_CC))) { - zephir_update_property_array_append(this_ptr, SL("_methods"), className TSRMLS_CC); + ZEPHIR_GET_HVALUE(value, _35); + _36 = zephir_fetch_nproperty_this(this_ptr, SL("methods"), PH_NOISY_CC); + if (!(zephir_fast_in_array(className, _36 TSRMLS_CC))) { + zephir_update_property_array_append(this_ptr, SL("methods"), className TSRMLS_CC); } if (ZEPHIR_IS_STRING(value, "__construct")) { - ZEPHIR_SINIT_NVAR(_3); - ZVAL_LONG(&_3, (zephir_get_numberval(tab) + 1)); - ZEPHIR_CALL_FUNCTION(&_8, "str_repeat", &_9, space, &_3); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_LONG(&_4, (zephir_get_numberval(tab) + 1)); + ZEPHIR_CALL_FUNCTION(&_9, "str_repeat", &_10, 68, space, &_4); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_10); - array_init_size(_10, 3); + ZEPHIR_INIT_NVAR(_11); + zephir_create_array(_11, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "obj", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_11, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_12, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_array_update_string(&_10, SL(":style"), &_11, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10, SL(":method"), &value, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "->:method(); [constructor]\n", 0); - ZEPHIR_CALL_FUNCTION(&_11, "strtr", &_4, &_3, _10); + zephir_array_update_string(&_11, SL(":style"), &_12, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_11, SL(":method"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "->:method(); [constructor]\n", 0); + ZEPHIR_CALL_FUNCTION(&_12, "strtr", &_5, 85, &_4, _11); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_13); - ZEPHIR_CONCAT_VV(_13, _8, _11); + ZEPHIR_CONCAT_VV(_13, _9, _12); zephir_concat_self(&output, _13 TSRMLS_CC); } else { - ZEPHIR_SINIT_NVAR(_3); - ZVAL_LONG(&_3, (zephir_get_numberval(tab) + 1)); - ZEPHIR_CALL_FUNCTION(&_27, "str_repeat", &_9, space, &_3); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_LONG(&_4, (zephir_get_numberval(tab) + 1)); + ZEPHIR_CALL_FUNCTION(&_26, "str_repeat", &_10, 68, space, &_4); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_40); - array_init_size(_40, 3); + ZEPHIR_INIT_NVAR(_37); + zephir_create_array(_37, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "obj", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_28, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_27, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_array_update_string(&_40, SL(":style"), &_28, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_40, SL(":method"), &value, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "->:method();\n", 0); - ZEPHIR_CALL_FUNCTION(&_28, "strtr", &_4, &_3, _40); + zephir_array_update_string(&_37, SL(":style"), &_27, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_37, SL(":method"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "->:method();\n", 0); + ZEPHIR_CALL_FUNCTION(&_27, "strtr", &_5, 85, &_4, _37); zephir_check_call_status(); - ZEPHIR_INIT_LNVAR(_41); - ZEPHIR_CONCAT_VV(_41, _27, _28); - zephir_concat_self(&output, _41 TSRMLS_CC); + ZEPHIR_INIT_LNVAR(_38); + ZEPHIR_CONCAT_VV(_38, _26, _27); + zephir_concat_self(&output, _38 TSRMLS_CC); } } - ZEPHIR_CALL_FUNCTION(&_17, "str_repeat", &_9, space, tab); + ZEPHIR_CALL_FUNCTION(&_17, "str_repeat", &_10, 68, space, tab); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_20); ZEPHIR_CONCAT_VS(_20, _17, ")\n"); zephir_concat_self(&output, _20 TSRMLS_CC); } - ZEPHIR_SINIT_NVAR(_3); - ZVAL_LONG(&_3, (zephir_get_numberval(tab) - 1)); - ZEPHIR_CALL_FUNCTION(&_8, "str_repeat", &_9, space, &_3); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_LONG(&_4, (zephir_get_numberval(tab) - 1)); + ZEPHIR_CALL_FUNCTION(&_9, "str_repeat", &_10, 68, space, &_4); zephir_check_call_status(); - ZEPHIR_CONCAT_VVS(return_value, output, _8, ")"); + ZEPHIR_CONCAT_VVS(return_value, output, _9, ")"); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_LONG) { ZEPHIR_INIT_NVAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "int", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL(":var"), &variable, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "integer (:var)", 0); - ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_4, &_3, _0); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "integer (:var)", 0); + ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_5, 85, &_4, _0); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _1); RETURN_MM(); } - ZEPHIR_CALL_FUNCTION(&_1, "is_float", &_42, variable); + ZEPHIR_CALL_FUNCTION(&_1, "is_float", NULL, 92, variable); zephir_check_call_status(); if (zephir_is_true(_1)) { ZEPHIR_INIT_NVAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "float", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_11, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_12, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_array_update_string(&_0, SL(":style"), &_11, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_0, SL(":style"), &_12, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL(":var"), &variable, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "float (:var)", 0); - ZEPHIR_CALL_FUNCTION(&_11, "strtr", &_4, &_3, _0); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "float (:var)", 0); + ZEPHIR_CALL_FUNCTION(&_12, "strtr", &_5, 85, &_4, _0); zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, output, _11); + ZEPHIR_CONCAT_VV(return_value, output, _12); RETURN_MM(); } if (zephir_is_numeric(variable)) { ZEPHIR_INIT_NVAR(_0); - array_init_size(_0, 4); + zephir_create_array(_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "num", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_0, SS(":length"), zephir_fast_strlen_ev(variable)); zephir_array_update_string(&_0, SL(":var"), &variable, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "numeric string (:length) \":var\"", 0); - ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_4, &_3, _0); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "numeric string (:length) \":var\"", 0); + ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_5, 85, &_4, _0); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _1); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_STRING) { ZEPHIR_INIT_NVAR(_0); - array_init_size(_0, 4); + zephir_create_array(_0, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "str", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); add_assoc_long_ex(_0, SS(":length"), zephir_fast_strlen_ev(variable)); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_LONG(&_3, 4); - ZEPHIR_SINIT_VAR(_43); - ZVAL_STRING(&_43, "utf-8", 0); - ZEPHIR_CALL_FUNCTION(&_1, "htmlentities", &_44, variable, &_3, &_43); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_LONG(&_4, 4); + ZEPHIR_SINIT_VAR(_39); + ZVAL_STRING(&_39, "utf-8", 0); + ZEPHIR_CALL_FUNCTION(&_1, "htmlentities", NULL, 93, variable, &_4, &_39); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_27, "nl2br", &_45, _1); + ZEPHIR_CALL_FUNCTION(&_26, "nl2br", NULL, 94, _1); zephir_check_call_status(); - zephir_array_update_string(&_0, SL(":var"), &_27, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "string (:length) \":var\"", 0); - ZEPHIR_CALL_FUNCTION(&_27, "strtr", &_4, &_3, _0); + zephir_array_update_string(&_0, SL(":var"), &_26, PH_COPY | PH_SEPARATE); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "string (:length) \":var\"", 0); + ZEPHIR_CALL_FUNCTION(&_26, "strtr", &_5, 85, &_4, _0); zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, output, _27); + ZEPHIR_CONCAT_VV(return_value, output, _26); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_BOOL) { ZEPHIR_INIT_NVAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "bool", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); @@ -710,41 +737,41 @@ PHP_METHOD(Ice_Dump, output) { ZVAL_STRING(_13, "false", 1); } zephir_array_update_string(&_0, SL(":var"), &_13, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "boolean (:var)", 0); - ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_4, &_3, _0); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "boolean (:var)", 0); + ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_5, 85, &_4, _0); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _1); RETURN_MM(); } if (Z_TYPE_P(variable) == IS_NULL) { ZEPHIR_INIT_NVAR(_0); - array_init_size(_0, 2); + zephir_create_array(_0, 1, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "null", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "null", 0); - ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_4, &_3, _0); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "null", 0); + ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_5, 85, &_4, _0); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _1); RETURN_MM(); } ZEPHIR_INIT_NVAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "other", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_12, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", &_3, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL(":var"), &variable, PH_COPY | PH_SEPARATE); - ZEPHIR_SINIT_NVAR(_3); - ZVAL_STRING(&_3, "(:var)", 0); - ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_4, &_3, _0); + ZEPHIR_SINIT_NVAR(_4); + ZVAL_STRING(&_4, "(:var)", 0); + ZEPHIR_CALL_FUNCTION(&_1, "strtr", &_5, 85, &_4, _0); zephir_check_call_status(); ZEPHIR_CONCAT_VV(return_value, output, _1); RETURN_MM(); @@ -765,7 +792,6 @@ PHP_METHOD(Ice_Dump, output) { */ PHP_METHOD(Ice_Dump, variable) { - zephir_nts_static zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *_0; zval *name = NULL; @@ -783,19 +809,19 @@ PHP_METHOD(Ice_Dump, variable) { ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "pre", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", NULL, _2); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":style"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "output", NULL, variable, name); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "output", NULL, 0, variable, name); zephir_check_call_status(); zephir_array_update_string(&_0, SL(":output"), &_1, PH_COPY | PH_SEPARATE); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "
:output
", 0); - ZEPHIR_RETURN_CALL_FUNCTION("strtr", &_4, &_3, _0); + ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 85, &_3, _0); zephir_check_call_status(); RETURN_MM(); @@ -818,33 +844,59 @@ PHP_METHOD(Ice_Dump, variable) { */ PHP_METHOD(Ice_Dump, vars) { - zephir_fcall_cache_entry *_7 = NULL; - HashTable *_3; - HashPosition _2; + zephir_fcall_cache_entry *_6 = NULL; + HashTable *_2; + HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; - zval *key = NULL, *value = NULL, *output, *_0 = NULL, **_4, *_5 = NULL, *_6 = NULL; + zval *key = NULL, *value = NULL, *output = NULL, *_0 = NULL, **_3, *_4 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(output); ZVAL_STRING(output, "", 1); - ZEPHIR_CALL_FUNCTION(&_0, "func_get_args", &_1); + ZEPHIR_CALL_FUNCTION(&_0, "func_get_args", NULL, 84); zephir_check_call_status(); - zephir_is_iterable(_0, &_3, &_2, 0, 0, "ice/dump.zep", 300); + zephir_is_iterable(_0, &_2, &_1, 0, 0, "ice/dump.zep", 309); for ( - ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS - ; zephir_hash_move_forward_ex(_3, &_2) + ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS + ; zephir_hash_move_forward_ex(_2, &_1) ) { - ZEPHIR_GET_HMKEY(key, _3, _2); - ZEPHIR_GET_HVALUE(value, _4); - ZEPHIR_INIT_LNVAR(_6); - ZEPHIR_CONCAT_SV(_6, "var ", key); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "one", &_7, value, _6); + ZEPHIR_GET_HMKEY(key, _2, _1); + ZEPHIR_GET_HVALUE(value, _3); + ZEPHIR_INIT_LNVAR(_5); + ZEPHIR_CONCAT_SV(_5, "var ", key); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "one", &_6, 0, value, _5); zephir_check_call_status(); - zephir_concat_self(&output, _5 TSRMLS_CC); + zephir_concat_self(&output, _4 TSRMLS_CC); } RETURN_CCTOR(output); } +static zend_object_value zephir_init_properties_Ice_Dump(zend_class_entry *class_type TSRMLS_DC) { + + zval *_0, *_1 = NULL, *_2; + + ZEPHIR_MM_GROW(); + + { + zval *this_ptr = NULL; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("styles"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("styles"), _1 TSRMLS_CC); + } + _2 = zephir_fetch_nproperty_this(this_ptr, SL("methods"), PH_NOISY_CC); + if (Z_TYPE_P(_2) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("methods"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } + +} + diff --git a/ext/ice/dump.zep.h b/ext/ice/dump.zep.h index c7c5a938..bec7c803 100644 --- a/ext/ice/dump.zep.h +++ b/ext/ice/dump.zep.h @@ -13,6 +13,7 @@ PHP_METHOD(Ice_Dump, one); PHP_METHOD(Ice_Dump, output); PHP_METHOD(Ice_Dump, variable); PHP_METHOD(Ice_Dump, vars); +static zend_object_value zephir_init_properties_Ice_Dump(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_dump_setdetailed, 0, 0, 1) ZEND_ARG_INFO(0, detailed) @@ -58,5 +59,5 @@ ZEPHIR_INIT_FUNCS(ice_dump_method_entry) { PHP_ME(Ice_Dump, output, arginfo_ice_dump_output, ZEND_ACC_PROTECTED) PHP_ME(Ice_Dump, variable, arginfo_ice_dump_variable, ZEND_ACC_PUBLIC) PHP_ME(Ice_Dump, vars, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/exception.zep.c b/ext/ice/exception.zep.c index 4891d0a0..9be09956 100644 --- a/ext/ice/exception.zep.c +++ b/ext/ice/exception.zep.c @@ -51,10 +51,10 @@ ZEPHIR_INIT_CLASS(Ice_Exception) { */ PHP_METHOD(Ice_Exception, __construct) { - zval *_9 = NULL; + zval *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_2 = NULL, *_6 = NULL, *_7 = NULL; - zval *message = NULL, *code = NULL, *previous = NULL, *di = NULL, *values = NULL, *str = NULL, _1 = zval_used_for_init, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_8 = NULL; + zephir_fcall_cache_entry *_0 = NULL; + zval *message = NULL, *code = NULL, *previous = NULL, *di = NULL, *values = NULL, *str = NULL, _1 = zval_used_for_init, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 3, &message, &code, &previous); @@ -74,12 +74,12 @@ PHP_METHOD(Ice_Exception, __construct) { } - ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_0); + ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_0, 8); zephir_check_call_status(); if (Z_TYPE_P(message) == IS_ARRAY) { ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 1); - ZEPHIR_CALL_FUNCTION(&values, "array_slice", &_2, message, &_1); + ZEPHIR_CALL_FUNCTION(&values, "array_slice", NULL, 95, message, &_1); zephir_check_call_status(); ZEPHIR_OBS_VAR(str); zephir_array_fetch_long(&str, message, 0, PH_NOISY, "ice/exception.zep", 32 TSRMLS_CC); @@ -88,42 +88,46 @@ PHP_METHOD(Ice_Exception, __construct) { ZVAL_NULL(values); ZEPHIR_CPY_WRT(str, message); } - ZEPHIR_INIT_VAR(_4); - ZVAL_STRING(_4, "i18n", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_3, di, "has", NULL, _4); - zephir_check_temp_parameter(_4); + ZEPHIR_INIT_VAR(_3); + ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_2, di, "has", NULL, 0, _3); + zephir_check_temp_parameter(_3); zephir_check_call_status(); - if (zephir_is_true(_3)) { - ZEPHIR_INIT_NVAR(_4); - ZVAL_STRING(_4, "i18n", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_5, di, "get", NULL, _4); - zephir_check_temp_parameter(_4); + if (zephir_is_true(_2)) { + ZEPHIR_INIT_NVAR(_3); + ZVAL_STRING(_3, "i18n", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_5); + ZVAL_NULL(_5); + ZEPHIR_INIT_VAR(_6); + ZVAL_BOOL(_6, 1); + ZEPHIR_CALL_METHOD(&_4, di, "get", NULL, 0, _3, _5, _6); + zephir_check_temp_parameter(_3); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&message, _5, "translate", NULL, str, values); + ZEPHIR_CALL_METHOD(&message, _4, "translate", NULL, 0, str, values); zephir_check_call_status(); } else if (Z_TYPE_P(values) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(_4); - zephir_array_keys(_4, values TSRMLS_CC); + ZEPHIR_INIT_NVAR(_3); + zephir_array_keys(_3, values TSRMLS_CC); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "is_string", 0); - ZEPHIR_CALL_FUNCTION(&_5, "array_filter", &_6, _4, &_1); + ZEPHIR_CALL_FUNCTION(&_4, "array_filter", NULL, 10, _3, &_1); zephir_check_call_status(); - if (zephir_fast_count_int(_5 TSRMLS_CC)) { - ZEPHIR_CALL_FUNCTION(&message, "strtr", &_7, str, values); + if (zephir_fast_count_int(_4 TSRMLS_CC)) { + ZEPHIR_CALL_FUNCTION(&message, "strtr", NULL, 85, str, values); zephir_check_call_status(); } else { - ZEPHIR_INIT_VAR(_8); + ZEPHIR_INIT_NVAR(_5); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "sprintf", 0); - ZEPHIR_CALL_USER_FUNC_ARRAY(_8, &_1, message); + ZEPHIR_CALL_USER_FUNC_ARRAY(_5, &_1, message); zephir_check_call_status(); - ZEPHIR_CPY_WRT(message, _8); + ZEPHIR_CPY_WRT(message, _5); } } - zephir_get_strval(_9, message); - ZEPHIR_INIT_NVAR(_8); - ZVAL_LONG(_8, zephir_get_intval(code)); - ZEPHIR_CALL_PARENT(NULL, ice_exception_ce, this_ptr, "__construct", NULL, _9, _8, previous); + zephir_get_strval(_7, message); + ZEPHIR_INIT_NVAR(_5); + ZVAL_LONG(_5, zephir_get_intval(code)); + ZEPHIR_CALL_PARENT(NULL, ice_exception_ce, this_ptr, "__construct", NULL, 0, _7, _5, previous); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -137,20 +141,21 @@ PHP_METHOD(Ice_Exception, __construct) { */ PHP_METHOD(Ice_Exception, getFullTraceAsString) { - zephir_nts_static zephir_fcall_cache_entry *_19 = NULL; + zephir_fcall_cache_entry *_19 = NULL; HashTable *_2, *_6; HashPosition _1, _5; - int count = 0, ZEPHIR_LAST_CALL_STATUS; - zval *e, *output, *frame = NULL, *args = NULL, *arg = NULL, *node = NULL, *_0 = NULL, **_3, *_4, **_7, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11, *_12 = NULL, *_13, *_14, *_15, _16 = zval_used_for_init, _17 = zval_used_for_init, *_18 = NULL; + int count, ZEPHIR_LAST_CALL_STATUS; + zval *e, *output = NULL, *frame = NULL, *args = NULL, *arg = NULL, *node = NULL, *_0 = NULL, **_3, *_4, **_7, *_8 = NULL, *_9 = NULL, *_10 = NULL, *_11, *_12 = NULL, *_13, *_14, *_15, _16 = zval_used_for_init, _17 = zval_used_for_init, *_18 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &e); + count = 0; ZEPHIR_INIT_VAR(output); ZVAL_STRING(output, "", 1); - ZEPHIR_CALL_METHOD(&_0, e, "gettrace", NULL); + ZEPHIR_CALL_METHOD(&_0, e, "gettrace", NULL, 0); zephir_check_call_status(); zephir_is_iterable(_0, &_2, &_1, 0, 0, "ice/exception.zep", 109); for ( @@ -248,7 +253,7 @@ PHP_METHOD(Ice_Exception, getFullTraceAsString) { ZVAL_STRING(&_16, "#%s %s: %s(%s)\n", 0); ZEPHIR_SINIT_NVAR(_17); ZVAL_LONG(&_17, count); - ZEPHIR_CALL_FUNCTION(&_18, "sprintf", &_19, &_16, &_17, _9, _12, args); + ZEPHIR_CALL_FUNCTION(&_18, "sprintf", &_19, 1, &_16, &_17, _9, _12, args); zephir_check_call_status(); zephir_concat_self(&output, _18 TSRMLS_CC); count++; @@ -265,10 +270,9 @@ PHP_METHOD(Ice_Exception, getFullTraceAsString) { */ PHP_METHOD(Ice_Exception, errorHandler) { - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; zval *context = NULL; zval *message = NULL, *file = NULL; - zval *code_param = NULL, *message_param = NULL, *file_param = NULL, *line_param = NULL, *context_param = NULL, *_0 = NULL, *_2, *_3, *_4, *_5; + zval *code_param = NULL, *message_param = NULL, *file_param = NULL, *line_param = NULL, *context_param = NULL, *_0 = NULL, *_1, *_2, *_3, *_4; int code, line, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); @@ -295,20 +299,20 @@ PHP_METHOD(Ice_Exception, errorHandler) { } - ZEPHIR_CALL_FUNCTION(&_0, "error_reporting", &_1); + ZEPHIR_CALL_FUNCTION(&_0, "error_reporting", NULL, 96); zephir_check_call_status(); if (((int) (zephir_get_numberval(_0)) & code)) { + ZEPHIR_INIT_VAR(_1); + object_init_ex(_1, zephir_get_internal_ce(SS("errorexception") TSRMLS_CC)); ZEPHIR_INIT_VAR(_2); - object_init_ex(_2, zephir_get_internal_ce(SS("errorexception") TSRMLS_CC)); + ZVAL_LONG(_2, code); ZEPHIR_INIT_VAR(_3); - ZVAL_LONG(_3, code); + ZVAL_LONG(_3, 0); ZEPHIR_INIT_VAR(_4); - ZVAL_LONG(_4, 0); - ZEPHIR_INIT_VAR(_5); - ZVAL_LONG(_5, line); - ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, message, _3, _4, file, _5); + ZVAL_LONG(_4, line); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 97, message, _2, _3, file, _4); zephir_check_call_status(); - zephir_throw_exception_debug(_2, "ice/exception.zep", 123 TSRMLS_CC); + zephir_throw_exception_debug(_1, "ice/exception.zep", 123 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } @@ -337,21 +341,21 @@ PHP_METHOD(Ice_Exception, handler) { ZEPHIR_INIT_VAR(_1); zephir_get_called_class(_1 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 4); - ZEPHIR_CALL_METHOD(&_3, e, "getmessage", NULL); + zephir_create_array(_2, 3, 0 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_3, e, "getmessage", NULL, 0); zephir_check_call_status(); zephir_array_fast_append(_2, _3); - ZEPHIR_CALL_METHOD(&_3, e, "getcode", NULL); + ZEPHIR_CALL_METHOD(&_3, e, "getcode", NULL, 0); zephir_check_call_status(); zephir_array_fast_append(_2, _3); zephir_array_fast_append(_2, e); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(_0, _1, _2 TSRMLS_CC); zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 1); zephir_exit(&_4); ZEPHIR_MM_RESTORE(); - ZEPHIR_MM_RESTORE(); } @@ -362,53 +366,52 @@ PHP_METHOD(Ice_Exception, handler) { */ PHP_METHOD(Ice_Exception, shutdownHandler) { - zval *_3; - zend_bool _1; + zval *_2; + zend_bool _0; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_5 = NULL, *_6 = NULL; - zval *e = NULL, *_2, *_4 = NULL, *_7, *_8, *_9, *_10, *_11, _12; + zval *e = NULL, *_1, *_3 = NULL, *_4, *_5, *_6, *_7, *_8, _9; ZEPHIR_MM_GROW(); - ZEPHIR_CALL_FUNCTION(&e, "error_get_last", &_0); + ZEPHIR_CALL_FUNCTION(&e, "error_get_last", NULL, 98); zephir_check_call_status(); - _1 = Z_TYPE_P(e) == IS_ARRAY; - if (_1) { - zephir_array_fetch_string(&_2, e, SL("type"), PH_NOISY | PH_READONLY, "ice/exception.zep", 152 TSRMLS_CC); + _0 = Z_TYPE_P(e) == IS_ARRAY; + if (_0) { + zephir_array_fetch_string(&_1, e, SL("type"), PH_NOISY | PH_READONLY, "ice/exception.zep", 152 TSRMLS_CC); + ZEPHIR_INIT_VAR(_2); + zephir_create_array(_2, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); - array_init_size(_3, 4); - ZEPHIR_INIT_VAR(_4); - ZVAL_LONG(_4, 4); - zephir_array_fast_append(_3, _4); - ZEPHIR_INIT_NVAR(_4); - ZVAL_LONG(_4, 1); - zephir_array_fast_append(_3, _4); - ZEPHIR_INIT_NVAR(_4); - ZVAL_LONG(_4, 256); - zephir_array_fast_append(_3, _4); - _1 = zephir_fast_in_array(_2, _3 TSRMLS_CC); + ZVAL_LONG(_3, 4); + zephir_array_fast_append(_2, _3); + ZEPHIR_INIT_NVAR(_3); + ZVAL_LONG(_3, 1); + zephir_array_fast_append(_2, _3); + ZEPHIR_INIT_NVAR(_3); + ZVAL_LONG(_3, 256); + zephir_array_fast_append(_2, _3); + _0 = zephir_fast_in_array(_1, _2 TSRMLS_CC); } - if (_1) { - ZEPHIR_CALL_FUNCTION(NULL, "ob_get_level", &_5); + if (_0) { + ZEPHIR_CALL_FUNCTION(NULL, "ob_get_level", NULL, 99); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "ob_clean", &_6); + ZEPHIR_CALL_FUNCTION(NULL, "ob_clean", NULL, 100); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(_4); - object_init_ex(_4, zephir_get_internal_ce(SS("errorexception") TSRMLS_CC)); - zephir_array_fetch_string(&_7, e, SL("message"), PH_NOISY | PH_READONLY, "ice/exception.zep", 157 TSRMLS_CC); - zephir_array_fetch_string(&_8, e, SL("type"), PH_NOISY | PH_READONLY, "ice/exception.zep", 157 TSRMLS_CC); - zephir_array_fetch_string(&_9, e, SL("file"), PH_NOISY | PH_READONLY, "ice/exception.zep", 157 TSRMLS_CC); - zephir_array_fetch_string(&_10, e, SL("line"), PH_NOISY | PH_READONLY, "ice/exception.zep", 157 TSRMLS_CC); - ZEPHIR_INIT_VAR(_11); - ZVAL_LONG(_11, 0); - ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, _7, _8, _11, _9, _10); + ZEPHIR_INIT_NVAR(_3); + object_init_ex(_3, zephir_get_internal_ce(SS("errorexception") TSRMLS_CC)); + zephir_array_fetch_string(&_4, e, SL("message"), PH_NOISY | PH_READONLY, "ice/exception.zep", 157 TSRMLS_CC); + zephir_array_fetch_string(&_5, e, SL("type"), PH_NOISY | PH_READONLY, "ice/exception.zep", 157 TSRMLS_CC); + zephir_array_fetch_string(&_6, e, SL("file"), PH_NOISY | PH_READONLY, "ice/exception.zep", 157 TSRMLS_CC); + zephir_array_fetch_string(&_7, e, SL("line"), PH_NOISY | PH_READONLY, "ice/exception.zep", 157 TSRMLS_CC); + ZEPHIR_INIT_VAR(_8); + ZVAL_LONG(_8, 0); + ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 97, _4, _5, _8, _6, _7); zephir_check_call_status(); - ZEPHIR_CALL_SELF(NULL, "handler", NULL, _4); + ZEPHIR_CALL_SELF(NULL, "handler", NULL, 0, _3); zephir_check_call_status(); - ZEPHIR_SINIT_VAR(_12); - ZVAL_LONG(&_12, 1); - zephir_exit(&_12); ZEPHIR_MM_RESTORE(); + ZEPHIR_SINIT_VAR(_9); + ZVAL_LONG(&_9, 1); + zephir_exit(&_9); } ZEPHIR_MM_RESTORE(); diff --git a/ext/ice/exception.zep.h b/ext/ice/exception.zep.h index 6053ef65..d33ce7f9 100644 --- a/ext/ice/exception.zep.h +++ b/ext/ice/exception.zep.h @@ -37,5 +37,5 @@ ZEPHIR_INIT_FUNCS(ice_exception_method_entry) { PHP_ME(Ice_Exception, errorHandler, arginfo_ice_exception_errorhandler, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Ice_Exception, handler, arginfo_ice_exception_handler, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Ice_Exception, shutdownHandler, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/filter.zep.c b/ext/ice/filter.zep.c index db246740..695ab263 100644 --- a/ext/ice/filter.zep.c +++ b/ext/ice/filter.zep.c @@ -38,7 +38,7 @@ ZEPHIR_INIT_CLASS(Ice_Filter) { ZEPHIR_REGISTER_CLASS(Ice, Filter, ice, filter, ice_filter_method_entry, 0); - zend_declare_property_null(ice_filter_ce, SL("_filters"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_filter_ce, SL("filters"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -62,7 +62,6 @@ PHP_METHOD(Ice_Filter, add) { 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 { @@ -75,7 +74,7 @@ PHP_METHOD(Ice_Filter, add) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Filter must be an object", "ice/filter.zep", 27); return; } - zephir_update_property_array(this_ptr, SL("_filters"), name, body TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("filters"), name, body TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -114,7 +113,7 @@ PHP_METHOD(Ice_Filter, sanitize) { ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(filter, _3); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "_sanitize", &_5, value, filter); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "dosanitize", &_5, 0, value, filter); zephir_check_call_status(); ZEPHIR_CPY_WRT(value, _4); } @@ -131,10 +130,9 @@ PHP_METHOD(Ice_Filter, sanitize) { * @param string filter * @return mixed */ -PHP_METHOD(Ice_Filter, _sanitize) { +PHP_METHOD(Ice_Filter, doSanitize) { - zephir_fcall_cache_entry *_11 = NULL; - zephir_nts_static zephir_fcall_cache_entry *_9 = NULL, *_15 = NULL, *_16 = NULL, *_17 = NULL; + zephir_fcall_cache_entry *_9 = NULL, *_11 = NULL; zval *_1 = NULL, *_12; int ZEPHIR_LAST_CALL_STATUS; zval *value_param = NULL, *filter_param = NULL, *custom = NULL, *_0, _2 = zval_used_for_init, *_3 = NULL, *_4 = NULL, *_5 = NULL, *_6, *_7, *_8 = NULL, _10 = zval_used_for_init, *_13; @@ -148,7 +146,6 @@ PHP_METHOD(Ice_Filter, _sanitize) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filter' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(filter_param) == IS_STRING)) { zephir_get_strval(filter, filter_param); } else { @@ -158,44 +155,44 @@ PHP_METHOD(Ice_Filter, _sanitize) { ZEPHIR_OBS_VAR(custom); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("filters"), PH_NOISY_CC); if (zephir_array_isset_fetch(&custom, _0, filter, 0 TSRMLS_CC)) { if (zephir_instance_of_ev(custom, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 2); + zephir_create_array(_1, 1, 0 TSRMLS_CC); zephir_array_fast_append(_1, value); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, custom, _1); zephir_check_call_status(); RETURN_MM(); } - ZEPHIR_RETURN_CALL_METHOD(custom, "sanitize", NULL, value); + ZEPHIR_RETURN_CALL_METHOD(custom, "sanitize", NULL, 0, value); zephir_check_call_status(); RETURN_MM(); } do { if (ZEPHIR_IS_STRING(filter, "cssmin")) { - ZEPHIR_INIT_NVAR(custom); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "Ice\\Filter\\Css", 0); + ZEPHIR_INIT_NVAR(custom); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(custom, &_2 TSRMLS_CC); zephir_check_call_status(); ZEPHIR_INIT_VAR(_3); ZVAL_STRING(_3, "cssmin", 1); - zephir_update_property_array(this_ptr, SL("_filters"), _3, custom TSRMLS_CC); - ZEPHIR_RETURN_CALL_METHOD(custom, "sanitize", NULL, value); + zephir_update_property_array(this_ptr, SL("filters"), _3, custom TSRMLS_CC); + ZEPHIR_RETURN_CALL_METHOD(custom, "sanitize", NULL, 0, value); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "jsmin")) { - ZEPHIR_INIT_NVAR(custom); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "Ice\\Filter\\Js", 0); + ZEPHIR_INIT_NVAR(custom); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(custom, &_2 TSRMLS_CC); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "jsmin", 1); - zephir_update_property_array(this_ptr, SL("_filters"), _3, custom TSRMLS_CC); - ZEPHIR_RETURN_CALL_METHOD(custom, "sanitize", NULL, value); + zephir_update_property_array(this_ptr, SL("filters"), _3, custom TSRMLS_CC); + ZEPHIR_RETURN_CALL_METHOD(custom, "sanitize", NULL, 0, value); zephir_check_call_status(); RETURN_MM(); } @@ -217,7 +214,7 @@ PHP_METHOD(Ice_Filter, _sanitize) { ZVAL_STRING(_6, "/(?<=\\w)(?=[A-Z])/", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_7); ZVAL_STRING(_7, " $1", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_FUNCTION(&_8, "preg_replace", &_9, _6, _7, value); + ZEPHIR_CALL_FUNCTION(&_8, "preg_replace", &_9, 101, _6, _7, value); zephir_check_temp_parameter(_6); zephir_check_temp_parameter(_7); zephir_check_call_status(); @@ -226,7 +223,7 @@ PHP_METHOD(Ice_Filter, _sanitize) { ZVAL_STRING(&_2, "_", 0); ZEPHIR_SINIT_VAR(_10); ZVAL_STRING(&_10, " ", 0); - zephir_fast_str_replace(_4, &_2, &_10, _5 TSRMLS_CC); + zephir_fast_str_replace(&_4, &_2, &_10, _5 TSRMLS_CC); zephir_fast_trim(_3, _4, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); zephir_ucfirst(return_value, _3); RETURN_MM(); @@ -234,7 +231,7 @@ PHP_METHOD(Ice_Filter, _sanitize) { if (ZEPHIR_IS_STRING(filter, "lower")) { ZEPHIR_INIT_NVAR(_3); if ((zephir_function_exists_ex(SS("mb_strtolower") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_FUNCTION(&_3, "mb_strtolower", NULL, value); + ZEPHIR_CALL_FUNCTION(&_3, "mb_strtolower", NULL, 102, value); zephir_check_call_status(); } else { zephir_fast_strtolower(_3, value); @@ -244,7 +241,7 @@ PHP_METHOD(Ice_Filter, _sanitize) { if (ZEPHIR_IS_STRING(filter, "upper")) { ZEPHIR_INIT_NVAR(_3); if ((zephir_function_exists_ex(SS("mb_strtoupper") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_FUNCTION(&_3, "mb_strtoupper", NULL, value); + ZEPHIR_CALL_FUNCTION(&_3, "mb_strtoupper", NULL, 103, value); zephir_check_call_status(); } else { zephir_fast_strtoupper(_3, value); @@ -256,7 +253,7 @@ PHP_METHOD(Ice_Filter, _sanitize) { ZVAL_STRING(_3, "/[^a-z0-9]/i", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", &_9, _3, _4, value); + ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", &_9, 101, _3, _4, value); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); @@ -267,7 +264,7 @@ PHP_METHOD(Ice_Filter, _sanitize) { ZVAL_STRING(_3, "/[^a-z]/i", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", &_9, _3, _4, value); + ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", &_9, 101, _3, _4, value); zephir_check_temp_parameter(_3); zephir_check_temp_parameter(_4); zephir_check_call_status(); @@ -276,7 +273,7 @@ PHP_METHOD(Ice_Filter, _sanitize) { if (ZEPHIR_IS_STRING(filter, "email")) { ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 517); - ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_11, value, &_2); + ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_11, 104, value, &_2); zephir_check_call_status(); RETURN_MM(); } @@ -285,27 +282,27 @@ PHP_METHOD(Ice_Filter, _sanitize) { ZVAL_LONG(&_2, 520); ZEPHIR_SINIT_NVAR(_10); ZVAL_LONG(&_10, 4096); - ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_11, value, &_2, &_10); + ZEPHIR_CALL_FUNCTION(&_8, "filter_var", &_11, 104, value, &_2, &_10); zephir_check_call_status(); - RETURN_MM(); + RETURN_MM_DOUBLE(zephir_get_doubleval(_8)); } if (ZEPHIR_IS_STRING(filter, "int")) { ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 519); - ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_11, value, &_2); + ZEPHIR_CALL_FUNCTION(&_8, "filter_var", &_11, 104, value, &_2); zephir_check_call_status(); - RETURN_MM(); + RETURN_MM_LONG(zephir_get_intval(_8)); } if (ZEPHIR_IS_STRING(filter, "string")) { ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, 513); - ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_11, value, &_2); + ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_11, 104, value, &_2); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "repeats") || ZEPHIR_IS_STRING(filter, "strip_repeats")) { ZEPHIR_INIT_NVAR(_1); - array_init_size(_1, 4); + zephir_create_array(_1, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, "/[ ]{2,}/", 1); zephir_array_fast_append(_1, _3); @@ -316,7 +313,7 @@ PHP_METHOD(Ice_Filter, _sanitize) { ZVAL_STRING(_3, "~(.?)\\1{3,}~", 1); zephir_array_fast_append(_1, _3); ZEPHIR_INIT_VAR(_12); - array_init_size(_12, 4); + zephir_create_array(_12, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_3); ZVAL_STRING(_3, " ", 1); zephir_array_fast_append(_12, _3); @@ -330,7 +327,7 @@ PHP_METHOD(Ice_Filter, _sanitize) { ZEPHIR_INIT_NVAR(_5); ZVAL_STRING(_5, "$1$1$1", 1); zephir_array_fast_append(_12, _5); - ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", &_9, _1, _12, value); + ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", &_9, 101, _1, _12, value); zephir_check_call_status(); RETURN_MM(); } @@ -338,14 +335,14 @@ PHP_METHOD(Ice_Filter, _sanitize) { zephir_get_strval(_14, value); ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, (3 | 48)); - ZEPHIR_RETURN_CALL_FUNCTION("htmlspecialchars", &_15, _14, &_2); + ZEPHIR_RETURN_CALL_FUNCTION("htmlspecialchars", NULL, 105, _14, &_2); zephir_check_call_status(); RETURN_MM(); } if (ZEPHIR_IS_STRING(filter, "unescape") || ZEPHIR_IS_STRING(filter, "unstrip_special")) { ZEPHIR_SINIT_NVAR(_2); ZVAL_LONG(&_2, (3 | 48)); - ZEPHIR_RETURN_CALL_FUNCTION("htmlspecialchars_decode", &_16, value, &_2); + ZEPHIR_RETURN_CALL_FUNCTION("htmlspecialchars_decode", NULL, 106, value, &_2); zephir_check_call_status(); RETURN_MM(); } @@ -353,9 +350,9 @@ PHP_METHOD(Ice_Filter, _sanitize) { object_init_ex(_3, ice_exception_ce); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "Filter '%s' is not supported", 0); - ZEPHIR_CALL_FUNCTION(&_8, "sprintf", &_17, &_2, filter); + ZEPHIR_CALL_FUNCTION(&_8, "sprintf", NULL, 1, &_2, filter); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, _8); + ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 2, _8); zephir_check_call_status(); zephir_throw_exception_debug(_3, "ice/filter.zep", 127 TSRMLS_CC); ZEPHIR_MM_RESTORE(); diff --git a/ext/ice/filter.zep.h b/ext/ice/filter.zep.h index fda0d861..7fa256e6 100644 --- a/ext/ice/filter.zep.h +++ b/ext/ice/filter.zep.h @@ -5,7 +5,7 @@ ZEPHIR_INIT_CLASS(Ice_Filter); PHP_METHOD(Ice_Filter, add); PHP_METHOD(Ice_Filter, sanitize); -PHP_METHOD(Ice_Filter, _sanitize); +PHP_METHOD(Ice_Filter, doSanitize); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_filter_add, 0, 0, 2) ZEND_ARG_INFO(0, name) @@ -17,7 +17,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_filter_sanitize, 0, 0, 2) ZEND_ARG_INFO(0, filters) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_filter__sanitize, 0, 0, 2) +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_filter_dosanitize, 0, 0, 2) ZEND_ARG_INFO(0, value) ZEND_ARG_INFO(0, filter) ZEND_END_ARG_INFO() @@ -25,6 +25,6 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_filter_method_entry) { PHP_ME(Ice_Filter, add, arginfo_ice_filter_add, ZEND_ACC_PUBLIC) PHP_ME(Ice_Filter, sanitize, arginfo_ice_filter_sanitize, ZEND_ACC_PUBLIC) - PHP_ME(Ice_Filter, _sanitize, arginfo_ice_filter__sanitize, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_ME(Ice_Filter, doSanitize, arginfo_ice_filter_dosanitize, ZEND_ACC_PROTECTED) + PHP_FE_END }; diff --git a/ext/ice/filter/css.zep.c b/ext/ice/filter/css.zep.c index e9b1a0d0..d880fc0a 100644 --- a/ext/ice/filter/css.zep.c +++ b/ext/ice/filter/css.zep.c @@ -12,8 +12,8 @@ #include #include "kernel/main.h" -#include "kernel/operators.h" #include "kernel/memory.h" +#include "kernel/operators.h" /** @@ -58,8 +58,8 @@ PHP_METHOD(Ice_Filter_Css, sanitize) { unsigned char _2; zend_bool _1, _3; long _0; - int i, tmp, state = 1, inParen = 0; - char c, next; + int i = 0, tmp = 0, state, inParen; + char c = 0, next = 0; zval *css_param = NULL; zval *css = NULL, *min; @@ -67,10 +67,12 @@ PHP_METHOD(Ice_Filter_Css, sanitize) { zephir_fetch_params(1, 1, 0, &css_param); zephir_get_strval(css, css_param); - ZEPHIR_INIT_VAR(min); - ZVAL_STRING(min, "", 1); + ZEPHIR_INIT_VAR(min); + ZVAL_EMPTY_STRING(min); + state = 1; + inParen = 0; for (_0 = 0; _0 < Z_STRLEN_P(css); _0++) { i = _0; c = ZEPHIR_STRING_OFFSET(css, _0); diff --git a/ext/ice/filter/css.zep.h b/ext/ice/filter/css.zep.h index ae54c354..5dc2b7a4 100644 --- a/ext/ice/filter/css.zep.h +++ b/ext/ice/filter/css.zep.h @@ -11,5 +11,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_filter_css_method_entry) { PHP_ME(Ice_Filter_Css, sanitize, arginfo_ice_filter_css_sanitize, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/filter/js.zep.c b/ext/ice/filter/js.zep.c index dd76cb1c..9408e5bc 100644 --- a/ext/ice/filter/js.zep.c +++ b/ext/ice/filter/js.zep.c @@ -12,8 +12,13 @@ #include #include "kernel/main.h" -#include "kernel/operators.h" +#include "kernel/object.h" #include "kernel/memory.h" +#include "kernel/string.h" +#include "kernel/fcall.h" +#include "kernel/operators.h" +#include "kernel/concat.h" +#include "kernel/exception.h" /** @@ -30,10 +35,41 @@ ZEPHIR_INIT_CLASS(Ice_Filter_Js) { ZEPHIR_REGISTER_CLASS(Ice\\Filter, Js, ice, filter_js, ice_filter_js_method_entry, 0); + zend_declare_property_string(ice_filter_js_ce, SL("a"), "", ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_string(ice_filter_js_ce, SL("b"), "", ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_string(ice_filter_js_ce, SL("input"), "", ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_long(ice_filter_js_ce, SL("inputIndex"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_long(ice_filter_js_ce, SL("inputLength"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_null(ice_filter_js_ce, SL("lookAhead"), ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_string(ice_filter_js_ce, SL("output"), "", ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_class_constant_long(ice_filter_js_ce, SL("ORD_LF"), 10 TSRMLS_CC); + + zend_declare_class_constant_long(ice_filter_js_ce, SL("ORD_SPACE"), 32 TSRMLS_CC); + + zend_declare_class_constant_long(ice_filter_js_ce, SL("ACTION_KEEP_A"), 1 TSRMLS_CC); + + zend_declare_class_constant_long(ice_filter_js_ce, SL("ACTION_DELETE_A"), 2 TSRMLS_CC); + + zend_declare_class_constant_long(ice_filter_js_ce, SL("ACTION_DELETE_A_B"), 3 TSRMLS_CC); + return SUCCESS; } +PHP_METHOD(Ice_Filter_Js, getOutput) { + + + RETURN_MEMBER(this_ptr, "output"); + +} + /** * Minify the js. * @@ -42,28 +78,630 @@ ZEPHIR_INIT_CLASS(Ice_Filter_Js) { */ PHP_METHOD(Ice_Filter_Js, sanitize) { - long _0; - int i; - char c, next; - zval *js_param = NULL; - zval *js = NULL, *min; + int ZEPHIR_LAST_CALL_STATUS; + zval *js_param = NULL, *_0, *_1, _2, _3, *_4; + zval *js = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &js_param); zephir_get_strval(js, js_param); - ZEPHIR_INIT_VAR(min); - ZVAL_STRING(min, "", 1); - for (_0 = 0; _0 < Z_STRLEN_P(js); _0++) { - i = _0; - c = ZEPHIR_STRING_OFFSET(js, _0); - next = ZEPHIR_STRING_OFFSET(js, i); - next = next; - zephir_concat_self_char(&min, c TSRMLS_CC); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_STRING(_0, "", 1); + zephir_update_property_this(this_ptr, SL("a"), _0 TSRMLS_CC); + ZEPHIR_INIT_ZVAL_NREF(_0); + ZVAL_STRING(_0, "", 1); + zephir_update_property_this(this_ptr, SL("b"), _0 TSRMLS_CC); + ZEPHIR_INIT_VAR(_1); + ZEPHIR_SINIT_VAR(_2); + ZVAL_STRING(&_2, "\r\n", 0); + ZEPHIR_SINIT_VAR(_3); + ZVAL_STRING(&_3, "\n", 0); + zephir_fast_str_replace(&_1, &_2, &_3, js TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("input"), _1 TSRMLS_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("input"), PH_NOISY_CC); + ZEPHIR_INIT_ZVAL_NREF(_4); + ZVAL_LONG(_4, zephir_fast_strlen_ev(_0)); + zephir_update_property_this(this_ptr, SL("inputLength"), _4 TSRMLS_CC); + ZEPHIR_INIT_ZVAL_NREF(_4); + ZVAL_LONG(_4, 0); + zephir_update_property_this(this_ptr, SL("inputIndex"), _4 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("lookAhead"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); + ZEPHIR_INIT_ZVAL_NREF(_4); + ZVAL_STRING(_4, "", 1); + zephir_update_property_this(this_ptr, SL("output"), _4 TSRMLS_CC); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "min", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + +} + +/** + * 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). + */ +PHP_METHOD(Ice_Filter_Js, action) { + + zephir_fcall_cache_entry *_9 = NULL, *_14 = NULL, *_21 = NULL; + zend_bool _3, _4, _20, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _34, _36; + zval *command_param = NULL, *_0, *_1, *_2 = NULL, *_5, *_6, *_7, *_8 = NULL, *_10, *_11, *_12, *_13 = NULL, *_15, *_16, *_17, *_18 = NULL, *_19 = NULL, *_33, *_35, *_37, *_38, *_39, *_40, *_41, *_42, *_43, *_44, *_45, *_46, *_47 = NULL, *_48, *_49, *_50, *_51 = NULL, *_52, *_53, *_54 = NULL, *_55 = NULL; + int command, ZEPHIR_LAST_CALL_STATUS; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &command_param); + + command = zephir_get_intval(command_param); + + + if (command == 1) { + _0 = zephir_fetch_nproperty_this(this_ptr, SL("output"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_2); + ZEPHIR_CONCAT_VV(_2, _0, _1); + zephir_update_property_this(this_ptr, SL("output"), _2 TSRMLS_CC); + } + _3 = command == 1; + if (!(_3)) { + _3 = command == 2; + } + if (_3) { + _0 = zephir_fetch_nproperty_this(this_ptr, SL("b"), PH_NOISY_CC); + zephir_update_property_this(this_ptr, SL("a"), _0 TSRMLS_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _4 = ZEPHIR_IS_STRING_IDENTICAL(_1, "'"); + if (!(_4)) { + _5 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _4 = ZEPHIR_IS_STRING_IDENTICAL(_5, "\""); + } + if (_4) { + while (1) { + if (!(1)) { + break; + } + _6 = zephir_fetch_nproperty_this(this_ptr, SL("output"), PH_NOISY_CC); + _7 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_INIT_LNVAR(_2); + ZEPHIR_CONCAT_VV(_2, _6, _7); + zephir_update_property_this(this_ptr, SL("output"), _2 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", &_9, 0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("a"), _8 TSRMLS_CC); + _10 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("b"), PH_NOISY_CC); + if (ZEPHIR_IS_IDENTICAL(_10, _11)) { + break; + } + _12 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_CALL_FUNCTION(&_13, "ord", &_14, 69, _12); + zephir_check_call_status(); + if (ZEPHIR_LE_LONG(_13, 10)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Unterminated string literal.", "ice/filter/js.zep", 89); + return; + } + _15 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + if (ZEPHIR_IS_STRING_IDENTICAL(_15, "\\")) { + _16 = zephir_fetch_nproperty_this(this_ptr, SL("output"), PH_NOISY_CC); + _17 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_INIT_LNVAR(_18); + ZEPHIR_CONCAT_VV(_18, _16, _17); + zephir_update_property_this(this_ptr, SL("output"), _18 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_19, this_ptr, "get", &_9, 0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("a"), _19 TSRMLS_CC); + } + } + } + } + _4 = command == 1; + if (!(_4)) { + _4 = command == 2; + } + _20 = _4; + if (!(_20)) { + _20 = command == 3; + } + if (_20) { + ZEPHIR_CALL_METHOD(&_8, this_ptr, "next", &_21, 0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("b"), _8 TSRMLS_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("b"), PH_NOISY_CC); + _22 = ZEPHIR_IS_STRING_IDENTICAL(_0, "/"); + if (_22) { + _1 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _23 = ZEPHIR_IS_STRING_IDENTICAL(_1, "("); + if (!(_23)) { + _5 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _23 = ZEPHIR_IS_STRING_IDENTICAL(_5, ","); + } + _24 = _23; + if (!(_24)) { + _6 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _24 = ZEPHIR_IS_STRING_IDENTICAL(_6, "="); + } + _25 = _24; + if (!(_25)) { + _7 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _25 = ZEPHIR_IS_STRING_IDENTICAL(_7, ":"); + } + _26 = _25; + if (!(_26)) { + _10 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _26 = ZEPHIR_IS_STRING_IDENTICAL(_10, "["); + } + _27 = _26; + if (!(_27)) { + _11 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _27 = ZEPHIR_IS_STRING_IDENTICAL(_11, "!"); + } + _28 = _27; + if (!(_28)) { + _12 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _28 = ZEPHIR_IS_STRING_IDENTICAL(_12, "&"); + } + _29 = _28; + if (!(_29)) { + _15 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _29 = ZEPHIR_IS_STRING_IDENTICAL(_15, "|"); + } + _30 = _29; + if (!(_30)) { + _16 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _30 = ZEPHIR_IS_STRING_IDENTICAL(_16, "?"); + } + _31 = _30; + if (!(_31)) { + _17 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _31 = ZEPHIR_IS_STRING_IDENTICAL(_17, "{"); + } + _32 = _31; + if (!(_32)) { + _33 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _32 = ZEPHIR_IS_STRING_IDENTICAL(_33, "}"); + } + _34 = _32; + if (!(_34)) { + _35 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _34 = ZEPHIR_IS_STRING_IDENTICAL(_35, ";"); + } + _36 = _34; + if (!(_36)) { + _37 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _36 = ZEPHIR_IS_STRING_IDENTICAL(_37, "\n"); + } + _22 = _36; + } + if (_22) { + _38 = zephir_fetch_nproperty_this(this_ptr, SL("output"), PH_NOISY_CC); + _39 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _40 = zephir_fetch_nproperty_this(this_ptr, SL("b"), PH_NOISY_CC); + ZEPHIR_INIT_LNVAR(_2); + ZEPHIR_CONCAT_VVV(_2, _38, _39, _40); + zephir_update_property_this(this_ptr, SL("output"), _2 TSRMLS_CC); + while (1) { + if (!(1)) { + break; + } + ZEPHIR_CALL_METHOD(&_13, this_ptr, "get", &_9, 0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("a"), _13 TSRMLS_CC); + _41 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _42 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _43 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _44 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_CALL_FUNCTION(&_19, "ord", &_14, 69, _44); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING_IDENTICAL(_41, "[")) { + while (1) { + if (!(1)) { + break; + } + _45 = zephir_fetch_nproperty_this(this_ptr, SL("output"), PH_NOISY_CC); + _46 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_INIT_LNVAR(_18); + ZEPHIR_CONCAT_VV(_18, _45, _46); + zephir_update_property_this(this_ptr, SL("output"), _18 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_47, this_ptr, "get", &_9, 0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("a"), _47 TSRMLS_CC); + _48 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _49 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + _50 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_CALL_FUNCTION(&_51, "ord", &_14, 69, _50); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING_IDENTICAL(_48, "]")) { + break; + } else if (ZEPHIR_IS_STRING_IDENTICAL(_49, "\\")) { + _52 = zephir_fetch_nproperty_this(this_ptr, SL("output"), PH_NOISY_CC); + _53 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_INIT_LNVAR(_54); + ZEPHIR_CONCAT_VV(_54, _52, _53); + zephir_update_property_this(this_ptr, SL("output"), _54 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_55, this_ptr, "get", &_9, 0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("a"), _55 TSRMLS_CC); + } else if (ZEPHIR_LE_LONG(_51, 10)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Unterminated regular expression set in regex literal.", "ice/filter/js.zep", 129); + return; + } + } + } else if (ZEPHIR_IS_STRING_IDENTICAL(_42, "/")) { + break; + } else if (ZEPHIR_IS_STRING_IDENTICAL(_43, "\\")) { + _16 = zephir_fetch_nproperty_this(this_ptr, SL("output"), PH_NOISY_CC); + _17 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_INIT_LNVAR(_18); + ZEPHIR_CONCAT_VV(_18, _16, _17); + zephir_update_property_this(this_ptr, SL("output"), _18 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_19, this_ptr, "get", &_9, 0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("a"), _19 TSRMLS_CC); + } else if (ZEPHIR_LE_LONG(_19, 10)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Unterminated regular expression literal.", "ice/filter/js.zep", 138); + return; + } + _16 = zephir_fetch_nproperty_this(this_ptr, SL("output"), PH_NOISY_CC); + _17 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_INIT_LNVAR(_18); + ZEPHIR_CONCAT_VV(_18, _16, _17); + zephir_update_property_this(this_ptr, SL("output"), _18 TSRMLS_CC); + } + ZEPHIR_CALL_METHOD(&_8, this_ptr, "next", &_21, 0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("b"), _8 TSRMLS_CC); + } + } + ZEPHIR_MM_RESTORE(); + +} + +/** + * Get next char. Convert ctrl char to space. + * + * @return string|null + */ +PHP_METHOD(Ice_Filter_Js, get) { + + int ZEPHIR_LAST_CALL_STATUS; + zend_bool _6, _7; + zval *c = NULL, *i = NULL, *_0, *_1, *_2, *_3, _4, *_5, *_8 = NULL; + + ZEPHIR_MM_GROW(); + + ZEPHIR_OBS_VAR(c); + zephir_read_property_this(&c, this_ptr, SL("lookAhead"), PH_NOISY_CC); + zephir_update_property_this(this_ptr, SL("lookAhead"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC); + if (Z_TYPE_P(c) == IS_NULL) { + _0 = zephir_fetch_nproperty_this(this_ptr, SL("inputIndex"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("inputLength"), PH_NOISY_CC); + if (ZEPHIR_LT(_0, _1)) { + _2 = zephir_fetch_nproperty_this(this_ptr, SL("input"), PH_NOISY_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("inputIndex"), PH_NOISY_CC); + ZEPHIR_SINIT_VAR(_4); + ZVAL_LONG(&_4, 1); + ZEPHIR_INIT_NVAR(c); + zephir_substr(c, _2, zephir_get_intval(_3), 1 , 0); + ZEPHIR_OBS_VAR(i); + zephir_read_property_this(&i, this_ptr, SL("inputIndex"), PH_NOISY_CC); + ZEPHIR_INIT_ZVAL_NREF(_5); + ZVAL_LONG(_5, (zephir_get_numberval(i) + 1)); + zephir_update_property_this(this_ptr, SL("inputIndex"), _5 TSRMLS_CC); + } else { + ZEPHIR_INIT_NVAR(c); + ZVAL_NULL(c); + } + } + if (ZEPHIR_IS_STRING_IDENTICAL(c, "\r")) { + RETURN_MM_STRING("\n", 1); + } + _6 = Z_TYPE_P(c) == IS_NULL; + if (!(_6)) { + _6 = ZEPHIR_IS_STRING_IDENTICAL(c, "\n"); + } + _7 = _6; + if (!(_7)) { + ZEPHIR_CALL_FUNCTION(&_8, "ord", NULL, 69, c); + zephir_check_call_status(); + _7 = ZEPHIR_GE_LONG(_8, 32); + } + if (_7) { + RETURN_CCTOR(c); + } + RETURN_MM_STRING(" ", 1); + +} + +/** + * Is $c a letter, digit, underscore, dollar sign, or non-ASCII character. + * + * @return bool + */ +PHP_METHOD(Ice_Filter_Js, isAlphaNum) { + + zend_bool _1, _2; + int ZEPHIR_LAST_CALL_STATUS; + zval *c, *_0 = NULL, *_3, *_4, _5; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &c); + + + + ZEPHIR_CALL_FUNCTION(&_0, "ord", NULL, 69, c); + zephir_check_call_status(); + _1 = ZEPHIR_GT_LONG(_0, 126); + if (!(_1)) { + _1 = ZEPHIR_IS_STRING_IDENTICAL(c, "\\"); + } + _2 = _1; + if (!(_2)) { + ZEPHIR_INIT_VAR(_3); + ZEPHIR_INIT_VAR(_4); + ZEPHIR_SINIT_VAR(_5); + ZVAL_STRING(&_5, "/^[\\w\\$]$/", 0); + zephir_preg_match(_4, &_5, c, _3, 0, 0 , 0 TSRMLS_CC); + _2 = ZEPHIR_IS_LONG_IDENTICAL(_4, 1); + } + RETURN_MM_BOOL(_2); + +} + +/** + * Perform minification, return result + * + * @return string + */ +PHP_METHOD(Ice_Filter_Js, min) { + + zephir_fcall_cache_entry *_4 = NULL, *_7 = NULL, *_11 = NULL; + int ZEPHIR_LAST_CALL_STATUS; + zval *_0 = NULL, _1, _2, *_3 = NULL, *_5, *_6 = NULL, *_8, *_9 = NULL, *_10, *_12, *_13 = NULL, *_14; + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "peek", NULL, 0); + zephir_check_call_status(); + ZEPHIR_SINIT_VAR(_1); + ZVAL_STRING(&_1, "\\xef", 0); + ZEPHIR_SINIT_VAR(_2); + ZVAL_LONG(&_2, 1); + ZEPHIR_CALL_FUNCTION(&_3, "strncmp", NULL, 107, _0, &_1, &_2); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(_3, 0)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "get", &_4, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "get", &_4, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "get", &_4, 0); + zephir_check_call_status(); + } + ZEPHIR_INIT_ZVAL_NREF(_5); + ZVAL_STRING(_5, "\n", 1); + zephir_update_property_this(this_ptr, SL("a"), _5 TSRMLS_CC); + ZEPHIR_INIT_VAR(_6); + ZVAL_LONG(_6, 3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + while (1) { + _5 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + if (!(Z_TYPE_P(_5) != IS_NULL)) { + break; + } + _8 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + do { + if (ZEPHIR_IS_STRING(_8, " ")) { + _10 = zephir_fetch_nproperty_this(this_ptr, SL("b"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "isalphanum", &_11, 0, _10); + zephir_check_call_status(); + if (zephir_is_true(_9)) { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 2); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + } + break; + } + if (ZEPHIR_IS_STRING(_8, "\n")) { + _10 = zephir_fetch_nproperty_this(this_ptr, SL("b"), PH_NOISY_CC); + do { + if (ZEPHIR_IS_STRING(_10, "{") || ZEPHIR_IS_STRING(_10, "[") || ZEPHIR_IS_STRING(_10, "(") || ZEPHIR_IS_STRING(_10, "+") || ZEPHIR_IS_STRING(_10, "-") || ZEPHIR_IS_STRING(_10, "!") || ZEPHIR_IS_STRING(_10, "~")) { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_STRING(_10, " ")) { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + break; + } + _12 = zephir_fetch_nproperty_this(this_ptr, SL("b"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "isalphanum", &_11, 0, _12); + zephir_check_call_status(); + if (zephir_is_true(_9)) { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 2); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + } + } while(0); + + break; + } + _10 = zephir_fetch_nproperty_this(this_ptr, SL("b"), PH_NOISY_CC); + do { + if (ZEPHIR_IS_STRING(_10, " ")) { + _12 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "isalphanum", &_11, 0, _12); + zephir_check_call_status(); + if (zephir_is_true(_9)) { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + break; + } + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_STRING(_10, "\n")) { + _12 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + do { + if (ZEPHIR_IS_STRING(_12, "}") || ZEPHIR_IS_STRING(_12, "]") || ZEPHIR_IS_STRING(_12, ")") || ZEPHIR_IS_STRING(_12, "+") || ZEPHIR_IS_STRING(_12, "-") || ZEPHIR_IS_STRING(_12, "\"") || ZEPHIR_IS_STRING(_12, "'")) { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + break; + } + _14 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_13, this_ptr, "isalphanum", &_11, 0, _14); + zephir_check_call_status(); + if (zephir_is_true(_13)) { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + } + } while(0); + + break; + } + ZEPHIR_INIT_NVAR(_6); + ZVAL_LONG(_6, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "action", &_7, 0, _6); + zephir_check_call_status(); + break; + } while(0); + + } while(0); + } - RETURN_CTOR(min); + RETURN_MM_MEMBER(this_ptr, "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 + */ +PHP_METHOD(Ice_Filter_Js, next) { + + zephir_fcall_cache_entry *_0 = NULL, *_2 = NULL, *_4 = NULL; + int ZEPHIR_LAST_CALL_STATUS; + zval *c = NULL, *_1 = NULL, *_3 = NULL, *_5 = NULL; + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_METHOD(&c, this_ptr, "get", &_0, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING_IDENTICAL(c, "/")) { + ZEPHIR_CALL_METHOD(&_1, this_ptr, "peek", &_2, 0); + zephir_check_call_status(); + do { + if (ZEPHIR_IS_STRING(_1, "/")) { + while (1) { + if (!(1)) { + break; + } + ZEPHIR_CALL_METHOD(&c, this_ptr, "get", &_0, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_3, "ord", &_4, 69, c); + zephir_check_call_status(); + if (ZEPHIR_LE_LONG(_3, 10)) { + RETURN_CCTOR(c); + } + } + } + if (ZEPHIR_IS_STRING(_1, "*")) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "get", &_0, 0); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + ZEPHIR_CALL_METHOD(&_3, this_ptr, "get", &_0, 0); + zephir_check_call_status(); + do { + if (ZEPHIR_IS_STRING(_3, "*")) { + ZEPHIR_CALL_METHOD(&_5, this_ptr, "peek", &_2, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING_IDENTICAL(_5, "/")) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "get", &_0, 0); + zephir_check_call_status(); + RETURN_MM_STRING(" ", 1); + } + break; + } + if (Z_TYPE_P(_3) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Unterminated comment.", "ice/filter/js.zep", 312); + return; + } + } while(0); + + } + } + RETURN_CCTOR(c); + } while(0); + + } + RETURN_CCTOR(c); + +} + +/** + * Get next char. If is ctrl character, translate to a space or newline. + * + * @return string|null + */ +PHP_METHOD(Ice_Filter_Js, peek) { + + int ZEPHIR_LAST_CALL_STATUS; + zval *_0 = NULL; + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "get", NULL, 0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("lookAhead"), _0 TSRMLS_CC); + RETURN_MM_MEMBER(this_ptr, "lookAhead"); } diff --git a/ext/ice/filter/js.zep.h b/ext/ice/filter/js.zep.h index 91ff21bd..be4b6482 100644 --- a/ext/ice/filter/js.zep.h +++ b/ext/ice/filter/js.zep.h @@ -3,13 +3,35 @@ extern zend_class_entry *ice_filter_js_ce; ZEPHIR_INIT_CLASS(Ice_Filter_Js); +PHP_METHOD(Ice_Filter_Js, getOutput); PHP_METHOD(Ice_Filter_Js, sanitize); +PHP_METHOD(Ice_Filter_Js, action); +PHP_METHOD(Ice_Filter_Js, get); +PHP_METHOD(Ice_Filter_Js, isAlphaNum); +PHP_METHOD(Ice_Filter_Js, min); +PHP_METHOD(Ice_Filter_Js, next); +PHP_METHOD(Ice_Filter_Js, peek); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_filter_js_sanitize, 0, 0, 1) ZEND_ARG_INFO(0, js) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_filter_js_action, 0, 0, 1) + ZEND_ARG_INFO(0, command) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_filter_js_isalphanum, 0, 0, 1) + ZEND_ARG_INFO(0, c) +ZEND_END_ARG_INFO() + ZEPHIR_INIT_FUNCS(ice_filter_js_method_entry) { + PHP_ME(Ice_Filter_Js, getOutput, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Filter_Js, sanitize, arginfo_ice_filter_js_sanitize, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_ME(Ice_Filter_Js, action, arginfo_ice_filter_js_action, ZEND_ACC_PROTECTED) + PHP_ME(Ice_Filter_Js, get, NULL, ZEND_ACC_PROTECTED) + PHP_ME(Ice_Filter_Js, isAlphaNum, arginfo_ice_filter_js_isalphanum, ZEND_ACC_PROTECTED) + PHP_ME(Ice_Filter_Js, min, NULL, ZEND_ACC_PROTECTED) + PHP_ME(Ice_Filter_Js, next, NULL, ZEND_ACC_PROTECTED) + PHP_ME(Ice_Filter_Js, peek, NULL, ZEND_ACC_PROTECTED) + PHP_FE_END }; diff --git a/ext/ice/flash.zep.c b/ext/ice/flash.zep.c index f05db1bd..6cbdbc90 100644 --- a/ext/ice/flash.zep.c +++ b/ext/ice/flash.zep.c @@ -12,26 +12,37 @@ #include #include "kernel/main.h" +#include "kernel/fcall.h" #include "kernel/memory.h" -#include "kernel/array.h" #include "kernel/object.h" -#include "kernel/fcall.h" #include "kernel/operators.h" +#include "kernel/array.h" #include "ext/spl/spl_exceptions.h" #include "kernel/exception.h" #include "kernel/hash.h" #include "kernel/concat.h" + +/** + * Shows HTML notifications related to different circumstances. + * + * @package Ice/Flash + * @category Helper + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Flash) { ZEPHIR_REGISTER_CLASS(Ice, Flash, ice, flash, ice_flash_method_entry, 0); - zend_declare_property_null(ice_flash_ce, SL("_session"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_flash_ce, SL("session"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_flash_ce, SL("_tag"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_flash_ce, SL("tag"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_flash_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_flash_ce, SL("options"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_flash_ce->create_object = zephir_init_properties_Ice_Flash; return SUCCESS; } @@ -44,9 +55,9 @@ ZEPHIR_INIT_CLASS(Ice_Flash) { PHP_METHOD(Ice_Flash, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL; - zval *options_param = NULL, *di = NULL, *_3 = NULL, *_4 = NULL; - zval *options = NULL, *_0, *_1 = NULL; + zephir_fcall_cache_entry *_0 = NULL; + zval *options_param = NULL, *di = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5 = NULL; + zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options_param); @@ -59,37 +70,30 @@ PHP_METHOD(Ice_Flash, __construct) { } - ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 8); - add_assoc_stringl_ex(_0, SS("session_key"), SL("_flash"), 1); - ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 2); - add_assoc_stringl_ex(_1, SS("class"), SL("alert alert-success"), 1); - zephir_array_update_string(&_0, SL("success"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(_1); - array_init_size(_1, 2); - add_assoc_stringl_ex(_1, SS("class"), SL("alert alert-info"), 1); - zephir_array_update_string(&_0, SL("info"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(_1); - array_init_size(_1, 2); - add_assoc_stringl_ex(_1, SS("class"), SL("alert alert-warning"), 1); - zephir_array_update_string(&_0, SL("warning"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(_1); - array_init_size(_1, 2); - add_assoc_stringl_ex(_1, SS("class"), SL("alert alert-danger"), 1); - zephir_array_update_string(&_0, SL("danger"), &_1, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_0, SL("html"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); - zephir_update_property_this(this_ptr, SL("_options"), _0 TSRMLS_CC); - ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_2); + ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_0, 8); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, di, "getsession", NULL); + ZEPHIR_INIT_VAR(_2); + ZVAL_STRING(_2, "session", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_3); + ZVAL_NULL(_3); + ZEPHIR_INIT_VAR(_4); + ZVAL_BOOL(_4, 1); + ZEPHIR_CALL_METHOD(&_1, di, "get", NULL, 0, _2, _3, _4); + zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_session"), _3 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_4, di, "gettag", NULL); + zephir_update_property_this(this_ptr, SL("session"), _1 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_2); + ZVAL_STRING(_2, "tag", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_3); + ZVAL_NULL(_3); + ZEPHIR_INIT_NVAR(_4); + ZVAL_BOOL(_4, 1); + ZEPHIR_CALL_METHOD(&_5, di, "get", NULL, 27, _2, _3, _4); + zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_tag"), _4 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("tag"), _5 TSRMLS_CC); if (zephir_fast_count_int(options 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(); @@ -104,7 +108,7 @@ PHP_METHOD(Ice_Flash, __construct) { */ PHP_METHOD(Ice_Flash, getOption) { - zval *key_param = NULL, *defaultValue = NULL, *value, *_0; + zval *key_param = NULL, *defaultValue = NULL, *value = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); @@ -114,7 +118,6 @@ PHP_METHOD(Ice_Flash, getOption) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { @@ -126,7 +129,7 @@ PHP_METHOD(Ice_Flash, getOption) { } - _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_CTOR(value); } @@ -147,7 +150,7 @@ PHP_METHOD(Ice_Flash, getMessages) { HashTable *_3; HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; - zval *remove_param = NULL, *key = NULL, *type = NULL, *message = NULL, *messages = NULL, *body, *_0, *_1, **_4, *_5 = NULL, *_7; + zval *remove_param = NULL, *key = NULL, *type = NULL, *message = NULL, *messages = NULL, *body = NULL, *_0, *_1, **_4, *_5 = NULL, *_7; zend_bool remove; ZEPHIR_MM_GROW(); @@ -162,11 +165,11 @@ PHP_METHOD(Ice_Flash, getMessages) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "session_key", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&key, this_ptr, "getoption", NULL, _0); + ZEPHIR_CALL_METHOD(&key, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&messages, _1, "get", NULL, key); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&messages, _1, "get", NULL, 0, key); zephir_check_call_status(); ZEPHIR_INIT_VAR(body); ZVAL_STRING(body, "", 1); @@ -178,14 +181,14 @@ PHP_METHOD(Ice_Flash, getMessages) { ) { ZEPHIR_GET_HMKEY(type, _3, _2); ZEPHIR_GET_HVALUE(message, _4); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "getmessage", &_6, type, message); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getmessage", &_6, 0, type, message); zephir_check_call_status(); zephir_concat_self(&body, _5 TSRMLS_CC); } } if (remove) { - _7 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _7, "remove", NULL, key); + _7 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _7, "remove", NULL, 0, key); zephir_check_call_status(); } RETURN_CCTOR(body); @@ -201,12 +204,12 @@ PHP_METHOD(Ice_Flash, getMessages) { */ PHP_METHOD(Ice_Flash, getMessage) { - zephir_fcall_cache_entry *_8 = NULL; - HashTable *_5; - HashPosition _4; - zval *_2, *_11 = NULL, *_13 = NULL; + HashTable *_6; + HashPosition _5; + zval *_3, *_11 = NULL, *_13 = NULL; + zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *messages = NULL, *params = NULL, *body, *close = NULL, *message = NULL, *_0, *_1, *_3 = NULL, **_6, *_7 = NULL, *_9, *_10 = NULL, *_12 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL; + zval *type_param = NULL, *messages = NULL, *params = NULL, *body = NULL, *close = NULL, *message = NULL, *_0, *_2, *_4 = NULL, **_7, *_8 = NULL, *_9, *_10 = NULL, *_12 = NULL, *_14 = NULL, *_15 = NULL, *_16 = NULL; zval *type = NULL; ZEPHIR_MM_GROW(); @@ -218,68 +221,68 @@ PHP_METHOD(Ice_Flash, getMessage) { ZEPHIR_INIT_VAR(_0); array_init(_0); - ZEPHIR_CALL_METHOD(¶ms, this_ptr, "getoption", NULL, type, _0); + ZEPHIR_CALL_METHOD(¶ms, this_ptr, "getoption", &_1, 0, type, _0); zephir_check_call_status(); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 4); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("tag"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_3); - ZVAL_STRING(_3, "#", 1); - zephir_array_fast_append(_2, _3); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "×", 1); - zephir_array_fast_append(_2, _3); - add_assoc_stringl_ex(_2, SS("class"), SL("close"), 1); - ZEPHIR_CALL_METHOD(&close, _1, "a", NULL, _2); + zephir_create_array(_3, 3, 0 TSRMLS_CC); + ZEPHIR_INIT_VAR(_4); + ZVAL_STRING(_4, "#", 1); + zephir_array_fast_append(_3, _4); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "×", 1); + zephir_array_fast_append(_3, _4); + add_assoc_stringl_ex(_3, SS("class"), SL("close"), 1); + ZEPHIR_CALL_METHOD(&close, _2, "a", NULL, 0, _3); zephir_check_call_status(); ZEPHIR_INIT_VAR(body); ZVAL_STRING(body, "", 1); if (Z_TYPE_P(messages) != IS_ARRAY) { ZEPHIR_INIT_NVAR(messages); - array_init_size(messages, 2); + zephir_create_array(messages, 1, 0 TSRMLS_CC); zephir_array_fast_append(messages, messages); } - zephir_is_iterable(messages, &_5, &_4, 0, 0, "ice/flash.zep", 116); + zephir_is_iterable(messages, &_6, &_5, 0, 0, "ice/flash.zep", 116); 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(_6, (void**) &_7, &_5) == SUCCESS + ; zephir_hash_move_forward_ex(_6, &_5) ) { - ZEPHIR_GET_HVALUE(message, _6); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "html", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_7, this_ptr, "getoption", &_8, _3); - zephir_check_temp_parameter(_3); + ZEPHIR_GET_HVALUE(message, _7); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "html", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "getoption", &_1, 0, _4); + zephir_check_temp_parameter(_4); zephir_check_call_status(); - if (zephir_is_true(_7)) { - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_tag"), PH_NOISY_CC); + if (zephir_is_true(_8)) { + _9 = zephir_fetch_nproperty_this(this_ptr, SL("tag"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_11); - array_init_size(_11, 2); + zephir_create_array(_11, 1, 0 TSRMLS_CC); ZEPHIR_INIT_LNVAR(_12); ZEPHIR_CONCAT_VV(_12, close, message); zephir_array_update_string(&_11, SL("content"), &_12, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_NVAR(_13); - array_init_size(_13, 2); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "content", 1); - zephir_array_fast_append(_13, _3); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "div", ZEPHIR_TEMP_PARAM_COPY); + zephir_create_array(_13, 1, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "content", 1); + zephir_array_fast_append(_13, _4); + ZEPHIR_INIT_NVAR(_4); + ZVAL_STRING(_4, "div", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_14); ZVAL_STRING(_14, "content", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_15); ZVAL_BOOL(_15, 1); ZEPHIR_INIT_NVAR(_16); ZVAL_BOOL(_16, 1); - ZEPHIR_CALL_METHOD(&_10, _9, "taghtml", NULL, _3, params, _11, _13, _14, _15, _16); - zephir_check_temp_parameter(_3); + ZEPHIR_CALL_METHOD(&_10, _9, "taghtml", NULL, 0, _4, params, _11, _13, _14, _15, _16); + zephir_check_temp_parameter(_4); zephir_check_temp_parameter(_14); zephir_check_call_status(); zephir_concat_self(&body, _10 TSRMLS_CC); } else { - ZEPHIR_INIT_NVAR(_3); - ZEPHIR_GET_CONSTANT(_3, "PHP_EOL"); + ZEPHIR_INIT_NVAR(_4); + ZEPHIR_GET_CONSTANT(_4, "PHP_EOL"); ZEPHIR_INIT_LNVAR(_12); - ZEPHIR_CONCAT_VV(_12, message, _3); + ZEPHIR_CONCAT_VV(_12, message, _4); zephir_concat_self(&body, _12 TSRMLS_CC); } } @@ -309,13 +312,13 @@ PHP_METHOD(Ice_Flash, message) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "session_key", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&key, this_ptr, "getoption", NULL, _0); + ZEPHIR_CALL_METHOD(&key, this_ptr, "getoption", NULL, 0, _0); zephir_check_temp_parameter(_0); zephir_check_call_status(); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_0); array_init(_0); - ZEPHIR_CALL_METHOD(&messages, _1, "get", NULL, key, _0); + ZEPHIR_CALL_METHOD(&messages, _1, "get", NULL, 0, key, _0); zephir_check_call_status(); if (!(zephir_array_isset(messages, type))) { ZEPHIR_INIT_VAR(_2); @@ -323,8 +326,8 @@ PHP_METHOD(Ice_Flash, message) { zephir_array_update_zval(&messages, type, &_2, PH_COPY | PH_SEPARATE); } zephir_array_update_multi(&messages, &message TSRMLS_CC, SL("za"), 2, type); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_session"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _3, "set", NULL, key, messages); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _3, "set", NULL, 0, key, messages); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -350,7 +353,7 @@ PHP_METHOD(Ice_Flash, success) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "success", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, _0, message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -374,7 +377,7 @@ PHP_METHOD(Ice_Flash, ok) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "success", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, _0, message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -401,7 +404,7 @@ PHP_METHOD(Ice_Flash, info) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "info", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, _0, message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -425,7 +428,7 @@ PHP_METHOD(Ice_Flash, notice) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "info", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, _0, message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -452,7 +455,7 @@ PHP_METHOD(Ice_Flash, warning) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "warning", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, _0, message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -476,7 +479,7 @@ PHP_METHOD(Ice_Flash, alert) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "warning", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, _0, message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -503,7 +506,7 @@ PHP_METHOD(Ice_Flash, danger) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "danger", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, _0, message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -527,10 +530,50 @@ PHP_METHOD(Ice_Flash, error) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "danger", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, _0, message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "message", NULL, 0, _0, message); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } +static zend_object_value zephir_init_properties_Ice_Flash(zend_class_entry *class_type TSRMLS_DC) { + + zval *_1, *_2 = NULL; + zval *_0; + + 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); + zephir_create_array(_1, 6, 0 TSRMLS_CC); + add_assoc_stringl_ex(_1, SS("session_key"), SL("_flash"), 1); + ZEPHIR_INIT_VAR(_2); + zephir_create_array(_2, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_2, SS("class"), SL("alert alert-success"), 1); + zephir_array_update_string(&_1, SL("success"), &_2, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(_2); + zephir_create_array(_2, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_2, SS("class"), SL("alert alert-info"), 1); + zephir_array_update_string(&_1, SL("info"), &_2, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(_2); + zephir_create_array(_2, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_2, SS("class"), SL("alert alert-warning"), 1); + zephir_array_update_string(&_1, SL("warning"), &_2, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(_2); + zephir_create_array(_2, 1, 0 TSRMLS_CC); + add_assoc_stringl_ex(_2, SS("class"), SL("alert alert-danger"), 1); + zephir_array_update_string(&_1, SL("danger"), &_2, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("html"), &ZEPHIR_GLOBAL(global_true), PH_COPY | PH_SEPARATE); + 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/flash.zep.h b/ext/ice/flash.zep.h index 1e5b384e..2f631ff5 100644 --- a/ext/ice/flash.zep.h +++ b/ext/ice/flash.zep.h @@ -16,6 +16,7 @@ PHP_METHOD(Ice_Flash, warning); PHP_METHOD(Ice_Flash, alert); PHP_METHOD(Ice_Flash, danger); PHP_METHOD(Ice_Flash, error); +static zend_object_value zephir_init_properties_Ice_Flash(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_flash___construct, 0, 0, 0) ZEND_ARG_ARRAY_INFO(0, options, 1) @@ -86,5 +87,5 @@ ZEPHIR_INIT_FUNCS(ice_flash_method_entry) { PHP_ME(Ice_Flash, alert, arginfo_ice_flash_alert, ZEND_ACC_PUBLIC) PHP_ME(Ice_Flash, danger, arginfo_ice_flash_danger, ZEND_ACC_PUBLIC) PHP_ME(Ice_Flash, error, arginfo_ice_flash_error, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/http/request.zep.c b/ext/ice/http/request.zep.c index 0b7819e2..f085c0bc 100644 --- a/ext/ice/http/request.zep.c +++ b/ext/ice/http/request.zep.c @@ -33,13 +33,13 @@ ZEPHIR_INIT_CLASS(Ice_Http_Request) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Http, Request, ice, http_request, ice_arr_ce, ice_http_request_method_entry, 0); - zend_declare_property_null(ice_http_request_ce, SL("_files"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_http_request_ce, SL("files"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_http_request_ce, SL("_get"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_http_request_ce, SL("get"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_http_request_ce, SL("_post"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_http_request_ce, SL("post"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_http_request_ce, SL("_server"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_http_request_ce, SL("server"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -50,39 +50,38 @@ ZEPHIR_INIT_CLASS(Ice_Http_Request) { */ PHP_METHOD(Ice_Http_Request, __construct) { - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL; - zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL, *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *_0, *_FILES, *_2, *_GET, *_3, *_POST, *_4, *_SERVER, *_REQUEST; ZEPHIR_MM_GROW(); + zephir_get_global(&_REQUEST, SS("_REQUEST") TSRMLS_CC); + zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); + zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); + zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); + zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); ZEPHIR_INIT_VAR(_0); object_init_ex(_0, ice_arr_ce); - zephir_get_global(&_FILES, SS("_FILES") TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_1, _FILES); + ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_1, 6, _FILES); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_files"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("files"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); object_init_ex(_2, ice_arr_ce); - zephir_get_global(&_GET, SS("_GET") TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_1, _GET); + ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_1, 6, _GET); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_get"), _2 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("get"), _2 TSRMLS_CC); ZEPHIR_INIT_VAR(_3); object_init_ex(_3, ice_arr_ce); - zephir_get_global(&_POST, SS("_POST") TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_1, _POST); + ZEPHIR_CALL_METHOD(NULL, _3, "__construct", &_1, 6, _POST); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_post"), _3 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("post"), _3 TSRMLS_CC); ZEPHIR_INIT_VAR(_4); object_init_ex(_4, ice_arr_ce); - zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_1, _SERVER); + ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_1, 6, _SERVER); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_server"), _4 TSRMLS_CC); - zephir_get_global(&_REQUEST, SS("_REQUEST") TSRMLS_CC); - ZEPHIR_CALL_PARENT(NULL, ice_http_request_ce, this_ptr, "__construct", &_5, _REQUEST); + zephir_update_property_this(this_ptr, SL("server"), _4 TSRMLS_CC); + ZEPHIR_CALL_PARENT(NULL, ice_http_request_ce, this_ptr, "__construct", &_5, 6, _REQUEST); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -107,7 +106,6 @@ PHP_METHOD(Ice_Http_Request, hasRequest) { 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 { @@ -116,7 +114,7 @@ PHP_METHOD(Ice_Http_Request, hasRequest) { } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, name); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); @@ -141,7 +139,6 @@ PHP_METHOD(Ice_Http_Request, hasPost) { 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 { @@ -150,8 +147,8 @@ PHP_METHOD(Ice_Http_Request, hasPost) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_post"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, name); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("post"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); @@ -176,7 +173,6 @@ PHP_METHOD(Ice_Http_Request, hasGet) { 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 { @@ -185,8 +181,8 @@ PHP_METHOD(Ice_Http_Request, hasGet) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_get"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, name); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("get"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); @@ -211,7 +207,6 @@ PHP_METHOD(Ice_Http_Request, hasServer) { 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 { @@ -220,8 +215,8 @@ PHP_METHOD(Ice_Http_Request, hasServer) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_server"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, name); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("server"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); @@ -246,7 +241,6 @@ PHP_METHOD(Ice_Http_Request, hasFile) { 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 { @@ -255,8 +249,8 @@ PHP_METHOD(Ice_Http_Request, hasFile) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_files"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, name); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("files"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); @@ -274,7 +268,7 @@ PHP_METHOD(Ice_Http_Request, isPost) { ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "POST")); @@ -292,7 +286,7 @@ PHP_METHOD(Ice_Http_Request, isGet) { ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "GET")); @@ -310,7 +304,7 @@ PHP_METHOD(Ice_Http_Request, isPut) { ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "PUT")); @@ -328,7 +322,7 @@ PHP_METHOD(Ice_Http_Request, isPatch) { ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "PATCH")); @@ -346,7 +340,7 @@ PHP_METHOD(Ice_Http_Request, isHead) { ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "HEAD")); @@ -364,7 +358,7 @@ PHP_METHOD(Ice_Http_Request, isDelete) { ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "DELETE")); @@ -382,7 +376,7 @@ PHP_METHOD(Ice_Http_Request, isOptions) { ZEPHIR_MM_GROW(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 0); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "OPTIONS")); @@ -400,10 +394,10 @@ PHP_METHOD(Ice_Http_Request, isAjax) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_server"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("server"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "HTTP_X_REQUESTED_WITH", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&_1, _0, "get", NULL, _2); + ZEPHIR_CALL_METHOD(&_1, _0, "get", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); RETURN_MM_BOOL(ZEPHIR_IS_STRING(_1, "XMLHttpRequest")); @@ -422,12 +416,12 @@ PHP_METHOD(Ice_Http_Request, getMethod) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_server"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("server"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "REQUEST_METHOD", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, _1, _2); + ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, _1, _2); zephir_check_temp_parameter(_1); zephir_check_temp_parameter(_2); zephir_check_call_status(); @@ -447,12 +441,12 @@ PHP_METHOD(Ice_Http_Request, getUserAgent) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_server"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("server"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "HTTP_USER_AGENT", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, _1, _2); + ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, _1, _2); zephir_check_temp_parameter(_1); zephir_check_temp_parameter(_2); zephir_check_call_status(); @@ -472,12 +466,12 @@ PHP_METHOD(Ice_Http_Request, getHTTPReferer) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_server"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("server"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "HTTP_REFERER", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, _1, _2); + ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, _1, _2); zephir_check_temp_parameter(_1); zephir_check_temp_parameter(_2); zephir_check_call_status(); @@ -497,31 +491,31 @@ PHP_METHOD(Ice_Http_Request, getClientAddress) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_server"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("server"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "HTTP_CLIENT_IP", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&client, _0, "get", NULL, _1); + ZEPHIR_CALL_METHOD(&client, _0, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_server"), PH_NOISY_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("server"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "HTTP_X_FORWARDED_FOR", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&forward, _2, "get", NULL, _1); + ZEPHIR_CALL_METHOD(&forward, _2, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_server"), PH_NOISY_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("server"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "REMOTE_ADDR", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&remote, _3, "get", NULL, _1); + ZEPHIR_CALL_METHOD(&remote, _3, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_4); ZVAL_LONG(&_4, 275); - ZEPHIR_CALL_FUNCTION(&_5, "filter_var", NULL, client, &_4); + ZEPHIR_CALL_FUNCTION(&_5, "filter_var", NULL, 104, client, &_4); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_4); ZVAL_LONG(&_4, 275); - ZEPHIR_CALL_FUNCTION(&_6, "filter_var", NULL, forward, &_4); + ZEPHIR_CALL_FUNCTION(&_6, "filter_var", NULL, 104, forward, &_4); zephir_check_call_status(); if (zephir_is_true(_5)) { ZEPHIR_CPY_WRT(ip, client); @@ -557,10 +551,10 @@ PHP_METHOD(Ice_Http_Request, getClientAddress) { */ PHP_METHOD(Ice_Http_Request, getQuery) { - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL; + zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zend_bool allowEmpty, _7, _8; - zval *key_param = NULL, *filters = NULL, *defaultValue = NULL, *allowEmpty_param = NULL, *value = NULL, *filter = NULL, *_0, *_1 = NULL, *_2, *_3, *_4 = NULL, *_6 = NULL; + zend_bool allowEmpty, _8, _9; + zval *key_param = NULL, *filters = NULL, *defaultValue = NULL, *allowEmpty_param = NULL, *value = NULL, *filter = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3, *_4 = NULL, *_6, *_7 = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); @@ -585,44 +579,51 @@ PHP_METHOD(Ice_Http_Request, getQuery) { } - if (!(key && Z_STRLEN_P(key))) { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_get"), PH_NOISY_CC); + if (!(!(!key) && Z_STRLEN_P(key))) { + _0 = zephir_fetch_nproperty_this(this_ptr, SL("get"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "_url", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2); ZVAL_NULL(_2); - ZEPHIR_CALL_METHOD(NULL, _0, "set", NULL, _1, _2); + ZEPHIR_CALL_METHOD(NULL, _0, "set", NULL, 0, _1, _2); zephir_check_temp_parameter(_1); zephir_check_call_status(); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_get"), PH_NOISY_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("get"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "_url", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _3, "remove", NULL, _1); + ZEPHIR_CALL_METHOD(NULL, _3, "remove", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); - RETURN_MM_MEMBER(this_ptr, "_get"); + RETURN_MM_MEMBER(this_ptr, "get"); } else { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_get"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&value, _0, "get", NULL, key, defaultValue); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("get"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&value, _0, "get", NULL, 0, key, defaultValue); zephir_check_call_status(); if (zephir_is_true(filters)) { - ZEPHIR_CALL_CE_STATIC(&_4, ice_di_ce, "fetch", &_5); + ZEPHIR_CALL_CE_STATIC(&_4, ice_di_ce, "fetch", &_5, 8); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&filter, _4, "getfilter", NULL); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "filter", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_2); + ZVAL_NULL(_2); + ZEPHIR_INIT_VAR(_6); + ZVAL_BOOL(_6, 1); + ZEPHIR_CALL_METHOD(&filter, _4, "get", NULL, 0, _1, _2, _6); + zephir_check_temp_parameter(_1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6, filter, "sanitize", NULL, value, filters); + ZEPHIR_CALL_METHOD(&_7, filter, "sanitize", NULL, 0, value, filters); zephir_check_call_status(); - ZEPHIR_CPY_WRT(value, _6); + ZEPHIR_CPY_WRT(value, _7); } - _7 = ZEPHIR_IS_STRING_IDENTICAL(value, ""); - if (!(_7)) { - _7 = Z_TYPE_P(value) == IS_NULL; + _8 = ZEPHIR_IS_STRING_IDENTICAL(value, ""); + if (!(_8)) { + _8 = Z_TYPE_P(value) == IS_NULL; } - _8 = _7; - if (_8) { - _8 = allowEmpty == 0; + _9 = _8; + if (_9) { + _9 = allowEmpty == 0; } - if (_8) { + if (_9) { RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } @@ -655,10 +656,10 @@ PHP_METHOD(Ice_Http_Request, getQuery) { */ PHP_METHOD(Ice_Http_Request, getPost) { - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL; + zephir_fcall_cache_entry *_2 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zend_bool allowEmpty, _4, _5; - zval *key_param = NULL, *filters = NULL, *defaultValue = NULL, *allowEmpty_param = NULL, *value = NULL, *filter = NULL, *_0, *_1 = NULL, *_3 = NULL; + zend_bool allowEmpty, _7, _8; + zval *key_param = NULL, *filters = NULL, *defaultValue = NULL, *allowEmpty_param = NULL, *value = NULL, *filter = NULL, *_0, *_1 = NULL, *_3, *_4, *_5, *_6 = NULL; zval *key = NULL; ZEPHIR_MM_GROW(); @@ -683,30 +684,37 @@ PHP_METHOD(Ice_Http_Request, getPost) { } - if (!(key && Z_STRLEN_P(key))) { - RETURN_MM_MEMBER(this_ptr, "_post"); + if (!(!(!key) && Z_STRLEN_P(key))) { + RETURN_MM_MEMBER(this_ptr, "post"); } else { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_post"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&value, _0, "get", NULL, key, defaultValue); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("post"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&value, _0, "get", NULL, 0, key, defaultValue); zephir_check_call_status(); if (zephir_is_true(filters)) { - ZEPHIR_CALL_CE_STATIC(&_1, ice_di_ce, "fetch", &_2); + ZEPHIR_CALL_CE_STATIC(&_1, ice_di_ce, "fetch", &_2, 8); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&filter, _1, "getfilter", NULL); + ZEPHIR_INIT_VAR(_3); + ZVAL_STRING(_3, "filter", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_4); + ZVAL_NULL(_4); + ZEPHIR_INIT_VAR(_5); + ZVAL_BOOL(_5, 1); + ZEPHIR_CALL_METHOD(&filter, _1, "get", NULL, 0, _3, _4, _5); + zephir_check_temp_parameter(_3); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, filter, "sanitize", NULL, value, filters); + ZEPHIR_CALL_METHOD(&_6, filter, "sanitize", NULL, 0, value, filters); zephir_check_call_status(); - ZEPHIR_CPY_WRT(value, _3); + ZEPHIR_CPY_WRT(value, _6); } - _4 = ZEPHIR_IS_STRING_IDENTICAL(value, ""); - if (!(_4)) { - _4 = Z_TYPE_P(value) == IS_NULL; + _7 = ZEPHIR_IS_STRING_IDENTICAL(value, ""); + if (!(_7)) { + _7 = Z_TYPE_P(value) == IS_NULL; } - _5 = _4; - if (_5) { - _5 = allowEmpty == 0; + _8 = _7; + if (_8) { + _8 = allowEmpty == 0; } - if (_5) { + if (_8) { RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } @@ -744,12 +752,12 @@ PHP_METHOD(Ice_Http_Request, getServer) { ZEPHIR_INIT_VAR(_0); - if (key && Z_STRLEN_P(key)) { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_server"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_0, _1, "get", NULL, key, defaultValue); + if (!(!key) && Z_STRLEN_P(key)) { + _1 = zephir_fetch_nproperty_this(this_ptr, SL("server"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_0, _1, "get", NULL, 0, key, defaultValue); zephir_check_call_status(); } else { - zephir_read_property_this(&_0, this_ptr, SL("_server"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("server"), PH_NOISY_CC); } RETURN_CCTOR(_0); @@ -783,12 +791,12 @@ PHP_METHOD(Ice_Http_Request, getFiles) { ZEPHIR_INIT_VAR(_0); - if (key && Z_STRLEN_P(key)) { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_files"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_0, _1, "get", NULL, key, defaultValue); + if (!(!key) && Z_STRLEN_P(key)) { + _1 = zephir_fetch_nproperty_this(this_ptr, SL("files"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_0, _1, "get", NULL, 0, key, defaultValue); zephir_check_call_status(); } else { - zephir_read_property_this(&_0, this_ptr, SL("_files"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("files"), PH_NOISY_CC); } RETURN_CCTOR(_0); diff --git a/ext/ice/http/request.zep.h b/ext/ice/http/request.zep.h index bcf6cb7e..2329a420 100644 --- a/ext/ice/http/request.zep.h +++ b/ext/ice/http/request.zep.h @@ -93,5 +93,5 @@ ZEPHIR_INIT_FUNCS(ice_http_request_method_entry) { PHP_ME(Ice_Http_Request, getPost, arginfo_ice_http_request_getpost, ZEND_ACC_PUBLIC) PHP_ME(Ice_Http_Request, getServer, arginfo_ice_http_request_getserver, ZEND_ACC_PUBLIC) PHP_ME(Ice_Http_Request, getFiles, arginfo_ice_http_request_getfiles, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/http/request/requestinterface.zep.h b/ext/ice/http/request/requestinterface.zep.h index 79a5c845..776e671d 100644 --- a/ext/ice/http/request/requestinterface.zep.h +++ b/ext/ice/http/request/requestinterface.zep.h @@ -58,5 +58,5 @@ ZEPHIR_INIT_FUNCS(ice_http_request_requestinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Http_Request_RequestInterface, request, arginfo_ice_http_request_requestinterface_request) PHP_ABSTRACT_ME(Ice_Http_Request_RequestInterface, post, arginfo_ice_http_request_requestinterface_post) PHP_ABSTRACT_ME(Ice_Http_Request_RequestInterface, server, arginfo_ice_http_request_requestinterface_server) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/http/response.zep.c b/ext/ice/http/response.zep.c index 53c353d7..fa265014 100644 --- a/ext/ice/http/response.zep.c +++ b/ext/ice/http/response.zep.c @@ -19,21 +19,33 @@ #include "kernel/array.h" #include "kernel/string.h" + +/** + * This class provides a simple interface around the HTTP response. + * + * @package Ice/Http + * @category Component + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Http_Response) { ZEPHIR_REGISTER_CLASS(Ice\\Http, Response, ice, http_response, ice_http_response_method_entry, 0); - zend_declare_property_null(ice_http_response_ce, SL("_di"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_http_response_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_string(ice_http_response_ce, SL("protocolVersion"), "HTTP/1.1", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_http_response_ce, SL("_protocolVersion"), "HTTP/1.1", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_long(ice_http_response_ce, SL("status"), 200, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_long(ice_http_response_ce, SL("_status"), 200, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_http_response_ce, SL("headers"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_http_response_ce, SL("_headers"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_http_response_ce, SL("body"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_http_response_ce, SL("_body"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_http_response_ce, SL("messages"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_http_response_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_http_response_ce->create_object = zephir_init_properties_Ice_Http_Response; zend_class_implements(ice_http_response_ce TSRMLS_CC, 1, ice_http_response_responseinterface_ce); return SUCCESS; @@ -43,7 +55,7 @@ ZEPHIR_INIT_CLASS(Ice_Http_Response) { PHP_METHOD(Ice_Http_Response, getProtocolVersion) { - RETURN_MEMBER(this_ptr, "_protocolVersion"); + RETURN_MEMBER(this_ptr, "protocolVersion"); } @@ -55,14 +67,14 @@ PHP_METHOD(Ice_Http_Response, setProtocolVersion) { - zephir_update_property_this(this_ptr, SL("_protocolVersion"), protocolVersion TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("protocolVersion"), protocolVersion TSRMLS_CC); } PHP_METHOD(Ice_Http_Response, getStatus) { - RETURN_MEMBER(this_ptr, "_status"); + RETURN_MEMBER(this_ptr, "status"); } @@ -74,14 +86,14 @@ PHP_METHOD(Ice_Http_Response, setStatus) { - zephir_update_property_this(this_ptr, SL("_status"), status TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("status"), status TSRMLS_CC); } PHP_METHOD(Ice_Http_Response, getBody) { - RETURN_MEMBER(this_ptr, "_body"); + RETURN_MEMBER(this_ptr, "body"); } @@ -93,14 +105,14 @@ PHP_METHOD(Ice_Http_Response, setBody) { - zephir_update_property_this(this_ptr, SL("_body"), body TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("body"), body TSRMLS_CC); } PHP_METHOD(Ice_Http_Response, getMessages) { - RETURN_MEMBER(this_ptr, "_messages"); + RETURN_MEMBER(this_ptr, "messages"); } @@ -112,10 +124,9 @@ PHP_METHOD(Ice_Http_Response, getMessages) { */ PHP_METHOD(Ice_Http_Response, __construct) { - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL; - zval *_0; + zephir_fcall_cache_entry *_1 = NULL; int status, ZEPHIR_LAST_CALL_STATUS; - zval *body_param = NULL, *status_param = NULL, *_1 = NULL, *_3, *_4, *_5, *_6; + zval *body_param = NULL, *status_param = NULL, *_0 = NULL, *_2, *_3, *_4, *_5; zval *body = NULL; ZEPHIR_MM_GROW(); @@ -134,89 +145,26 @@ PHP_METHOD(Ice_Http_Response, __construct) { } - ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 76); - add_index_stringl(_0, 100, SL("Continue"), 1); - add_index_stringl(_0, 101, SL("Switching Protocols"), 1); - add_index_stringl(_0, 102, SL("Processing"), 1); - add_index_stringl(_0, 200, SL("OK"), 1); - add_index_stringl(_0, 201, SL("Created"), 1); - add_index_stringl(_0, 202, SL("Accepted"), 1); - add_index_stringl(_0, 203, SL("Non-Authoritative Information"), 1); - add_index_stringl(_0, 204, SL("No Content"), 1); - add_index_stringl(_0, 205, SL("Reset Content"), 1); - add_index_stringl(_0, 206, SL("Partial Content"), 1); - add_index_stringl(_0, 207, SL("Multi-Status"), 1); - add_index_stringl(_0, 208, SL("Already Reported"), 1); - add_index_stringl(_0, 226, SL("IM Used"), 1); - add_index_stringl(_0, 300, SL("Multiple Choices"), 1); - add_index_stringl(_0, 301, SL("Moved Permanently"), 1); - add_index_stringl(_0, 302, SL("Found"), 1); - add_index_stringl(_0, 303, SL("See Other"), 1); - add_index_stringl(_0, 304, SL("Not Modified"), 1); - add_index_stringl(_0, 305, SL("Use Proxy"), 1); - add_index_stringl(_0, 306, SL("(Unused)"), 1); - add_index_stringl(_0, 307, SL("Temporary Redirect"), 1); - add_index_stringl(_0, 308, SL("Permanent Redirect"), 1); - add_index_stringl(_0, 310, SL("Too Many Redirects"), 1); - add_index_stringl(_0, 400, SL("Bad Request"), 1); - add_index_stringl(_0, 401, SL("Unauthorized"), 1); - add_index_stringl(_0, 402, SL("Payment Required"), 1); - add_index_stringl(_0, 403, SL("Forbidden"), 1); - add_index_stringl(_0, 404, SL("Not Found"), 1); - add_index_stringl(_0, 405, SL("Method Not Allowed"), 1); - add_index_stringl(_0, 406, SL("Not Acceptable"), 1); - add_index_stringl(_0, 407, SL("Proxy Authentication Required"), 1); - add_index_stringl(_0, 408, SL("Request Timeout"), 1); - add_index_stringl(_0, 409, SL("Conflict"), 1); - add_index_stringl(_0, 410, SL("Gone"), 1); - add_index_stringl(_0, 411, SL("Length Required"), 1); - add_index_stringl(_0, 412, SL("Precondition Failed"), 1); - add_index_stringl(_0, 413, SL("Request Entity Too Large"), 1); - add_index_stringl(_0, 414, SL("Request-URI Too Long"), 1); - add_index_stringl(_0, 415, SL("Unsupported Media Type"), 1); - add_index_stringl(_0, 416, SL("Requested Range Not Satisfiable"), 1); - add_index_stringl(_0, 417, SL("Expectation Failed"), 1); - add_index_stringl(_0, 418, SL("I\"m a teapot"), 1); - add_index_stringl(_0, 422, SL("Unprocessable Entity"), 1); - add_index_stringl(_0, 423, SL("Locked"), 1); - add_index_stringl(_0, 424, SL("Failed Dependency"), 1); - add_index_stringl(_0, 426, SL("Upgrade Required"), 1); - add_index_stringl(_0, 428, SL("Precondition Required"), 1); - add_index_stringl(_0, 429, SL("Too Many Requests"), 1); - add_index_stringl(_0, 431, SL("Request Header Fields Too Large"), 1); - add_index_stringl(_0, 500, SL("Internal Server Error"), 1); - add_index_stringl(_0, 501, SL("Not Implemented"), 1); - add_index_stringl(_0, 502, SL("Bad Gateway"), 1); - add_index_stringl(_0, 503, SL("Service Unavailable"), 1); - add_index_stringl(_0, 504, SL("Gateway Timeout"), 1); - add_index_stringl(_0, 505, SL("HTTP Version Not Supported"), 1); - add_index_stringl(_0, 506, SL("Variant Also Negotiates"), 1); - add_index_stringl(_0, 507, SL("Insufficient Storage"), 1); - add_index_stringl(_0, 508, SL("Loop Detected"), 1); - add_index_stringl(_0, 510, SL("Not Extended"), 1); - add_index_stringl(_0, 511, SL("Network Authentication Required"), 1); - zephir_update_property_this(this_ptr, SL("_messages"), _0 TSRMLS_CC); - ZEPHIR_CALL_CE_STATIC(&_1, ice_di_ce, "fetch", &_2); + ZEPHIR_CALL_CE_STATIC(&_0, ice_di_ce, "fetch", &_1, 8); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_di"), _1 TSRMLS_CC); - ZEPHIR_INIT_VAR(_3); - object_init_ex(_3, ice_http_response_headers_ce); - ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL); + zephir_update_property_this(this_ptr, SL("di"), _0 TSRMLS_CC); + ZEPHIR_INIT_VAR(_2); + object_init_ex(_2, ice_http_response_headers_ce); + ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, 6); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_headers"), _3 TSRMLS_CC); - ZEPHIR_INIT_ZVAL_NREF(_4); - ZVAL_LONG(_4, status); - zephir_update_property_this(this_ptr, SL("_status"), _4 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_body"), body TSRMLS_CC); - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); + zephir_update_property_this(this_ptr, SL("headers"), _2 TSRMLS_CC); + ZEPHIR_INIT_ZVAL_NREF(_3); + ZVAL_LONG(_3, status); + zephir_update_property_this(this_ptr, SL("status"), _3 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("body"), body TSRMLS_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_4); + ZVAL_STRING(_4, "Content-Type", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_5); - ZVAL_STRING(_5, "Content-Type", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_INIT_VAR(_6); - ZVAL_STRING(_6, "text/html", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _4, "set", NULL, _5, _6); + ZVAL_STRING(_5, "text/html", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _3, "set", NULL, 0, _4, _5); + zephir_check_temp_parameter(_4); zephir_check_temp_parameter(_5); - zephir_check_temp_parameter(_6); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -234,8 +182,8 @@ PHP_METHOD(Ice_Http_Response, getHeaders) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "all", NULL); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "all", NULL, 0); zephir_check_call_status(); RETURN_MM(); @@ -259,8 +207,8 @@ PHP_METHOD(Ice_Http_Response, hasHeader) { zephir_get_strval(name, name_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, name); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "has", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); @@ -284,8 +232,8 @@ PHP_METHOD(Ice_Http_Response, getHeader) { zephir_get_strval(name, name_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, name); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "get", NULL, 0, name); zephir_check_call_status(); RETURN_MM(); @@ -310,8 +258,8 @@ PHP_METHOD(Ice_Http_Response, setHeader) { zephir_get_strval(value, value_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _0, "set", NULL, name, value); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _0, "set", NULL, 0, name, value); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -334,8 +282,8 @@ PHP_METHOD(Ice_Http_Response, setHeaders) { zephir_get_arrval(headers, headers_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _0, "replace", NULL, headers); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _0, "replace", NULL, 0, headers); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -358,13 +306,35 @@ PHP_METHOD(Ice_Http_Response, removeHeader) { zephir_get_strval(name, name_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _0, "remove", NULL, name); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _0, "remove", NULL, 0, name); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } +/** + * Set body content. + * + * @param string content + * @return object Response + */ +PHP_METHOD(Ice_Http_Response, setContent) { + + zval *contet_param = NULL; + zval *contet = NULL; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &contet_param); + + zephir_get_strval(contet, contet_param); + + + zephir_update_property_this(this_ptr, SL("body"), contet TSRMLS_CC); + RETURN_THIS(); + +} + /** * Finalize response for delivery to client. * Apply final preparations to the resposne object so that it is suitable for delivery to the client. @@ -376,7 +346,7 @@ PHP_METHOD(Ice_Http_Response, finalize) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; - zend_bool sendBody; + zend_bool sendBody = 0; zval *request, *_0, *_2 = NULL, *_3, *_4, *_5 = NULL; ZEPHIR_MM_GROW(); @@ -385,9 +355,9 @@ PHP_METHOD(Ice_Http_Response, finalize) { sendBody = 1; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 3); + zephir_create_array(_1, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 204); zephir_array_fast_append(_1, _2); @@ -395,21 +365,21 @@ PHP_METHOD(Ice_Http_Response, finalize) { ZVAL_LONG(_2, 304); zephir_array_fast_append(_1, _2); if (zephir_fast_in_array(_0, _1 TSRMLS_CC)) { - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "Content-Type", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _3, "remove", NULL, _2); + ZEPHIR_CALL_METHOD(NULL, _3, "remove", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_2); ZVAL_STRING(_2, "Content-Length", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _4, "remove", NULL, _2); + ZEPHIR_CALL_METHOD(NULL, _4, "remove", NULL, 0, _2); zephir_check_temp_parameter(_2); zephir_check_call_status(); sendBody = 0; } - ZEPHIR_CALL_METHOD(&_5, request, "ishead", NULL); + ZEPHIR_CALL_METHOD(&_5, request, "ishead", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_5)) { sendBody = 0; @@ -417,7 +387,7 @@ PHP_METHOD(Ice_Http_Response, finalize) { if (!(sendBody)) { ZEPHIR_INIT_ZVAL_NREF(_3); ZVAL_STRING(_3, "", 1); - zephir_update_property_this(this_ptr, SL("_body"), _3 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("body"), _3 TSRMLS_CC); } RETURN_THIS(); @@ -430,50 +400,50 @@ PHP_METHOD(Ice_Http_Response, finalize) { */ PHP_METHOD(Ice_Http_Response, send) { + zephir_fcall_cache_entry *_10 = NULL, *_11 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_11 = NULL, *_12 = NULL; - zval *_0 = NULL, *_2, _3, *_4, *_5, *_6, *_7, *_8 = NULL, _9 = zval_used_for_init, *_10 = NULL, *_13 = NULL; + zval *_0 = NULL, *_1, _2, *_3, *_4, *_5, *_6, *_7 = NULL, _8 = zval_used_for_init, *_9 = NULL, *_12 = 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_INIT_VAR(_2); - ZEPHIR_GET_CONSTANT(_2, "PHP_SAPI"); - ZEPHIR_SINIT_VAR(_3); - ZVAL_STRING(&_3, "cgi", 0); - ZEPHIR_INIT_VAR(_4); - zephir_fast_strpos(_4, _2, &_3, 0 ); - if (ZEPHIR_IS_LONG_IDENTICAL(_4, 0)) { - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); - _6 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); - ZEPHIR_OBS_VAR(_8); - zephir_read_property_this(&_8, this_ptr, SL("_status"), PH_NOISY_CC); - zephir_array_fetch(&_7, _6, _8, PH_NOISY | PH_READONLY, "ice/http/response.zep", 216 TSRMLS_CC); - ZEPHIR_SINIT_VAR(_9); - ZVAL_STRING(&_9, "Status: %d %s", 0); - ZEPHIR_CALL_FUNCTION(&_10, "sprintf", &_11, &_9, _5, _7); + ZEPHIR_INIT_VAR(_1); + ZEPHIR_GET_CONSTANT(_1, "PHP_SAPI"); + ZEPHIR_SINIT_VAR(_2); + ZVAL_STRING(&_2, "cgi", 0); + ZEPHIR_INIT_VAR(_3); + zephir_fast_strpos(_3, _1, &_2, 0 ); + if (ZEPHIR_IS_LONG_IDENTICAL(_3, 0)) { + _4 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC); + ZEPHIR_OBS_VAR(_7); + zephir_read_property_this(&_7, this_ptr, SL("status"), PH_NOISY_CC); + zephir_array_fetch(&_6, _5, _7, PH_NOISY | PH_READONLY, "ice/http/response.zep", 229 TSRMLS_CC); + ZEPHIR_SINIT_VAR(_8); + ZVAL_STRING(&_8, "Status: %d %s", 0); + ZEPHIR_CALL_FUNCTION(&_9, "sprintf", &_10, 1, &_8, _4, _6); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "header", &_12, _10); + ZEPHIR_CALL_FUNCTION(NULL, "header", &_11, 109, _9); zephir_check_call_status(); } else { - ZEPHIR_CALL_METHOD(&_10, this_ptr, "getprotocolversion", NULL); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "getprotocolversion", NULL, 0); zephir_check_call_status(); - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); - _6 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); - ZEPHIR_OBS_NVAR(_8); - zephir_read_property_this(&_8, this_ptr, SL("_status"), PH_NOISY_CC); - zephir_array_fetch(&_7, _6, _8, PH_NOISY | PH_READONLY, "ice/http/response.zep", 218 TSRMLS_CC); - ZEPHIR_SINIT_NVAR(_9); - ZVAL_STRING(&_9, "%s %d %s", 0); - ZEPHIR_CALL_FUNCTION(&_13, "sprintf", &_11, &_9, _10, _5, _7); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC); + ZEPHIR_OBS_NVAR(_7); + zephir_read_property_this(&_7, this_ptr, SL("status"), PH_NOISY_CC); + zephir_array_fetch(&_6, _5, _7, PH_NOISY | PH_READONLY, "ice/http/response.zep", 231 TSRMLS_CC); + ZEPHIR_SINIT_NVAR(_8); + ZVAL_STRING(&_8, "%s %d %s", 0); + ZEPHIR_CALL_FUNCTION(&_12, "sprintf", &_10, 1, &_8, _9, _4, _6); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "header", &_12, _13); + ZEPHIR_CALL_FUNCTION(NULL, "header", &_11, 109, _12); zephir_check_call_status(); } - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _5, "send", NULL); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _4, "send", NULL, 0); zephir_check_call_status(); } RETURN_THIS(); @@ -486,12 +456,13 @@ PHP_METHOD(Ice_Http_Response, send) { * * @param string location The redirect destination * @param int status The redirect HTTP status code + * @return object this */ PHP_METHOD(Ice_Http_Response, redirect) { zend_bool external; int status, ZEPHIR_LAST_CALL_STATUS; - zval *location_param = NULL, *status_param = NULL, *external_param = NULL, *url = NULL, *_0 = NULL, *_1, *_2 = NULL; + zval *location_param = NULL, *status_param = NULL, *external_param = NULL, *url = NULL, *_0 = NULL, *_1, *_2, *_3, *_4 = NULL; zval *location = NULL; ZEPHIR_MM_GROW(); @@ -517,23 +488,30 @@ PHP_METHOD(Ice_Http_Response, redirect) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, status); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatus", NULL, _0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatus", NULL, 0, _0); zephir_check_call_status(); if (!(external)) { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&url, _1, "geturl", NULL); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_NVAR(_0); + ZVAL_STRING(_0, "url", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_2); + ZVAL_NULL(_2); + ZEPHIR_INIT_VAR(_3); + ZVAL_BOOL(_3, 1); + ZEPHIR_CALL_METHOD(&url, _1, "get", NULL, 0, _0, _2, _3); + zephir_check_temp_parameter(_0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, url, "get", NULL, location); + ZEPHIR_CALL_METHOD(&_4, url, "get", NULL, 0, location); zephir_check_call_status(); - zephir_get_strval(location, _2); + zephir_get_strval(location, _4); } - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_headers"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("headers"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Location", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _1, "set", NULL, _0, location); + ZEPHIR_CALL_METHOD(NULL, _1, "set", NULL, 0, _0, location); zephir_check_temp_parameter(_0); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } @@ -549,9 +527,9 @@ PHP_METHOD(Ice_Http_Response, isEmpty) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 4); + zephir_create_array(_1, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 201); zephir_array_fast_append(_1, _2); @@ -576,10 +554,10 @@ PHP_METHOD(Ice_Http_Response, isInformational) { zval *_0, *_2; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_GE_LONG(_0, 100); if (_1) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_LT_LONG(_2, 200); } RETURN_BOOL(_1); @@ -596,7 +574,7 @@ PHP_METHOD(Ice_Http_Response, isOk) { zval *_0; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); RETURN_BOOL(ZEPHIR_IS_LONG_IDENTICAL(_0, 200)); } @@ -612,10 +590,10 @@ PHP_METHOD(Ice_Http_Response, isSuccessful) { zval *_0, *_2; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_GE_LONG(_0, 200); if (_1) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_LT_LONG(_2, 300); } RETURN_BOOL(_1); @@ -634,9 +612,9 @@ PHP_METHOD(Ice_Http_Response, isRedirect) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 6); + zephir_create_array(_1, 4, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_2); ZVAL_LONG(_2, 301); zephir_array_fast_append(_1, _2); @@ -664,10 +642,10 @@ PHP_METHOD(Ice_Http_Response, isRedirection) { zval *_0, *_2; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_GE_LONG(_0, 300); if (_1) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_LT_LONG(_2, 400); } RETURN_BOOL(_1); @@ -684,7 +662,7 @@ PHP_METHOD(Ice_Http_Response, isForbidden) { zval *_0; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); RETURN_BOOL(ZEPHIR_IS_LONG_IDENTICAL(_0, 403)); } @@ -699,7 +677,7 @@ PHP_METHOD(Ice_Http_Response, isNotFound) { zval *_0; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); RETURN_BOOL(ZEPHIR_IS_LONG_IDENTICAL(_0, 404)); } @@ -715,10 +693,10 @@ PHP_METHOD(Ice_Http_Response, isClientError) { zval *_0, *_2; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_GE_LONG(_0, 400); if (_1) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_LT_LONG(_2, 500); } RETURN_BOOL(_1); @@ -736,10 +714,10 @@ PHP_METHOD(Ice_Http_Response, isServerError) { zval *_0, *_2; - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_GE_LONG(_0, 500); if (_1) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_status"), PH_NOISY_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("status"), PH_NOISY_CC); _1 = ZEPHIR_LT_LONG(_2, 600); } RETURN_BOOL(_1); @@ -754,7 +732,7 @@ PHP_METHOD(Ice_Http_Response, isServerError) { */ PHP_METHOD(Ice_Http_Response, getMessage) { - zval *code_param = NULL, *message, *_0, *_1 = NULL; + zval *code_param = NULL, *message = NULL, *_0, *_1 = NULL; int code; ZEPHIR_MM_GROW(); @@ -767,7 +745,7 @@ PHP_METHOD(Ice_Http_Response, getMessage) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_messages"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC); zephir_array_isset_long_fetch(&message, _0, code, 1 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); if (zephir_is_true(message)) { @@ -787,7 +765,89 @@ PHP_METHOD(Ice_Http_Response, getMessage) { PHP_METHOD(Ice_Http_Response, __toString) { - RETURN_MEMBER(this_ptr, "_body"); + RETURN_MEMBER(this_ptr, "body"); + +} + +static zend_object_value zephir_init_properties_Ice_Http_Response(zend_class_entry *class_type TSRMLS_DC) { + + zval *_1; + zval *_0; + + ZEPHIR_MM_GROW(); + + { + zval *this_ptr = NULL; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + zephir_create_array(_1, 60, 0 TSRMLS_CC); + add_index_stringl(_1, 100, SL("Continue"), 1); + add_index_stringl(_1, 101, SL("Switching Protocols"), 1); + add_index_stringl(_1, 102, SL("Processing"), 1); + add_index_stringl(_1, 200, SL("OK"), 1); + add_index_stringl(_1, 201, SL("Created"), 1); + add_index_stringl(_1, 202, SL("Accepted"), 1); + add_index_stringl(_1, 203, SL("Non-Authoritative Information"), 1); + add_index_stringl(_1, 204, SL("No Content"), 1); + add_index_stringl(_1, 205, SL("Reset Content"), 1); + add_index_stringl(_1, 206, SL("Partial Content"), 1); + add_index_stringl(_1, 207, SL("Multi-Status"), 1); + add_index_stringl(_1, 208, SL("Already Reported"), 1); + add_index_stringl(_1, 226, SL("IM Used"), 1); + add_index_stringl(_1, 300, SL("Multiple Choices"), 1); + add_index_stringl(_1, 301, SL("Moved Permanently"), 1); + add_index_stringl(_1, 302, SL("Found"), 1); + add_index_stringl(_1, 303, SL("See Other"), 1); + add_index_stringl(_1, 304, SL("Not Modified"), 1); + add_index_stringl(_1, 305, SL("Use Proxy"), 1); + add_index_stringl(_1, 306, SL("(Unused)"), 1); + add_index_stringl(_1, 307, SL("Temporary Redirect"), 1); + add_index_stringl(_1, 308, SL("Permanent Redirect"), 1); + add_index_stringl(_1, 310, SL("Too Many Redirects"), 1); + add_index_stringl(_1, 400, SL("Bad Request"), 1); + add_index_stringl(_1, 401, SL("Unauthorized"), 1); + add_index_stringl(_1, 402, SL("Payment Required"), 1); + add_index_stringl(_1, 403, SL("Forbidden"), 1); + add_index_stringl(_1, 404, SL("Not Found"), 1); + add_index_stringl(_1, 405, SL("Method Not Allowed"), 1); + add_index_stringl(_1, 406, SL("Not Acceptable"), 1); + add_index_stringl(_1, 407, SL("Proxy Authentication Required"), 1); + add_index_stringl(_1, 408, SL("Request Timeout"), 1); + add_index_stringl(_1, 409, SL("Conflict"), 1); + add_index_stringl(_1, 410, SL("Gone"), 1); + add_index_stringl(_1, 411, SL("Length Required"), 1); + add_index_stringl(_1, 412, SL("Precondition Failed"), 1); + add_index_stringl(_1, 413, SL("Request Entity Too Large"), 1); + add_index_stringl(_1, 414, SL("Request-URI Too Long"), 1); + add_index_stringl(_1, 415, SL("Unsupported Media Type"), 1); + add_index_stringl(_1, 416, SL("Requested Range Not Satisfiable"), 1); + add_index_stringl(_1, 417, SL("Expectation Failed"), 1); + add_index_stringl(_1, 418, SL("I\"m a teapot"), 1); + add_index_stringl(_1, 422, SL("Unprocessable Entity"), 1); + add_index_stringl(_1, 423, SL("Locked"), 1); + add_index_stringl(_1, 424, SL("Failed Dependency"), 1); + add_index_stringl(_1, 426, SL("Upgrade Required"), 1); + add_index_stringl(_1, 428, SL("Precondition Required"), 1); + add_index_stringl(_1, 429, SL("Too Many Requests"), 1); + add_index_stringl(_1, 431, SL("Request Header Fields Too Large"), 1); + add_index_stringl(_1, 500, SL("Internal Server Error"), 1); + add_index_stringl(_1, 501, SL("Not Implemented"), 1); + add_index_stringl(_1, 502, SL("Bad Gateway"), 1); + add_index_stringl(_1, 503, SL("Service Unavailable"), 1); + add_index_stringl(_1, 504, SL("Gateway Timeout"), 1); + add_index_stringl(_1, 505, SL("HTTP Version Not Supported"), 1); + add_index_stringl(_1, 506, SL("Variant Also Negotiates"), 1); + add_index_stringl(_1, 507, SL("Insufficient Storage"), 1); + add_index_stringl(_1, 508, SL("Loop Detected"), 1); + add_index_stringl(_1, 510, SL("Not Extended"), 1); + add_index_stringl(_1, 511, SL("Network Authentication Required"), 1); + zephir_update_property_this(this_ptr, SL("messages"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } } diff --git a/ext/ice/http/response.zep.h b/ext/ice/http/response.zep.h index c7f4172e..dbd76546 100644 --- a/ext/ice/http/response.zep.h +++ b/ext/ice/http/response.zep.h @@ -17,6 +17,7 @@ PHP_METHOD(Ice_Http_Response, getHeader); PHP_METHOD(Ice_Http_Response, setHeader); PHP_METHOD(Ice_Http_Response, setHeaders); PHP_METHOD(Ice_Http_Response, removeHeader); +PHP_METHOD(Ice_Http_Response, setContent); PHP_METHOD(Ice_Http_Response, finalize); PHP_METHOD(Ice_Http_Response, send); PHP_METHOD(Ice_Http_Response, redirect); @@ -32,6 +33,7 @@ PHP_METHOD(Ice_Http_Response, isClientError); PHP_METHOD(Ice_Http_Response, isServerError); PHP_METHOD(Ice_Http_Response, getMessage); PHP_METHOD(Ice_Http_Response, __toString); +static zend_object_value zephir_init_properties_Ice_Http_Response(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_http_response_setprotocolversion, 0, 0, 1) ZEND_ARG_INFO(0, protocolVersion) @@ -71,6 +73,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_http_response_removeheader, 0, 0, 1) ZEND_ARG_INFO(0, name) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_http_response_setcontent, 0, 0, 1) + ZEND_ARG_INFO(0, contet) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_http_response_finalize, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, request, Ice\\Http\\Request\\RequestInterface, 0) ZEND_END_ARG_INFO() @@ -100,6 +106,7 @@ ZEPHIR_INIT_FUNCS(ice_http_response_method_entry) { PHP_ME(Ice_Http_Response, setHeader, arginfo_ice_http_response_setheader, ZEND_ACC_PUBLIC) PHP_ME(Ice_Http_Response, setHeaders, arginfo_ice_http_response_setheaders, ZEND_ACC_PUBLIC) PHP_ME(Ice_Http_Response, removeHeader, arginfo_ice_http_response_removeheader, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Http_Response, setContent, arginfo_ice_http_response_setcontent, ZEND_ACC_PUBLIC) PHP_ME(Ice_Http_Response, finalize, arginfo_ice_http_response_finalize, ZEND_ACC_PUBLIC) PHP_ME(Ice_Http_Response, send, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Http_Response, redirect, arginfo_ice_http_response_redirect, ZEND_ACC_PUBLIC) @@ -115,5 +122,5 @@ ZEPHIR_INIT_FUNCS(ice_http_response_method_entry) { PHP_ME(Ice_Http_Response, isServerError, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Http_Response, getMessage, arginfo_ice_http_response_getmessage, ZEND_ACC_PUBLIC) PHP_ME(Ice_Http_Response, __toString, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/http/response/headers.zep.c b/ext/ice/http/response/headers.zep.c index 898f22c5..58d3fb84 100644 --- a/ext/ice/http/response/headers.zep.c +++ b/ext/ice/http/response/headers.zep.c @@ -44,35 +44,36 @@ ZEPHIR_INIT_CLASS(Ice_Http_Response_Headers) { */ PHP_METHOD(Ice_Http_Response_Headers, send) { - zend_object_iterator *_2; + zephir_fcall_cache_entry *_3 = NULL; + zend_object_iterator *_1; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_4 = NULL; - zval *header = NULL, *value = NULL, *_0 = NULL, *_3 = NULL; + zval *header = NULL, *value = NULL, *_0 = NULL, *_2 = 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))) { - _2 = zephir_get_iterator(this_ptr TSRMLS_CC); - _2->funcs->rewind(_2 TSRMLS_CC); - for (;_2->funcs->valid(_2 TSRMLS_CC) == SUCCESS && !EG(exception); _2->funcs->move_forward(_2 TSRMLS_CC)) { - ZEPHIR_GET_IMKEY(header, _2); - { zval **tmp; - _2->funcs->get_current_data(_2, &tmp TSRMLS_CC); - value = *tmp; + _1 = zephir_get_iterator(this_ptr TSRMLS_CC); + _1->funcs->rewind(_1 TSRMLS_CC); + for (;_1->funcs->valid(_1 TSRMLS_CC) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1 TSRMLS_CC)) { + ZEPHIR_GET_IMKEY(header, _1); + { + zval **ZEPHIR_TMP_ITERATOR_PTR; + _1->funcs->get_current_data(_1, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); + ZEPHIR_CPY_WRT(value, (*ZEPHIR_TMP_ITERATOR_PTR)); } if (!(ZEPHIR_IS_EMPTY(value))) { - ZEPHIR_INIT_LNVAR(_3); - ZEPHIR_CONCAT_VSV(_3, header, ": ", value); - ZEPHIR_CALL_FUNCTION(NULL, "header", &_4, _3, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_INIT_LNVAR(_2); + ZEPHIR_CONCAT_VSV(_2, header, ": ", value); + ZEPHIR_CALL_FUNCTION(NULL, "header", &_3, 109, _2, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); } else { - ZEPHIR_CALL_FUNCTION(NULL, "header", &_4, header, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_CALL_FUNCTION(NULL, "header", &_3, 109, header, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); } } - _2->funcs->dtor(_2 TSRMLS_CC); + _1->funcs->dtor(_1 TSRMLS_CC); RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); diff --git a/ext/ice/http/response/headers.zep.h b/ext/ice/http/response/headers.zep.h index 743a5ba3..e2dfcc92 100644 --- a/ext/ice/http/response/headers.zep.h +++ b/ext/ice/http/response/headers.zep.h @@ -7,5 +7,5 @@ PHP_METHOD(Ice_Http_Response_Headers, send); ZEPHIR_INIT_FUNCS(ice_http_response_headers_method_entry) { PHP_ME(Ice_Http_Response_Headers, send, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/http/response/headersinterface.zep.h b/ext/ice/http/response/headersinterface.zep.h index 6f2cc234..847b4b10 100644 --- a/ext/ice/http/response/headersinterface.zep.h +++ b/ext/ice/http/response/headersinterface.zep.h @@ -5,5 +5,5 @@ ZEPHIR_INIT_CLASS(Ice_Http_Response_HeadersInterface); ZEPHIR_INIT_FUNCS(ice_http_response_headersinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Http_Response_HeadersInterface, send, NULL) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n.zep.c b/ext/ice/i18n.zep.c index 8897d234..d08a64c4 100644 --- a/ext/ice/i18n.zep.c +++ b/ext/ice/i18n.zep.c @@ -13,8 +13,8 @@ #include "kernel/main.h" #include "kernel/memory.h" -#include "kernel/object.h" #include "kernel/array.h" +#include "kernel/object.h" #include "kernel/operators.h" #include "kernel/string.h" #include "kernel/fcall.h" @@ -25,18 +25,32 @@ #include "ext/spl/spl_exceptions.h" #include "kernel/exception.h" + +/** + * Global alias of translate method. + */ +/** + * Internationalization (i18n) class. + * + * @package Ice/I18n + * @category Library + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_I18n) { ZEPHIR_REGISTER_CLASS(Ice, I18n, ice, i18n, ice_i18n_method_entry, 0); - zend_declare_property_null(ice_i18n_ce, SL("_i18n"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); + zend_declare_property_null(ice_i18n_ce, SL("i18n"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); - zend_declare_property_null(ice_i18n_ce, SL("_cache"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_i18n_ce, SL("cache"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_i18n_ce, SL("_rules"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_i18n_ce, SL("rules"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_i18n_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_i18n_ce, SL("options"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_i18n_ce->create_object = zephir_init_properties_Ice_I18n; return SUCCESS; } @@ -48,8 +62,8 @@ ZEPHIR_INIT_CLASS(Ice_I18n) { */ PHP_METHOD(Ice_I18n, __construct) { - zval *options_param = NULL, *_1, *_2, *_3, *_4; - zval *options = NULL, *_0; + zval *options_param = NULL, *_0, *_1; + zval *options = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &options_param); @@ -63,22 +77,10 @@ PHP_METHOD(Ice_I18n, __construct) { ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 4); - add_assoc_stringl_ex(_0, SS("source"), SL("en-gb"), 1); - add_assoc_stringl_ex(_0, SS("lang"), SL("en-gb"), 1); - add_assoc_stringl_ex(_0, SS("dir"), SL(""), 1); - zephir_update_property_this(this_ptr, SL("_options"), _0 TSRMLS_CC); - ZEPHIR_INIT_VAR(_1); - array_init(_1); - zephir_update_property_this(this_ptr, SL("_rules"), _1 TSRMLS_CC); - ZEPHIR_INIT_VAR(_2); - array_init(_2); - zephir_update_property_this(this_ptr, SL("_cache"), _2 TSRMLS_CC); - ZEPHIR_INIT_VAR(_3); - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); - zephir_fast_array_merge(_3, &(_4), &(options) TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_options"), _3 TSRMLS_CC); - zephir_update_static_property_ce(ice_i18n_ce, SL("_i18n"), &this_ptr TSRMLS_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC); + zephir_fast_array_merge(_0, &(_1), &(options) TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("options"), _0 TSRMLS_CC); + zephir_update_static_property_ce(ice_i18n_ce, SL("i18n"), &this_ptr TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -93,7 +95,7 @@ PHP_METHOD(Ice_I18n, fetch) { zval *_0; - _0 = zephir_fetch_static_property_ce(ice_i18n_ce, SL("_i18n") TSRMLS_CC); + _0 = zephir_fetch_static_property_ce(ice_i18n_ce, SL("i18n") TSRMLS_CC); RETURN_CTORW(_0); } @@ -120,21 +122,21 @@ PHP_METHOD(Ice_I18n, lang) { } - if (lang && Z_STRLEN_P(lang)) { + if (!(!lang) && Z_STRLEN_P(lang)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_VAR(_1); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "_", 0); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "-", 0); - zephir_fast_str_replace(_1, &_2, &_3, lang TSRMLS_CC); + zephir_fast_str_replace(&_1, &_2, &_3, lang TSRMLS_CC); zephir_fast_strtolower(_0, _1); ZEPHIR_INIT_VAR(_4); ZVAL_STRING(_4, "lang", 1); - zephir_update_property_array(this_ptr, SL("_options"), _4, _0 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("options"), _4, _0 TSRMLS_CC); } - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); - zephir_array_fetch_string(&_6, _5, SL("lang"), PH_NOISY | PH_READONLY, "ice/i18n.zep", 65 TSRMLS_CC); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC); + zephir_array_fetch_string(&_6, _5, SL("lang"), PH_NOISY | PH_READONLY, "ice/i18n.zep", 74 TSRMLS_CC); RETURN_CTOR(_6); } @@ -149,7 +151,7 @@ PHP_METHOD(Ice_I18n, lang) { PHP_METHOD(Ice_I18n, iso) { zend_bool country, _6; - zval *lang = NULL, *country_param = NULL, *parts, *_0, *_1, *_2, _3, _4, *_5; + zval *lang = NULL, *country_param = NULL, *parts = NULL, *_0, *_1, *_2, _3, _4, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &lang, &country_param); @@ -167,19 +169,19 @@ PHP_METHOD(Ice_I18n, iso) { if (!(zephir_is_true(lang))) { - _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_OBS_NVAR(lang); - zephir_array_fetch_string(&lang, _0, SL("lang"), PH_NOISY, "ice/i18n.zep", 80 TSRMLS_CC); + zephir_array_fetch_string(&lang, _0, SL("lang"), PH_NOISY, "ice/i18n.zep", 89 TSRMLS_CC); } - ZEPHIR_INIT_VAR(parts); ZEPHIR_INIT_VAR(_1); ZEPHIR_INIT_VAR(_2); ZEPHIR_SINIT_VAR(_3); ZVAL_STRING(&_3, "_", 0); ZEPHIR_SINIT_VAR(_4); ZVAL_STRING(&_4, "-", 0); - zephir_fast_str_replace(_2, &_3, &_4, lang TSRMLS_CC); + zephir_fast_str_replace(&_2, &_3, &_4, lang TSRMLS_CC); zephir_fast_strtolower(_1, _2); + ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("-"), _1, LONG_MAX TSRMLS_CC); ZEPHIR_INIT_VAR(_5); _6 = country; @@ -187,9 +189,9 @@ PHP_METHOD(Ice_I18n, iso) { _6 = zephir_array_isset_long(parts, 1); } if (_6) { - zephir_array_fetch_long(&_5, parts, 1, PH_NOISY, "ice/i18n.zep", 85 TSRMLS_CC); + zephir_array_fetch_long(&_5, parts, 1, PH_NOISY, "ice/i18n.zep", 94 TSRMLS_CC); } else { - zephir_array_fetch_long(&_5, parts, 0, PH_NOISY, "ice/i18n.zep", 85 TSRMLS_CC); + zephir_array_fetch_long(&_5, parts, 0, PH_NOISY, "ice/i18n.zep", 94 TSRMLS_CC); } RETURN_CCTOR(_5); @@ -206,9 +208,8 @@ PHP_METHOD(Ice_I18n, iso) { */ PHP_METHOD(Ice_I18n, get) { - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *str_param = NULL, *form = NULL, *lang_param = NULL, *messages = NULL, *translation, *_0, *_1, _4, *_5; + zval *str_param = NULL, *form = NULL, *lang_param = NULL, *messages = NULL, *translation = NULL, *_0, *_1, _3, *_4; zval *str = NULL, *lang = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); @@ -228,31 +229,31 @@ PHP_METHOD(Ice_I18n, get) { ZEPHIR_INIT_VAR(messages); array_init(messages); - if (!(lang && Z_STRLEN_P(lang))) { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); + if (!(!(!lang) && Z_STRLEN_P(lang))) { + _0 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_1); - zephir_array_fetch_string(&_1, _0, SL("lang"), PH_NOISY, "ice/i18n.zep", 107 TSRMLS_CC); + zephir_array_fetch_string(&_1, _0, SL("lang"), PH_NOISY, "ice/i18n.zep", 116 TSRMLS_CC); zephir_get_strval(_2, _1); ZEPHIR_CPY_WRT(lang, _2); } - ZEPHIR_CALL_METHOD(&messages, this_ptr, "load", &_3, lang); + ZEPHIR_CALL_METHOD(&messages, this_ptr, "load", NULL, 110, lang); zephir_check_call_status(); if (zephir_array_isset(messages, str)) { ZEPHIR_OBS_VAR(translation); - zephir_array_fetch(&translation, messages, str, PH_NOISY, "ice/i18n.zep", 114 TSRMLS_CC); + zephir_array_fetch(&translation, messages, str, PH_NOISY, "ice/i18n.zep", 123 TSRMLS_CC); if (Z_TYPE_P(translation) == IS_ARRAY) { - ZEPHIR_SINIT_VAR(_4); - ZVAL_STRING(&_4, "other", 0); + ZEPHIR_SINIT_VAR(_3); + ZVAL_STRING(&_3, "other", 0); if (zephir_array_key_exists(translation, form TSRMLS_CC)) { - zephir_array_fetch(&_5, translation, form, PH_NOISY | PH_READONLY, "ice/i18n.zep", 120 TSRMLS_CC); - RETURN_CTOR(_5); - } else if (zephir_array_key_exists(translation, &_4 TSRMLS_CC)) { - zephir_array_fetch_string(&_5, translation, SL("other"), PH_NOISY | PH_READONLY, "ice/i18n.zep", 122 TSRMLS_CC); - RETURN_CTOR(_5); + zephir_array_fetch(&_4, translation, form, PH_NOISY | PH_READONLY, "ice/i18n.zep", 129 TSRMLS_CC); + RETURN_CTOR(_4); + } else if (zephir_array_key_exists(translation, &_3 TSRMLS_CC)) { + zephir_array_fetch_string(&_4, translation, SL("other"), PH_NOISY | PH_READONLY, "ice/i18n.zep", 131 TSRMLS_CC); + RETURN_CTOR(_4); } - Z_SET_ISREF_P(translation); - ZEPHIR_RETURN_CALL_FUNCTION("reset", &_6, translation); - Z_UNSET_ISREF_P(translation); + ZEPHIR_MAKE_REF(translation); + ZEPHIR_RETURN_CALL_FUNCTION("reset", NULL, 111, translation); + ZEPHIR_UNREF(translation); zephir_check_call_status(); RETURN_MM(); } @@ -273,7 +274,7 @@ PHP_METHOD(Ice_I18n, load) { HashTable *_4, *_7; HashPosition _3, _6; zval *_2; - zval *lang_param = NULL, *cache, *parts, *subdir, *tail = NULL, *tmp = NULL, *found = NULL, *path = NULL, *messages = NULL, *_0, _1, **_5, **_8, *_9, *_10 = NULL, *_12 = NULL, *_13; + zval *lang_param = NULL, *cache = NULL, *parts = NULL, *subdir = NULL, *tail = NULL, *tmp = NULL, *found = NULL, *path = NULL, *messages = NULL, *_0, _1, **_5, **_8, *_9, *_10 = NULL, *_12 = NULL, *_13; zval *lang = NULL, *_11 = NULL; ZEPHIR_MM_GROW(); @@ -283,24 +284,24 @@ PHP_METHOD(Ice_I18n, load) { ZEPHIR_OBS_VAR(cache); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_cache"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC); if (zephir_array_isset_fetch(&cache, _0, lang, 0 TSRMLS_CC)) { RETURN_CCTOR(cache); } ZEPHIR_INIT_VAR(parts); zephir_fast_explode_str(parts, SL("-"), lang, LONG_MAX TSRMLS_CC); - ZEPHIR_INIT_VAR(subdir); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "/", 0); + ZEPHIR_INIT_VAR(subdir); zephir_fast_join(subdir, &_1, parts TSRMLS_CC); ZEPHIR_INIT_VAR(messages); array_init(messages); ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 4); + zephir_create_array(_2, 3, 0 TSRMLS_CC); zephir_array_fast_append(_2, subdir); zephir_array_fast_append(_2, lang); zephir_array_fast_append(_2, parts); - zephir_is_iterable(_2, &_4, &_3, 0, 0, "ice/i18n.zep", 173); + zephir_is_iterable(_2, &_4, &_3, 0, 0, "ice/i18n.zep", 182); for ( ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zephir_hash_move_forward_ex(_4, &_3) @@ -309,18 +310,18 @@ PHP_METHOD(Ice_I18n, load) { if (Z_TYPE_P(tail) != IS_ARRAY) { ZEPHIR_CPY_WRT(tmp, tail); ZEPHIR_INIT_NVAR(tail); - array_init_size(tail, 2); + zephir_create_array(tail, 1, 0 TSRMLS_CC); zephir_array_fast_append(tail, tmp); } - zephir_is_iterable(tail, &_7, &_6, 0, 0, "ice/i18n.zep", 171); + zephir_is_iterable(tail, &_7, &_6, 0, 0, "ice/i18n.zep", 180); for ( ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS ; zephir_hash_move_forward_ex(_7, &_6) ) { ZEPHIR_GET_HVALUE(found, _8); - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); + _9 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(_10); - zephir_array_fetch_string(&_10, _9, SL("dir"), PH_NOISY, "ice/i18n.zep", 163 TSRMLS_CC); + zephir_array_fetch_string(&_10, _9, SL("dir"), PH_NOISY, "ice/i18n.zep", 172 TSRMLS_CC); zephir_get_strval(_11, _10); ZEPHIR_INIT_NVAR(path); ZEPHIR_CONCAT_VVS(path, _11, found, ".php"); @@ -334,9 +335,9 @@ PHP_METHOD(Ice_I18n, load) { } } } - zephir_update_property_array(this_ptr, SL("_cache"), lang, messages TSRMLS_CC); - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_cache"), PH_NOISY_CC); - zephir_array_fetch(&_13, _9, lang, PH_NOISY | PH_READONLY, "ice/i18n.zep", 175 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("cache"), lang, messages TSRMLS_CC); + _9 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC); + zephir_array_fetch(&_13, _9, lang, PH_NOISY | PH_READONLY, "ice/i18n.zep", 184 TSRMLS_CC); RETURN_CTOR(_13); } @@ -353,7 +354,7 @@ PHP_METHOD(Ice_I18n, load) { PHP_METHOD(Ice_I18n, plural) { int count, ZEPHIR_LAST_CALL_STATUS; - zval *str_param = NULL, *count_param = NULL, *lang_param = NULL, *rules = NULL, *form = NULL, *code = NULL, *_0, *_1 = NULL, *_2, *_3; + zval *str_param = NULL, *count_param = NULL, *lang_param = NULL, *rules = NULL, *form = NULL, *code = NULL, *_0, *_1 = NULL, *_2, *_3, *_4; zval *str = NULL, *lang = NULL; ZEPHIR_MM_GROW(); @@ -363,7 +364,6 @@ PHP_METHOD(Ice_I18n, plural) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(str_param) == IS_STRING)) { zephir_get_strval(str, str_param); } else { @@ -383,23 +383,23 @@ PHP_METHOD(Ice_I18n, plural) { } - ZEPHIR_CALL_METHOD(&code, this_ptr, "iso", NULL, lang); + ZEPHIR_CALL_METHOD(&code, this_ptr, "iso", NULL, 0, lang); zephir_check_call_status(); ZEPHIR_OBS_VAR(rules); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_rules"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&rules, _0, code, 0 TSRMLS_CC))) { - ZEPHIR_CALL_METHOD(&_1, this_ptr, "pluralrules", NULL, code); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "pluralrules", NULL, 0, code); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("_rules"), code, _1 TSRMLS_CC); - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_rules"), PH_NOISY_CC); - ZEPHIR_OBS_NVAR(rules); - zephir_array_fetch(&rules, _2, code, PH_NOISY, "ice/i18n.zep", 196 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("rules"), code, _1 TSRMLS_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); + zephir_array_fetch(&_3, _2, code, PH_NOISY | PH_READONLY, "ice/i18n.zep", 205 TSRMLS_CC); + ZEPHIR_CPY_WRT(rules, _3); } - ZEPHIR_INIT_VAR(_3); - ZVAL_LONG(_3, count); - ZEPHIR_CALL_METHOD(&form, rules, "getcategory", NULL, _3); + ZEPHIR_INIT_VAR(_4); + ZVAL_LONG(_4, count); + ZEPHIR_CALL_METHOD(&form, rules, "getcategory", NULL, 0, _4); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, str, form, lang); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, str, form, lang); zephir_check_call_status(); RETURN_MM(); @@ -414,10 +414,9 @@ PHP_METHOD(Ice_I18n, plural) { PHP_METHOD(Ice_I18n, pluralRules) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL; - zval *_0, *_4, *_6, *_8, *_10, *_12, *_14, *_16; - zval *code_param = NULL, *_1 = NULL, *_2 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_11 = NULL, *_13 = NULL, *_15 = NULL, *_17 = NULL; - zval *code = NULL, *_18; + zval *_0, *_3, *_5, *_7, *_9, *_11, *_13, *_15; + zval *code_param = NULL, *_1 = NULL, *_2 = NULL, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_10 = NULL, *_12 = NULL, *_14 = NULL, *_16 = NULL; + zval *code = NULL, *_17; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &code_param); @@ -426,592 +425,592 @@ PHP_METHOD(Ice_I18n, pluralRules) { ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "cs", 1); zephir_array_fast_append(_0, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sk", 1); zephir_array_fast_append(_0, _1); - ZEPHIR_CALL_FUNCTION(&_2, "in_array", &_3, code, _0, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_CALL_FUNCTION(&_2, "in_array", NULL, 112, code, _0, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_4); - array_init_size(_4, 9); + ZEPHIR_INIT_VAR(_3); + zephir_create_array(_3, 7, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ru", 1); - zephir_array_fast_append(_4, _1); + zephir_array_fast_append(_3, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sr", 1); - zephir_array_fast_append(_4, _1); + zephir_array_fast_append(_3, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "uk", 1); - zephir_array_fast_append(_4, _1); + zephir_array_fast_append(_3, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sh", 1); - zephir_array_fast_append(_4, _1); + zephir_array_fast_append(_3, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "be", 1); - zephir_array_fast_append(_4, _1); + zephir_array_fast_append(_3, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "hr", 1); - zephir_array_fast_append(_4, _1); + zephir_array_fast_append(_3, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bs", 1); - zephir_array_fast_append(_4, _1); - ZEPHIR_CALL_FUNCTION(&_5, "in_array", &_3, code, _4, ZEPHIR_GLOBAL(global_true)); + zephir_array_fast_append(_3, _1); + ZEPHIR_CALL_FUNCTION(&_4, "in_array", NULL, 112, code, _3, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_6); - array_init_size(_6, 4); + ZEPHIR_INIT_VAR(_5); + zephir_create_array(_5, 3, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "fr", 1); - zephir_array_fast_append(_6, _1); + zephir_array_fast_append(_5, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ff", 1); - zephir_array_fast_append(_6, _1); + zephir_array_fast_append(_5, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "kab", 1); - zephir_array_fast_append(_6, _1); - ZEPHIR_CALL_FUNCTION(&_7, "in_array", &_3, code, _6, ZEPHIR_GLOBAL(global_true)); + zephir_array_fast_append(_5, _1); + ZEPHIR_CALL_FUNCTION(&_6, "in_array", NULL, 112, code, _5, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_8); - array_init_size(_8, 3); + ZEPHIR_INIT_VAR(_7); + zephir_create_array(_7, 2, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "mo", 1); - zephir_array_fast_append(_8, _1); + zephir_array_fast_append(_7, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ro", 1); - zephir_array_fast_append(_8, _1); - ZEPHIR_CALL_FUNCTION(&_9, "in_array", &_3, code, _8, ZEPHIR_GLOBAL(global_true)); + zephir_array_fast_append(_7, _1); + ZEPHIR_CALL_FUNCTION(&_8, "in_array", NULL, 112, code, _7, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_10); - array_init_size(_10, 16); + ZEPHIR_INIT_VAR(_9); + zephir_create_array(_9, 12, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "hi", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ln", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "mg", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ak", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "tl", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "am", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bh", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "wa", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ti", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "guw", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "fil", 1); - zephir_array_fast_append(_10, _1); + zephir_array_fast_append(_9, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "nso", 1); - zephir_array_fast_append(_10, _1); - ZEPHIR_CALL_FUNCTION(&_11, "in_array", &_3, code, _10, ZEPHIR_GLOBAL(global_true)); + zephir_array_fast_append(_9, _1); + ZEPHIR_CALL_FUNCTION(&_10, "in_array", NULL, 112, code, _9, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_12); - array_init_size(_12, 118); + ZEPHIR_INIT_VAR(_11); + zephir_create_array(_11, 94, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "en", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ny", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "nr", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "no", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "om", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "os", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ps", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "pa", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "nn", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "or", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "nl", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "lg", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "lb", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ky", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ml", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "mr", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ne", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "nd", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "nb", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "pt", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "rm", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ts", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "tn", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "tk", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ur", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "vo", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "zu", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "xh", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ve", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "te", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ta", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sq", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "so", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sn", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ss", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "st", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sw", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sv", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ku", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "mn", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "et", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "eo", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "el", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "eu", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "fi", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "fy", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "fo", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ee", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dv", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bg", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "af", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bn", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ca", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "de", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "da", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "gl", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "es", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "it", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "is", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ks", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ha", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "kk", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "kl", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "gu", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "brx", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "mas", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "teo", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "chr", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "cgg", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "tig", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "wae", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "xog", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ast", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "vun", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bem", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "syr", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bez", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "asa", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "rof", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ksb", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "rwk", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "haw", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "pap", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "gsw", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "fur", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "saq", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "seh", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "nyn", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "kcg", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ssy", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "kaj", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "jmc", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "nah", 1); - zephir_array_fast_append(_12, _1); + zephir_array_fast_append(_11, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ckb", 1); - zephir_array_fast_append(_12, _1); - ZEPHIR_CALL_FUNCTION(&_13, "in_array", &_3, code, _12, ZEPHIR_GLOBAL(global_true)); + zephir_array_fast_append(_11, _1); + ZEPHIR_CALL_FUNCTION(&_12, "in_array", NULL, 112, code, _11, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_14); - array_init_size(_14, 12); + ZEPHIR_INIT_VAR(_13); + zephir_create_array(_13, 9, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "se", 1); - zephir_array_fast_append(_14, _1); + zephir_array_fast_append(_13, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "kw", 1); - zephir_array_fast_append(_14, _1); + zephir_array_fast_append(_13, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "iu", 1); - zephir_array_fast_append(_14, _1); + zephir_array_fast_append(_13, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "smn", 1); - zephir_array_fast_append(_14, _1); + zephir_array_fast_append(_13, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sms", 1); - zephir_array_fast_append(_14, _1); + zephir_array_fast_append(_13, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "smj", 1); - zephir_array_fast_append(_14, _1); + zephir_array_fast_append(_13, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sma", 1); - zephir_array_fast_append(_14, _1); + zephir_array_fast_append(_13, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "naq", 1); - zephir_array_fast_append(_14, _1); + zephir_array_fast_append(_13, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "smi", 1); - zephir_array_fast_append(_14, _1); - ZEPHIR_CALL_FUNCTION(&_15, "in_array", &_3, code, _14, ZEPHIR_GLOBAL(global_true)); + zephir_array_fast_append(_13, _1); + ZEPHIR_CALL_FUNCTION(&_14, "in_array", NULL, 112, code, _13, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_16); - array_init_size(_16, 38); + ZEPHIR_INIT_VAR(_15); + zephir_create_array(_15, 30, 0 TSRMLS_CC); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "my", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sg", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ms", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "lo", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "kn", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ko", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "th", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "to", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "yo", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "zh", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "wo", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "vi", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "tr", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "az", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "km", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "id", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ig", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "fa", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "dz", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bm", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "bo", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ii", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "hu", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ka", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "jv", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ja", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "kde", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "ses", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "sah", 1); - zephir_array_fast_append(_16, _1); + zephir_array_fast_append(_15, _1); ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "kea", 1); - zephir_array_fast_append(_16, _1); - ZEPHIR_CALL_FUNCTION(&_17, "in_array", &_3, code, _16, ZEPHIR_GLOBAL(global_true)); + zephir_array_fast_append(_15, _1); + ZEPHIR_CALL_FUNCTION(&_16, "in_array", NULL, 112, code, _15, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); if (ZEPHIR_IS_STRING_IDENTICAL(code, "pl")) { object_init_ex(return_value, ice_i18n_plural_polish_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); } else if (ZEPHIR_IS_STRING_IDENTICAL(code, "ar")) { object_init_ex(return_value, ice_i18n_plural_arabic_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); } else if (zephir_is_true(_2)) { object_init_ex(return_value, ice_i18n_plural_czech_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); - } else if (zephir_is_true(_5)) { + } else if (zephir_is_true(_4)) { object_init_ex(return_value, ice_i18n_plural_balkan_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); - } else if (zephir_is_true(_7)) { + } else if (zephir_is_true(_6)) { object_init_ex(return_value, ice_i18n_plural_french_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); - } else if (zephir_is_true(_9)) { + } else if (zephir_is_true(_8)) { object_init_ex(return_value, ice_i18n_plural_romanian_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); - } else if (zephir_is_true(_11)) { + } else if (zephir_is_true(_10)) { object_init_ex(return_value, ice_i18n_plural_zero_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); - } else if (zephir_is_true(_13)) { + } else if (zephir_is_true(_12)) { object_init_ex(return_value, ice_i18n_plural_one_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); - } else if (zephir_is_true(_15)) { + } else if (zephir_is_true(_14)) { object_init_ex(return_value, ice_i18n_plural_two_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); - } else if (zephir_is_true(_17)) { + } else if (zephir_is_true(_16)) { object_init_ex(return_value, ice_i18n_plural_none_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); } else { ZEPHIR_INIT_NVAR(_1); object_init_ex(_1, ice_exception_ce); - ZEPHIR_INIT_VAR(_18); - ZEPHIR_CONCAT_SV(_18, "Unknown language code: ", code); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, _18); + ZEPHIR_INIT_VAR(_17); + ZEPHIR_CONCAT_SV(_17, "Unknown language code: ", code); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 2, _17); zephir_check_call_status(); - zephir_throw_exception_debug(_1, "ice/i18n.zep", 244 TSRMLS_CC); + zephir_throw_exception_debug(_1, "ice/i18n.zep", 253 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } @@ -1035,7 +1034,6 @@ PHP_METHOD(Ice_I18n, _) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(str_param) == IS_STRING)) { zephir_get_strval(str, str_param); } else { @@ -1043,8 +1041,8 @@ PHP_METHOD(Ice_I18n, _) { ZVAL_EMPTY_STRING(str); } if (!values_param) { - ZEPHIR_INIT_VAR(values); - array_init(values); + ZEPHIR_INIT_VAR(values); + array_init(values); } else { zephir_get_arrval(values, values_param); } @@ -1059,7 +1057,7 @@ PHP_METHOD(Ice_I18n, _) { } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "translate", NULL, str, values, lang); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "translate", NULL, 0, str, values, lang); zephir_check_call_status(); RETURN_MM(); @@ -1076,10 +1074,9 @@ PHP_METHOD(Ice_I18n, _) { */ PHP_METHOD(Ice_I18n, translate) { - zephir_nts_static zephir_fcall_cache_entry *_6 = NULL, *_7 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *values = NULL, *_9; - zval *str_param = NULL, *values_param = NULL, *context = NULL, *lang_param = NULL, *_0, *_1, *_3 = NULL, *_4, _5 = zval_used_for_init, *_8; + zval *values = NULL, *_7; + zval *str_param = NULL, *values_param = NULL, *context = NULL, *lang_param = NULL, *_0, *_1, *_3 = NULL, *_4, _5 = zval_used_for_init, *_6; zval *str = NULL, *lang = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); @@ -1089,7 +1086,6 @@ PHP_METHOD(Ice_I18n, translate) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(str_param) == IS_STRING)) { zephir_get_strval(str, str_param); } else { @@ -1097,8 +1093,8 @@ PHP_METHOD(Ice_I18n, translate) { ZVAL_EMPTY_STRING(str); } if (!values_param) { - ZEPHIR_INIT_VAR(values); - array_init(values); + ZEPHIR_INIT_VAR(values); + array_init(values); } else { zephir_get_arrval(values, values_param); } @@ -1113,19 +1109,19 @@ PHP_METHOD(Ice_I18n, translate) { } - if (!(lang && Z_STRLEN_P(lang))) { - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC); + if (!(!(!lang) && Z_STRLEN_P(lang))) { + _0 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC); ZEPHIR_OBS_VAR(_1); - zephir_array_fetch_string(&_1, _0, SL("lang"), PH_NOISY, "ice/i18n.zep", 268 TSRMLS_CC); + zephir_array_fetch_string(&_1, _0, SL("lang"), PH_NOISY, "ice/i18n.zep", 277 TSRMLS_CC); zephir_get_strval(_2, _1); ZEPHIR_CPY_WRT(lang, _2); } if (zephir_is_numeric(context)) { - ZEPHIR_CALL_METHOD(&_3, this_ptr, "plural", NULL, str, context, lang); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "plural", NULL, 0, str, context, lang); zephir_check_call_status(); zephir_get_strval(str, _3); } else { - ZEPHIR_CALL_METHOD(&_3, this_ptr, "get", NULL, str, context, lang); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "get", NULL, 0, str, context, lang); zephir_check_call_status(); zephir_get_strval(str, _3); } @@ -1136,21 +1132,21 @@ PHP_METHOD(Ice_I18n, translate) { zephir_array_keys(_4, values TSRMLS_CC); ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "is_string", 0); - ZEPHIR_CALL_FUNCTION(&_3, "array_filter", &_6, _4, &_5); + ZEPHIR_CALL_FUNCTION(&_3, "array_filter", NULL, 10, _4, &_5); zephir_check_call_status(); if (zephir_fast_count_int(_3 TSRMLS_CC)) { - ZEPHIR_RETURN_CALL_FUNCTION("strtr", &_7, str, values); + ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 85, str, values); zephir_check_call_status(); RETURN_MM(); } else { - ZEPHIR_INIT_VAR(_8); - ZEPHIR_INIT_VAR(_9); - array_init_size(_9, 2); - zephir_array_fast_append(_9, str); - zephir_fast_array_merge(_8, &(_9), &(values) TSRMLS_CC); + ZEPHIR_INIT_VAR(_6); + ZEPHIR_INIT_VAR(_7); + zephir_create_array(_7, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_7, str); + zephir_fast_array_merge(_6, &(_7), &(values) TSRMLS_CC); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "sprintf", 0); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_5, _8); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_5, _6); zephir_check_call_status(); RETURN_MM(); } @@ -1158,3 +1154,88 @@ PHP_METHOD(Ice_I18n, translate) { } +static zend_object_value zephir_init_properties_Ice_I18n(zend_class_entry *class_type TSRMLS_DC) { + + zval *_1; + zval *_0, *_2, *_3 = NULL, *_4; + + 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); + zephir_create_array(_1, 3, 0 TSRMLS_CC); + add_assoc_stringl_ex(_1, SS("source"), SL("en-gb"), 1); + add_assoc_stringl_ex(_1, SS("lang"), SL("en-gb"), 1); + add_assoc_stringl_ex(_1, SS("dir"), SL(""), 1); + zephir_update_property_this(this_ptr, SL("options"), _1 TSRMLS_CC); + } + _2 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); + if (Z_TYPE_P(_2) == IS_NULL) { + ZEPHIR_INIT_VAR(_3); + array_init(_3); + zephir_update_property_this(this_ptr, SL("rules"), _3 TSRMLS_CC); + } + _4 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC); + if (Z_TYPE_P(_4) == IS_NULL) { + ZEPHIR_INIT_NVAR(_3); + array_init(_3); + zephir_update_property_this(this_ptr, SL("cache"), _3 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } + +} + +PHP_FUNCTION(g_ice__t) { + int ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_0 = NULL; + zval *values = NULL; + zval *str_param = NULL, *values_param = NULL, *context = NULL, *lang_param = NULL, *i18n = NULL; + zval *str = NULL, *lang = NULL; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 3, &str_param, &values_param, &context, &lang_param); + + if (unlikely(Z_TYPE_P(str_param) != IS_STRING && Z_TYPE_P(str_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be a string") TSRMLS_CC); + RETURN_MM_NULL(); + } + if (likely(Z_TYPE_P(str_param) == IS_STRING)) { + zephir_get_strval(str, str_param); + } else { + ZEPHIR_INIT_VAR(str); + ZVAL_EMPTY_STRING(str); + } + if (!values_param) { + ZEPHIR_INIT_VAR(values); + array_init(values); + } else { + zephir_get_arrval(values, values_param); + } + if (!context) { + context = ZEPHIR_GLOBAL(global_null); + } + if (!lang_param) { + ZEPHIR_INIT_VAR(lang); + ZVAL_EMPTY_STRING(lang); + } else { + zephir_get_strval(lang, lang_param); + } + + + ZEPHIR_CALL_CE_STATIC(&i18n, ice_i18n_ce, "fetch", &_0, 113); + zephir_check_call_status(); + if (zephir_is_true(i18n)) { + ZEPHIR_RETURN_CALL_METHOD(i18n, "translate", NULL, 0, str, values, context, lang); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_MM_RESTORE(); + +} + diff --git a/ext/ice/i18n.zep.h b/ext/ice/i18n.zep.h index a4a9bcf1..60927b0a 100644 --- a/ext/ice/i18n.zep.h +++ b/ext/ice/i18n.zep.h @@ -13,6 +13,7 @@ PHP_METHOD(Ice_I18n, plural); PHP_METHOD(Ice_I18n, pluralRules); PHP_METHOD(Ice_I18n, _); PHP_METHOD(Ice_I18n, translate); +static zend_object_value zephir_init_properties_Ice_I18n(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_i18n___construct, 0, 0, 0) ZEND_ARG_ARRAY_INFO(0, options, 1) @@ -72,5 +73,5 @@ ZEPHIR_INIT_FUNCS(ice_i18n_method_entry) { PHP_ME(Ice_I18n, pluralRules, arginfo_ice_i18n_pluralrules, ZEND_ACC_PROTECTED) PHP_ME(Ice_I18n, _, arginfo_ice_i18n__, ZEND_ACC_PUBLIC) PHP_ME(Ice_I18n, translate, arginfo_ice_i18n_translate, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/arabic.zep.c b/ext/ice/i18n/plural/arabic.zep.c index 72d1ca97..a7d8502b 100644 --- a/ext/ice/i18n/plural/arabic.zep.c +++ b/ext/ice/i18n/plural/arabic.zep.c @@ -53,7 +53,7 @@ PHP_METHOD(Ice_I18n_Plural_Arabic, getCategory) { zend_bool _1, _2, _3, _4; zval *count_param = NULL, *isInt = NULL, *_0; - int count, i100, ZEPHIR_LAST_CALL_STATUS; + int count, i100 = 0, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &count_param); @@ -63,9 +63,9 @@ PHP_METHOD(Ice_I18n_Plural_Arabic, getCategory) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, count); - ZEPHIR_CALL_METHOD(&isInt, this_ptr, "isint", NULL, _0); + ZEPHIR_CALL_METHOD(&isInt, this_ptr, "isint", NULL, 0, _0); zephir_check_call_status(); - i100 = (count % 100); + i100 = (long) (zephir_safe_mod_long_long(count, 100 TSRMLS_CC)); _1 = zephir_is_true(isInt); if (_1) { _1 = i100 >= 3; diff --git a/ext/ice/i18n/plural/arabic.zep.h b/ext/ice/i18n/plural/arabic.zep.h index cdb21f4f..951165cb 100644 --- a/ext/ice/i18n/plural/arabic.zep.h +++ b/ext/ice/i18n/plural/arabic.zep.h @@ -17,5 +17,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_arabic_method_entry) { PHP_ME(Ice_I18n_Plural_Arabic, getCategory, arginfo_ice_i18n_plural_arabic_getcategory, ZEND_ACC_PUBLIC) PHP_ME(Ice_I18n_Plural_Arabic, isInt, arginfo_ice_i18n_plural_arabic_isint, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/balkan.zep.c b/ext/ice/i18n/plural/balkan.zep.c index e7218528..c0649a0a 100644 --- a/ext/ice/i18n/plural/balkan.zep.c +++ b/ext/ice/i18n/plural/balkan.zep.c @@ -51,7 +51,7 @@ PHP_METHOD(Ice_I18n_Plural_Balkan, getCategory) { zend_bool _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11; zval *count_param = NULL, *isInt = NULL, *_0; - int count, i10, i100, ZEPHIR_LAST_CALL_STATUS; + int count, i10 = 0, i100 = 0, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &count_param); @@ -61,17 +61,17 @@ PHP_METHOD(Ice_I18n_Plural_Balkan, getCategory) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, count); - ZEPHIR_CALL_METHOD(&isInt, this_ptr, "isint", NULL, _0); + ZEPHIR_CALL_METHOD(&isInt, this_ptr, "isint", NULL, 0, _0); zephir_check_call_status(); - i10 = (count % 10); - i100 = (count % 100); + i10 = (long) (zephir_safe_mod_long_long(count, 10 TSRMLS_CC)); + i100 = (long) (zephir_safe_mod_long_long(count, 100 TSRMLS_CC)); _1 = zephir_is_true(isInt); if (_1) { - _1 = (count % 10) == 1; + _1 = zephir_safe_mod_long_long(count, 10 TSRMLS_CC) == 1; } _2 = _1; if (_2) { - _2 = (count % 100) != 11; + _2 = zephir_safe_mod_long_long(count, 100 TSRMLS_CC) != 11; } _3 = zephir_is_true(isInt); if (_3) { diff --git a/ext/ice/i18n/plural/balkan.zep.h b/ext/ice/i18n/plural/balkan.zep.h index 997b668d..23f66daf 100644 --- a/ext/ice/i18n/plural/balkan.zep.h +++ b/ext/ice/i18n/plural/balkan.zep.h @@ -17,5 +17,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_balkan_method_entry) { PHP_ME(Ice_I18n_Plural_Balkan, getCategory, arginfo_ice_i18n_plural_balkan_getcategory, ZEND_ACC_PUBLIC) PHP_ME(Ice_I18n_Plural_Balkan, isInt, arginfo_ice_i18n_plural_balkan_isint, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/czech.zep.c b/ext/ice/i18n/plural/czech.zep.c index 23a2304e..2e8fadc7 100644 --- a/ext/ice/i18n/plural/czech.zep.c +++ b/ext/ice/i18n/plural/czech.zep.c @@ -60,7 +60,7 @@ PHP_METHOD(Ice_I18n_Plural_Czech, getCategory) { ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, count); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "isint", NULL, _1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "isint", NULL, 0, _1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { diff --git a/ext/ice/i18n/plural/czech.zep.h b/ext/ice/i18n/plural/czech.zep.h index c1b1cae8..48f3a6ff 100644 --- a/ext/ice/i18n/plural/czech.zep.h +++ b/ext/ice/i18n/plural/czech.zep.h @@ -17,5 +17,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_czech_method_entry) { PHP_ME(Ice_I18n_Plural_Czech, getCategory, arginfo_ice_i18n_plural_czech_getcategory, ZEND_ACC_PUBLIC) PHP_ME(Ice_I18n_Plural_Czech, isInt, arginfo_ice_i18n_plural_czech_isint, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/french.zep.h b/ext/ice/i18n/plural/french.zep.h index 9deadda5..c2f838d6 100644 --- a/ext/ice/i18n/plural/french.zep.h +++ b/ext/ice/i18n/plural/french.zep.h @@ -11,5 +11,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_french_method_entry) { PHP_ME(Ice_I18n_Plural_French, getCategory, arginfo_ice_i18n_plural_french_getcategory, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/none.zep.h b/ext/ice/i18n/plural/none.zep.h index f7ba9514..f71edca9 100644 --- a/ext/ice/i18n/plural/none.zep.h +++ b/ext/ice/i18n/plural/none.zep.h @@ -11,5 +11,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_none_method_entry) { PHP_ME(Ice_I18n_Plural_None, getCategory, arginfo_ice_i18n_plural_none_getcategory, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/one.zep.h b/ext/ice/i18n/plural/one.zep.h index 4ec1b75b..7e9cfa55 100644 --- a/ext/ice/i18n/plural/one.zep.h +++ b/ext/ice/i18n/plural/one.zep.h @@ -11,5 +11,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_one_method_entry) { PHP_ME(Ice_I18n_Plural_One, getCategory, arginfo_ice_i18n_plural_one_getcategory, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/pluralinterface.zep.h b/ext/ice/i18n/plural/pluralinterface.zep.h index 147b0f79..f403132d 100644 --- a/ext/ice/i18n/plural/pluralinterface.zep.h +++ b/ext/ice/i18n/plural/pluralinterface.zep.h @@ -9,5 +9,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_pluralinterface_method_entry) { PHP_ABSTRACT_ME(Ice_I18n_Plural_PluralInterface, getCategory, arginfo_ice_i18n_plural_pluralinterface_getcategory) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/polish.zep.c b/ext/ice/i18n/plural/polish.zep.c index 11016a6a..8f7fd0ae 100644 --- a/ext/ice/i18n/plural/polish.zep.c +++ b/ext/ice/i18n/plural/polish.zep.c @@ -50,7 +50,7 @@ PHP_METHOD(Ice_I18n_Plural_Polish, getCategory) { zend_bool _1, _2, _3, _4, _5, _6; zval *count_param = NULL, *isInt = NULL, *_0; - int count, i10, i100, ZEPHIR_LAST_CALL_STATUS; + int count, i10 = 0, i100 = 0, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &count_param); @@ -60,10 +60,10 @@ PHP_METHOD(Ice_I18n_Plural_Polish, getCategory) { ZEPHIR_INIT_VAR(_0); ZVAL_LONG(_0, count); - ZEPHIR_CALL_METHOD(&isInt, this_ptr, "isint", NULL, _0); + ZEPHIR_CALL_METHOD(&isInt, this_ptr, "isint", NULL, 0, _0); zephir_check_call_status(); - i10 = (count % 10); - i100 = (count % 100); + i10 = (long) (zephir_safe_mod_long_long(count, 10 TSRMLS_CC)); + i100 = (long) (zephir_safe_mod_long_long(count, 100 TSRMLS_CC)); _1 = zephir_is_true(isInt); if (_1) { _1 = i10 >= 2; diff --git a/ext/ice/i18n/plural/polish.zep.h b/ext/ice/i18n/plural/polish.zep.h index c48a6188..bf382c37 100644 --- a/ext/ice/i18n/plural/polish.zep.h +++ b/ext/ice/i18n/plural/polish.zep.h @@ -17,5 +17,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_polish_method_entry) { PHP_ME(Ice_I18n_Plural_Polish, getCategory, arginfo_ice_i18n_plural_polish_getcategory, ZEND_ACC_PUBLIC) PHP_ME(Ice_I18n_Plural_Polish, isInt, arginfo_ice_i18n_plural_polish_isint, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/romanian.zep.c b/ext/ice/i18n/plural/romanian.zep.c index 8b3afc15..14ea0f6d 100644 --- a/ext/ice/i18n/plural/romanian.zep.c +++ b/ext/ice/i18n/plural/romanian.zep.c @@ -12,9 +12,9 @@ #include #include "kernel/main.h" +#include "kernel/operators.h" #include "kernel/memory.h" #include "kernel/fcall.h" -#include "kernel/operators.h" /** @@ -50,7 +50,7 @@ PHP_METHOD(Ice_I18n_Plural_Romanian, getCategory) { zend_bool _2, _3, _4; zval *count_param = NULL, *_0 = NULL, *_1; - int count, i100, ZEPHIR_LAST_CALL_STATUS; + int count, i100 = 0, ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &count_param); @@ -58,10 +58,10 @@ PHP_METHOD(Ice_I18n_Plural_Romanian, getCategory) { count = zephir_get_intval(count_param); - i100 = (count % 100); + i100 = (long) (zephir_safe_mod_long_long(count, 100 TSRMLS_CC)); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, count); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "isint", NULL, _1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "isint", NULL, 0, _1); zephir_check_call_status(); _2 = zephir_is_true(_0); if (_2) { diff --git a/ext/ice/i18n/plural/romanian.zep.h b/ext/ice/i18n/plural/romanian.zep.h index caeec3e4..b5e0e431 100644 --- a/ext/ice/i18n/plural/romanian.zep.h +++ b/ext/ice/i18n/plural/romanian.zep.h @@ -17,5 +17,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_romanian_method_entry) { PHP_ME(Ice_I18n_Plural_Romanian, getCategory, arginfo_ice_i18n_plural_romanian_getcategory, ZEND_ACC_PUBLIC) PHP_ME(Ice_I18n_Plural_Romanian, isInt, arginfo_ice_i18n_plural_romanian_isint, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/two.zep.h b/ext/ice/i18n/plural/two.zep.h index 37f2a6db..88b84b90 100644 --- a/ext/ice/i18n/plural/two.zep.h +++ b/ext/ice/i18n/plural/two.zep.h @@ -11,5 +11,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_two_method_entry) { PHP_ME(Ice_I18n_Plural_Two, getCategory, arginfo_ice_i18n_plural_two_getcategory, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/i18n/plural/zero.zep.h b/ext/ice/i18n/plural/zero.zep.h index 8e3d1a69..851c043c 100644 --- a/ext/ice/i18n/plural/zero.zep.h +++ b/ext/ice/i18n/plural/zero.zep.h @@ -11,5 +11,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_i18n_plural_zero_method_entry) { PHP_ME(Ice_I18n_Plural_Zero, getCategory, arginfo_ice_i18n_plural_zero_getcategory, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/loader.zep.c b/ext/ice/loader.zep.c index 1176e21b..2538ea9e 100644 --- a/ext/ice/loader.zep.c +++ b/ext/ice/loader.zep.c @@ -23,12 +23,23 @@ #include "kernel/file.h" #include "kernel/require.h" + +/** + * PSR-4 autoloader class. + * + * @package Ice/Loader + * @category Library + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Loader) { ZEPHIR_REGISTER_CLASS(Ice, Loader, ice, loader, ice_loader_method_entry, 0); - zend_declare_property_null(ice_loader_ce, SL("_prefixes"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_loader_ce, SL("prefixes"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_loader_ce->create_object = zephir_init_properties_Ice_Loader; return SUCCESS; } @@ -47,12 +58,12 @@ PHP_METHOD(Ice_Loader, register) { ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 3); + zephir_create_array(_0, 2, 0 TSRMLS_CC); zephir_array_fast_append(_0, this_ptr); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "loadClass", 1); zephir_array_fast_append(_0, _1); - ZEPHIR_CALL_FUNCTION(NULL, "spl_autoload_register", NULL, _0); + ZEPHIR_CALL_FUNCTION(NULL, "spl_autoload_register", NULL, 114, _0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -69,7 +80,6 @@ PHP_METHOD(Ice_Loader, register) { */ PHP_METHOD(Ice_Loader, addNamespace) { - zephir_nts_static zephir_fcall_cache_entry *_15 = NULL, *_16 = NULL; int ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_14 = NULL; zend_bool prepend; @@ -109,29 +119,29 @@ PHP_METHOD(Ice_Loader, addNamespace) { ZEPHIR_INIT_VAR(_8); ZEPHIR_CONCAT_VS(_8, _6, "/"); zephir_get_strval(baseDir, _8); - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_prefixes"), PH_NOISY_CC); + _9 = zephir_fetch_nproperty_this(this_ptr, SL("prefixes"), PH_NOISY_CC); if (!(zephir_array_isset(_9, prefix))) { ZEPHIR_INIT_VAR(_10); array_init(_10); - zephir_update_property_array(this_ptr, SL("_prefixes"), prefix, _10 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("prefixes"), prefix, _10 TSRMLS_CC); } if (prepend) { - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_prefixes"), PH_NOISY_CC); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("prefixes"), PH_NOISY_CC); zephir_array_fetch(&_12, _11, prefix, PH_NOISY | PH_READONLY, "ice/loader.zep", 53 TSRMLS_CC); - ZEPHIR_CALL_FUNCTION(&_13, "utf8_encode", &_14, baseDir); + ZEPHIR_CALL_FUNCTION(&_13, "utf8_encode", &_14, 115, baseDir); zephir_check_call_status(); - Z_SET_ISREF_P(_12); - ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", &_15, _12, _13); - Z_UNSET_ISREF_P(_12); + ZEPHIR_MAKE_REF(_12); + ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 116, _12, _13); + ZEPHIR_UNREF(_12); zephir_check_call_status(); } else { - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_prefixes"), PH_NOISY_CC); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("prefixes"), PH_NOISY_CC); zephir_array_fetch(&_12, _11, prefix, PH_NOISY | PH_READONLY, "ice/loader.zep", 55 TSRMLS_CC); - ZEPHIR_CALL_FUNCTION(&_13, "utf8_encode", &_14, baseDir); + ZEPHIR_CALL_FUNCTION(&_13, "utf8_encode", &_14, 115, baseDir); zephir_check_call_status(); - Z_SET_ISREF_P(_12); - ZEPHIR_CALL_FUNCTION(NULL, "array_push", &_16, _12, _13); - Z_UNSET_ISREF_P(_12); + ZEPHIR_MAKE_REF(_12); + ZEPHIR_CALL_FUNCTION(NULL, "array_push", NULL, 117, _12, _13); + ZEPHIR_UNREF(_12); zephir_check_call_status(); } RETURN_THIS(); @@ -146,9 +156,8 @@ PHP_METHOD(Ice_Loader, addNamespace) { */ PHP_METHOD(Ice_Loader, loadClass) { - zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL, *_4 = NULL; zval *className_param = NULL, *prefix = NULL, *pos = NULL, *relativeClass = NULL, *mappedFile = NULL, _0 = zval_used_for_init, _2 = zval_used_for_init, _3 = zval_used_for_init, *_5 = NULL, _6 = zval_used_for_init, _7 = zval_used_for_init; zval *className = NULL; @@ -161,7 +170,7 @@ PHP_METHOD(Ice_Loader, loadClass) { ZEPHIR_CPY_WRT(prefix, className); ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "\\", 0); - ZEPHIR_CALL_FUNCTION(&pos, "strrpos", &_1, prefix, &_0); + ZEPHIR_CALL_FUNCTION(&pos, "strrpos", &_1, 118, prefix, &_0); zephir_check_call_status(); while (1) { if (!(!ZEPHIR_IS_FALSE_IDENTICAL(pos))) { @@ -177,7 +186,7 @@ PHP_METHOD(Ice_Loader, loadClass) { ZVAL_LONG(&_3, (zephir_get_numberval(pos) + 1)); ZEPHIR_INIT_NVAR(relativeClass); zephir_substr(relativeClass, className, zephir_get_intval(&_3), 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CALL_METHOD(&mappedFile, this_ptr, "loadmappedfile", &_4, prefix, relativeClass); + ZEPHIR_CALL_METHOD(&mappedFile, this_ptr, "loadmappedfile", &_4, 0, prefix, relativeClass); zephir_check_call_status(); if (zephir_is_true(mappedFile)) { RETURN_CCTOR(mappedFile); @@ -189,7 +198,7 @@ PHP_METHOD(Ice_Loader, loadClass) { ZEPHIR_CPY_WRT(prefix, _5); ZEPHIR_SINIT_NVAR(_7); ZVAL_STRING(&_7, "\\", 0); - ZEPHIR_CALL_FUNCTION(&pos, "strrpos", &_1, prefix, &_7); + ZEPHIR_CALL_FUNCTION(&pos, "strrpos", &_1, 118, prefix, &_7); zephir_check_call_status(); } RETURN_MM_BOOL(0); @@ -219,11 +228,11 @@ PHP_METHOD(Ice_Loader, loadMappedFile) { zephir_get_strval(relativeClass, relativeClass_param); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefixes"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("prefixes"), PH_NOISY_CC); if (!(zephir_array_isset(_0, prefix))) { RETURN_MM_BOOL(0); } - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_prefixes"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("prefixes"), PH_NOISY_CC); zephir_array_fetch(&_2, _1, prefix, PH_NOISY | PH_READONLY, "ice/loader.zep", 116 TSRMLS_CC); zephir_is_iterable(_2, &_4, &_3, 0, 0, "ice/loader.zep", 131); for ( @@ -236,7 +245,7 @@ PHP_METHOD(Ice_Loader, loadMappedFile) { ZVAL_STRING(&_7, "\\", 0); ZEPHIR_SINIT_NVAR(_8); ZVAL_STRING(&_8, "/", 0); - zephir_fast_str_replace(_6, &_7, &_8, relativeClass TSRMLS_CC); + zephir_fast_str_replace(&_6, &_7, &_8, relativeClass TSRMLS_CC); ZEPHIR_INIT_NVAR(file); ZEPHIR_CONCAT_VVS(file, baseDir, _6, ".php"); ZEPHIR_INIT_NVAR(_9); @@ -244,10 +253,10 @@ PHP_METHOD(Ice_Loader, loadMappedFile) { ZVAL_STRING(&_10, "\\", 0); ZEPHIR_SINIT_NVAR(_11); ZVAL_STRING(&_11, "/", 0); - zephir_fast_str_replace(_9, &_10, &_11, relativeClass TSRMLS_CC); + zephir_fast_str_replace(&_9, &_10, &_11, relativeClass TSRMLS_CC); ZEPHIR_INIT_NVAR(file); ZEPHIR_CONCAT_VVS(file, baseDir, _9, ".php"); - ZEPHIR_CALL_METHOD(&_12, this_ptr, "requirefile", &_13, file); + ZEPHIR_CALL_METHOD(&_12, this_ptr, "requirefile", &_13, 0, file); zephir_check_call_status(); if (zephir_is_true(_12)) { RETURN_CCTOR(file); @@ -284,16 +293,24 @@ PHP_METHOD(Ice_Loader, requireFile) { } -PHP_METHOD(Ice_Loader, __construct) { +static zend_object_value zephir_init_properties_Ice_Loader(zend_class_entry *class_type TSRMLS_DC) { - zval *_0; + zval *_0, *_1; - ZEPHIR_MM_GROW(); - - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_prefixes"), _0 TSRMLS_CC); - ZEPHIR_MM_RESTORE(); + ZEPHIR_MM_GROW(); + + { + zval *this_ptr = NULL; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("prefixes"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("prefixes"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } } diff --git a/ext/ice/loader.zep.h b/ext/ice/loader.zep.h index c32fcbc5..6b8b1007 100644 --- a/ext/ice/loader.zep.h +++ b/ext/ice/loader.zep.h @@ -8,7 +8,7 @@ PHP_METHOD(Ice_Loader, addNamespace); PHP_METHOD(Ice_Loader, loadClass); PHP_METHOD(Ice_Loader, loadMappedFile); PHP_METHOD(Ice_Loader, requireFile); -PHP_METHOD(Ice_Loader, __construct); +static zend_object_value zephir_init_properties_Ice_Loader(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_loader_addnamespace, 0, 0, 2) ZEND_ARG_INFO(0, prefix) @@ -35,6 +35,5 @@ ZEPHIR_INIT_FUNCS(ice_loader_method_entry) { PHP_ME(Ice_Loader, loadClass, arginfo_ice_loader_loadclass, ZEND_ACC_PUBLIC) PHP_ME(Ice_Loader, loadMappedFile, arginfo_ice_loader_loadmappedfile, ZEND_ACC_PROTECTED) PHP_ME(Ice_Loader, requireFile, arginfo_ice_loader_requirefile, ZEND_ACC_PROTECTED) - PHP_ME(Ice_Loader, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/log/driver.zep.c b/ext/ice/log/driver.zep.c index c772c651..5e2af598 100644 --- a/ext/ice/log/driver.zep.c +++ b/ext/ice/log/driver.zep.c @@ -65,7 +65,7 @@ PHP_METHOD(Ice_Log_Driver, emergency) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "emergency", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, _0, message, context); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -102,7 +102,7 @@ PHP_METHOD(Ice_Log_Driver, alert) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "alert", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, _0, message, context); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -139,7 +139,7 @@ PHP_METHOD(Ice_Log_Driver, critical) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "critical", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, _0, message, context); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -174,7 +174,7 @@ PHP_METHOD(Ice_Log_Driver, error) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "error", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, _0, message, context); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -211,7 +211,7 @@ PHP_METHOD(Ice_Log_Driver, warning) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "warning", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, _0, message, context); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -246,7 +246,7 @@ PHP_METHOD(Ice_Log_Driver, notice) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "notice", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, _0, message, context); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -283,7 +283,7 @@ PHP_METHOD(Ice_Log_Driver, info) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "info", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, _0, message, context); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -318,7 +318,7 @@ PHP_METHOD(Ice_Log_Driver, debug) { ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "debug", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, _0, message, context); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, _0, message, context); zephir_check_temp_parameter(_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); diff --git a/ext/ice/log/driver.zep.h b/ext/ice/log/driver.zep.h index c074cc41..44825c17 100644 --- a/ext/ice/log/driver.zep.h +++ b/ext/ice/log/driver.zep.h @@ -69,5 +69,5 @@ ZEPHIR_INIT_FUNCS(ice_log_driver_method_entry) { PHP_ME(Ice_Log_Driver, info, arginfo_ice_log_driver_info, ZEND_ACC_PUBLIC) PHP_ME(Ice_Log_Driver, debug, arginfo_ice_log_driver_debug, ZEND_ACC_PUBLIC) PHP_ME(Ice_Log_Driver, log, arginfo_ice_log_driver_log, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/log/driver/file.zep.c b/ext/ice/log/driver/file.zep.c index f916f324..5108070e 100644 --- a/ext/ice/log/driver/file.zep.c +++ b/ext/ice/log/driver/file.zep.c @@ -37,7 +37,7 @@ ZEPHIR_INIT_CLASS(Ice_Log_Driver_File) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Log\\Driver, File, ice, log_driver_file, ice_log_driver_ce, ice_log_driver_file_method_entry, 0); - zend_declare_property_null(ice_log_driver_file_ce, SL("_file"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_log_driver_file_ce, SL("file"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -51,11 +51,10 @@ ZEPHIR_INIT_CLASS(Ice_Log_Driver_File) { */ PHP_METHOD(Ice_Log_Driver_File, __construct) { - zephir_fcall_cache_entry *_4 = NULL; + zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_1 = NULL, *_5 = NULL; - zval *file_param = NULL, *_0 = NULL, *_2 = NULL; - zval *file = NULL, *_3 = NULL; + zval *file_param = NULL, *_0 = NULL, *_1 = NULL; + zval *file = NULL, *_2 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &file_param); @@ -64,34 +63,34 @@ PHP_METHOD(Ice_Log_Driver_File, __construct) { if (!((zephir_file_exists(file TSRMLS_CC) == SUCCESS))) { - ZEPHIR_CALL_FUNCTION(&_0, "touch", &_1, file); + ZEPHIR_CALL_FUNCTION(&_0, "touch", NULL, 119, file); zephir_check_call_status(); if (!(zephir_is_true(_0))) { + ZEPHIR_INIT_VAR(_1); + object_init_ex(_1, ice_exception_ce); ZEPHIR_INIT_VAR(_2); - object_init_ex(_2, ice_exception_ce); - ZEPHIR_INIT_VAR(_3); - ZEPHIR_CONCAT_SVS(_3, "Log file ", file, " cannot be created"); - ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_4, _3); + ZEPHIR_CONCAT_SVS(_2, "Log file ", file, " cannot be created"); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_3, 2, _2); zephir_check_call_status(); - zephir_throw_exception_debug(_2, "ice/log/driver/file.zep", 31 TSRMLS_CC); + zephir_throw_exception_debug(_1, "ice/log/driver/file.zep", 31 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } - ZEPHIR_CALL_FUNCTION(&_0, "is_writable", &_5, file); + ZEPHIR_CALL_FUNCTION(&_0, "is_writable", NULL, 120, file); zephir_check_call_status(); if (!(zephir_is_true(_0))) { - ZEPHIR_INIT_NVAR(_2); - object_init_ex(_2, ice_exception_ce); - ZEPHIR_INIT_LNVAR(_3); - ZEPHIR_CONCAT_SVS(_3, "Log file ", file, " is not writeable"); - ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_4, _3); + ZEPHIR_INIT_NVAR(_1); + object_init_ex(_1, ice_exception_ce); + ZEPHIR_INIT_LNVAR(_2); + ZEPHIR_CONCAT_SVS(_2, "Log file ", file, " is not writeable"); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_3, 2, _2); zephir_check_call_status(); - zephir_throw_exception_debug(_2, "ice/log/driver/file.zep", 35 TSRMLS_CC); + zephir_throw_exception_debug(_1, "ice/log/driver/file.zep", 35 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } - zephir_update_property_this(this_ptr, SL("_file"), file TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("file"), file TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -106,11 +105,10 @@ PHP_METHOD(Ice_Log_Driver_File, __construct) { */ PHP_METHOD(Ice_Log_Driver_File, log) { - zephir_nts_static zephir_fcall_cache_entry *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *context = NULL; zval *message = NULL; - zval *level, *message_param = NULL, *context_param = NULL, *line, _0 = zval_used_for_init, *_1 = NULL, *_2, *_3 = NULL, *_4, *_5; + zval *level, *message_param = NULL, *context_param = NULL, *line = NULL, _0 = zval_used_for_init, *_1 = NULL, *_2, *_3 = NULL, *_4, *_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &level, &message_param, &context_param); @@ -126,20 +124,20 @@ PHP_METHOD(Ice_Log_Driver_File, log) { ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "Y-m-d H:i:s", 0); - ZEPHIR_CALL_FUNCTION(&_1, "date", NULL, &_0); + ZEPHIR_CALL_FUNCTION(&_1, "date", NULL, 54, &_0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_2); zephir_fast_strtoupper(_2, level); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "interpolate", NULL, message, context); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "interpolate", NULL, 0, message, context); zephir_check_call_status(); ZEPHIR_INIT_VAR(_4); ZEPHIR_GET_CONSTANT(_4, "PHP_EOL"); ZEPHIR_INIT_VAR(line); ZEPHIR_CONCAT_SVSVSVV(line, "[", _1, "] ", _2, ": ", _3, _4); - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_file"), PH_NOISY_CC); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("file"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, 8); - ZEPHIR_CALL_FUNCTION(NULL, "file_put_contents", &_6, _5, line, &_0); + ZEPHIR_CALL_FUNCTION(NULL, "file_put_contents", NULL, 121, _5, line, &_0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); @@ -155,11 +153,10 @@ PHP_METHOD(Ice_Log_Driver_File, log) { PHP_METHOD(Ice_Log_Driver_File, interpolate) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_4 = NULL; HashTable *_1; HashPosition _0; zval *context = NULL; - zval *message_param = NULL, *context_param = NULL, *replace, *key = NULL, *value = NULL, **_2, *_3 = NULL; + zval *message_param = NULL, *context_param = NULL, *replace = NULL, *key = NULL, *value = NULL, **_2, *_3 = NULL; zval *message = NULL; ZEPHIR_MM_GROW(); @@ -187,7 +184,7 @@ PHP_METHOD(Ice_Log_Driver_File, interpolate) { ZEPHIR_CONCAT_SVS(_3, "{", key, "}"); zephir_array_update_zval(&replace, _3, &value, PH_COPY | PH_SEPARATE); } - ZEPHIR_RETURN_CALL_FUNCTION("strtr", &_4, message, replace); + ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 85, message, replace); zephir_check_call_status(); RETURN_MM(); diff --git a/ext/ice/log/driver/file.zep.h b/ext/ice/log/driver/file.zep.h index f047ec91..9a7334d1 100644 --- a/ext/ice/log/driver/file.zep.h +++ b/ext/ice/log/driver/file.zep.h @@ -26,5 +26,5 @@ ZEPHIR_INIT_FUNCS(ice_log_driver_file_method_entry) { PHP_ME(Ice_Log_Driver_File, __construct, arginfo_ice_log_driver_file___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Log_Driver_File, log, arginfo_ice_log_driver_file_log, ZEND_ACC_PUBLIC) PHP_ME(Ice_Log_Driver_File, interpolate, arginfo_ice_log_driver_file_interpolate, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/log/loggerinterface.zep.h b/ext/ice/log/loggerinterface.zep.h index b0f8dffa..161aa4df 100644 --- a/ext/ice/log/loggerinterface.zep.h +++ b/ext/ice/log/loggerinterface.zep.h @@ -59,5 +59,5 @@ ZEPHIR_INIT_FUNCS(ice_log_loggerinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Log_LoggerInterface, info, arginfo_ice_log_loggerinterface_info) PHP_ABSTRACT_ME(Ice_Log_LoggerInterface, debug, arginfo_ice_log_loggerinterface_debug) PHP_ABSTRACT_ME(Ice_Log_LoggerInterface, log, arginfo_ice_log_loggerinterface_log) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/app.zep.c b/ext/ice/mvc/app.zep.c index 59cf5b84..298c4862 100644 --- a/ext/ice/mvc/app.zep.c +++ b/ext/ice/mvc/app.zep.c @@ -33,9 +33,9 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_App) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Mvc, App, ice, mvc_app, ice_di_access_ce, ice_mvc_app_method_entry, 0); - zend_declare_property_bool(ice_mvc_app_ce, SL("_autoRender"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(ice_mvc_app_ce, SL("autoRender"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_app_ce, SL("_modules"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_app_ce, SL("modules"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -44,7 +44,7 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_App) { PHP_METHOD(Ice_Mvc_App, getAutoRender) { - RETURN_MEMBER(this_ptr, "_autoRender"); + RETURN_MEMBER(this_ptr, "autoRender"); } @@ -56,14 +56,14 @@ PHP_METHOD(Ice_Mvc_App, setAutoRender) { - zephir_update_property_this(this_ptr, SL("_autoRender"), autoRender TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("autoRender"), autoRender TSRMLS_CC); } PHP_METHOD(Ice_Mvc_App, getModules) { - RETURN_MEMBER(this_ptr, "_modules"); + RETURN_MEMBER(this_ptr, "modules"); } @@ -75,7 +75,38 @@ PHP_METHOD(Ice_Mvc_App, setModules) { - zephir_update_property_this(this_ptr, SL("_modules"), modules TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("modules"), modules TSRMLS_CC); + +} + +/** + * App constructor + * + * @param Di $di + */ +PHP_METHOD(Ice_Mvc_App, __construct) { + + int ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_0 = NULL; + zval *di = NULL, *_1, *_2; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &di); + + if (!di) { + di = ZEPHIR_GLOBAL(global_null); + } + + + ZEPHIR_CALL_PARENT(NULL, ice_mvc_app_ce, this_ptr, "__construct", &_0, 29, di); + zephir_check_call_status(); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_2); + ZVAL_STRING(_2, "app", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _1, "set", NULL, 0, _2, this_ptr); + zephir_check_temp_parameter(_2); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } @@ -88,12 +119,13 @@ PHP_METHOD(Ice_Mvc_App, setModules) { */ PHP_METHOD(Ice_Mvc_App, handle) { - zval *_7, *_14 = NULL; - zend_bool _2, _3, _15; + zval *_10, *_18 = NULL; + zend_bool _4, _5, _16, _19; int ZEPHIR_LAST_CALL_STATUS; - zval *method = NULL, *uri = NULL, *argv, *router = NULL, *request = NULL, *response = NULL, *dispatcher = NULL, *controller = NULL, *view = NULL, *_0, *_1 = NULL, *_SERVER, *_4, *_5, *_6, *_8, *_9, *_10, *_11, *_12, *_13, *_16, *_17, *_18 = NULL, *_19 = NULL, *_20 = NULL, *_21 = NULL, *_22, *_23; + zval *method = NULL, *uri = NULL, *argv = NULL, *router = NULL, *request = NULL, *response = NULL, *dispatcher = NULL, *returned = NULL, *controller = NULL, *view = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_SERVER, *_6, *_7 = NULL, *_8, *_9, *_11, *_12, *_13, *_14, *_15, *_17, *_20, *_21, *_22, *_23 = NULL, *_24 = NULL, *_25 = NULL, *_26 = NULL, *_27; ZEPHIR_MM_GROW(); + zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); zephir_fetch_params(1, 0, 2, &method, &uri); if (!method) { @@ -108,156 +140,192 @@ PHP_METHOD(Ice_Mvc_App, handle) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&request, _0, "getrequest", NULL); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_1); + ZVAL_STRING(_1, "request", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_VAR(_2); + ZVAL_NULL(_2); + ZEPHIR_INIT_VAR(_3); + ZVAL_BOOL(_3, 1); + ZEPHIR_CALL_METHOD(&request, _0, "get", NULL, 0, _1, _2, _3); + zephir_check_temp_parameter(_1); zephir_check_call_status(); if (Z_TYPE_P(method) == IS_NULL) { - ZEPHIR_CALL_METHOD(&method, request, "getmethod", NULL); + ZEPHIR_CALL_METHOD(&method, request, "getmethod", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(uri) == IS_NULL) { - ZEPHIR_INIT_VAR(_1); + ZEPHIR_INIT_NVAR(_1); ZVAL_STRING(_1, "_url", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(&uri, request, "get", NULL, _1); + ZEPHIR_CALL_METHOD(&uri, request, "get", NULL, 0, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); } - _2 = !zephir_is_true(method); - if (_2) { + _4 = !zephir_is_true(method); + if (_4) { ZEPHIR_INIT_NVAR(_1); ZEPHIR_GET_CONSTANT(_1, "PHP_SAPI"); - _2 = ZEPHIR_IS_STRING_IDENTICAL(_1, "cli"); + _4 = ZEPHIR_IS_STRING_IDENTICAL(_1, "cli"); } - if (_2) { + if (_4) { ZEPHIR_INIT_NVAR(method); ZVAL_STRING(method, "GET", 1); - zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC); ZEPHIR_OBS_VAR(argv); - zephir_array_fetch_string(&argv, _SERVER, SL("argv"), PH_NOISY, "ice/mvc/app.zep", 45 TSRMLS_CC); - _3 = !zephir_is_true(uri); - if (_3) { - _3 = zephir_array_isset_long(argv, 1); + zephir_array_fetch_string(&argv, _SERVER, SL("argv"), PH_NOISY, "ice/mvc/app.zep", 60 TSRMLS_CC); + _5 = !zephir_is_true(uri); + if (_5) { + _5 = zephir_array_isset_long(argv, 1); } - if (_3) { + if (_5) { ZEPHIR_OBS_NVAR(uri); - zephir_array_fetch_long(&uri, argv, 1, PH_NOISY, "ice/mvc/app.zep", 48 TSRMLS_CC); + zephir_array_fetch_long(&uri, argv, 1, PH_NOISY, "ice/mvc/app.zep", 63 TSRMLS_CC); } } - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&router, _4, "getrouter", NULL); + _6 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_NVAR(_2); + ZVAL_STRING(_2, "router", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_3); + ZVAL_NULL(_3); + ZEPHIR_INIT_VAR(_7); + ZVAL_BOOL(_7, 1); + ZEPHIR_CALL_METHOD(&router, _6, "get", NULL, 0, _2, _3, _7); + zephir_check_temp_parameter(_2); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&response, router, "handle", NULL, method, uri); + ZEPHIR_CALL_METHOD(&response, router, "handle", NULL, 0, method, uri); zephir_check_call_status(); - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&dispatcher, _5, "getdispatcher", NULL); + _8 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_NVAR(_2); + ZVAL_STRING(_2, "dispatcher", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_3); + ZVAL_NULL(_3); + ZEPHIR_INIT_NVAR(_7); + ZVAL_BOOL(_7, 1); + ZEPHIR_CALL_METHOD(&dispatcher, _8, "get", NULL, 0, _2, _3, _7); + zephir_check_temp_parameter(_2); zephir_check_call_status(); - _6 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_7); - array_init_size(_7, 2); - zephir_array_fast_append(_7, response); - ZEPHIR_INIT_NVAR(_1); - ZVAL_STRING(_1, "app.after.router.handle", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _6, "applyhook", NULL, _1, _7); - zephir_check_temp_parameter(_1); + _9 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_10); + zephir_create_array(_10, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_10, response); + ZEPHIR_INIT_NVAR(_2); + ZVAL_STRING(_2, "app.after.router.handle", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _9, "applyhook", NULL, 0, _2, _10); + zephir_check_temp_parameter(_2); zephir_check_call_status(); - _3 = Z_TYPE_P(response) == IS_OBJECT; - if (_3) { - _3 = (zephir_instance_of_ev(response, ice_http_response_responseinterface_ce TSRMLS_CC)); + _5 = Z_TYPE_P(response) == IS_OBJECT; + if (_5) { + _5 = (zephir_instance_of_ev(response, ice_http_response_responseinterface_ce TSRMLS_CC)); } - if (!(_3)) { - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_modules"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmodules", NULL, _8); + if (!(_5)) { + _11 = zephir_fetch_nproperty_this(this_ptr, SL("modules"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmodules", NULL, 0, _11); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmethod", NULL, method); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmethod", NULL, 0, method); zephir_check_call_status(); - zephir_array_fetch_string(&_9, response, SL("module"), PH_NOISY | PH_READONLY, "ice/mvc/app.zep", 61 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmodule", NULL, _9); + zephir_array_fetch_string(&_12, response, SL("module"), PH_NOISY | PH_READONLY, "ice/mvc/app.zep", 76 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "setmodule", NULL, 0, _12); zephir_check_call_status(); - zephir_array_fetch_string(&_10, response, SL("handler"), PH_NOISY | PH_READONLY, "ice/mvc/app.zep", 62 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "sethandler", NULL, _10); + zephir_array_fetch_string(&_13, response, SL("handler"), PH_NOISY | PH_READONLY, "ice/mvc/app.zep", 77 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "sethandler", NULL, 0, _13); zephir_check_call_status(); - zephir_array_fetch_string(&_11, response, SL("action"), PH_NOISY | PH_READONLY, "ice/mvc/app.zep", 63 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "setaction", NULL, _11); + zephir_array_fetch_string(&_14, response, SL("action"), PH_NOISY | PH_READONLY, "ice/mvc/app.zep", 78 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "setaction", NULL, 0, _14); zephir_check_call_status(); - zephir_array_fetch_string(&_12, response, SL("params"), PH_NOISY | PH_READONLY, "ice/mvc/app.zep", 64 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, dispatcher, "setparams", NULL, _12); + zephir_array_fetch_string(&_15, response, SL("params"), PH_NOISY | PH_READONLY, "ice/mvc/app.zep", 79 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, dispatcher, "setparams", NULL, 0, _15); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&response, dispatcher, "dispatch", NULL); + ZEPHIR_CALL_METHOD(&response, dispatcher, "dispatch", NULL, 0); zephir_check_call_status(); - _13 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_14); - array_init_size(_14, 2); - zephir_array_fast_append(_14, response); - ZEPHIR_INIT_NVAR(_1); - ZVAL_STRING(_1, "app.after.dispatcher.dispatch", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _13, "applyhook", NULL, _1, _14); - zephir_check_temp_parameter(_1); + ZEPHIR_CALL_METHOD(&returned, dispatcher, "getreturnedvalue", NULL, 0); zephir_check_call_status(); - _15 = Z_TYPE_P(response) == IS_OBJECT; - if (_15) { - _15 = (zephir_instance_of_ev(response, ice_http_response_responseinterface_ce TSRMLS_CC)); + _16 = Z_TYPE_P(returned) == IS_OBJECT; + if (_16) { + _16 = (zephir_instance_of_ev(returned, ice_http_response_responseinterface_ce TSRMLS_CC)); } - if (!(_15)) { + if (_16) { + ZEPHIR_CPY_WRT(response, returned); + } + _17 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_18); + zephir_create_array(_18, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_18, response); + ZEPHIR_INIT_NVAR(_2); + ZVAL_STRING(_2, "app.after.dispatcher.dispatch", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _17, "applyhook", NULL, 0, _2, _18); + zephir_check_temp_parameter(_2); + zephir_check_call_status(); + _19 = Z_TYPE_P(response) == IS_OBJECT; + if (_19) { + _19 = (zephir_instance_of_ev(response, ice_http_response_responseinterface_ce TSRMLS_CC)); + } + if (!(_19)) { ZEPHIR_CPY_WRT(controller, response); - _16 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&response, _16, "getresponse", NULL); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(_17); - zephir_read_property(&_17, controller, SL("view"), PH_NOISY_CC); - ZEPHIR_CPY_WRT(view, _17); - ZEPHIR_CALL_METHOD(&_18, view, "getcontent", NULL); + _20 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_NVAR(_2); + ZVAL_STRING(_2, "response", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_INIT_NVAR(_3); + ZVAL_NULL(_3); + ZEPHIR_INIT_NVAR(_7); + ZVAL_BOOL(_7, 1); + ZEPHIR_CALL_METHOD(&response, _20, "get", NULL, 0, _2, _3, _7); + zephir_check_temp_parameter(_2); zephir_check_call_status(); - if (Z_TYPE_P(_18) == IS_NULL) { - ZEPHIR_CALL_METHOD(&_19, view, "getfile", NULL); + ZEPHIR_OBS_VAR(_21); + zephir_read_property(&_21, controller, SL("view"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(view, _21); + _22 = zephir_fetch_nproperty_this(this_ptr, SL("autoRender"), PH_NOISY_CC); + if (zephir_is_true(_22)) { + ZEPHIR_CALL_METHOD(&_23, view, "getcontent", NULL, 0); zephir_check_call_status(); - if (!(zephir_is_true(_19))) { - ZEPHIR_INIT_NVAR(_1); - ZVAL_BOOL(_1, 1); - ZEPHIR_CALL_METHOD(NULL, view, "setsilent", NULL, _1); + if (Z_TYPE_P(_23) == IS_NULL) { + ZEPHIR_CALL_METHOD(&_24, view, "getfile", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_20, dispatcher, "gethandler", NULL); + if (!(zephir_is_true(_24))) { + ZEPHIR_INIT_NVAR(_2); + ZVAL_BOOL(_2, 1); + ZEPHIR_CALL_METHOD(NULL, view, "setsilent", NULL, 0, _2); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_25, dispatcher, "gethandler", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_26, dispatcher, "getaction", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(_27); + ZEPHIR_CONCAT_VSV(_27, _25, "/", _26); + ZEPHIR_CALL_METHOD(NULL, view, "setfile", NULL, 0, _27); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&_25, view, "count", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_21, dispatcher, "getaction", NULL); + if (!(zephir_is_true(_25))) { + ZEPHIR_CALL_METHOD(&_26, dispatcher, "getparams", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, view, "replace", NULL, 0, _26); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&_25, view, "render", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_22); - ZEPHIR_CONCAT_VSV(_22, _20, "/", _21); - ZEPHIR_CALL_METHOD(NULL, view, "setfile", NULL, _22); + ZEPHIR_CALL_METHOD(NULL, view, "setcontent", NULL, 0, _25); zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(&_20, view, "count", NULL); + ZEPHIR_CALL_METHOD(&_26, view, "getmainview", NULL, 0); zephir_check_call_status(); - if (!(zephir_is_true(_20))) { - ZEPHIR_CALL_METHOD(&_21, dispatcher, "getparams", NULL); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, view, "replace", NULL, _21); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&_20, view, "render", NULL); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, view, "setcontent", NULL, _20); + ZEPHIR_CALL_METHOD(&_24, view, "layout", NULL, 0, _26); zephir_check_call_status(); - } - _23 = zephir_fetch_nproperty_this(this_ptr, SL("_autoRender"), PH_NOISY_CC); - if (zephir_is_true(_23)) { - ZEPHIR_CALL_METHOD(&_21, view, "getmainview", NULL); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_19, view, "layout", NULL, _21); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, response, "setbody", NULL, _19); + ZEPHIR_CALL_METHOD(NULL, response, "setbody", NULL, 0, _24); zephir_check_call_status(); } } } - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_INIT_NVAR(_14); - array_init_size(_14, 2); - zephir_array_fast_append(_14, response); - ZEPHIR_INIT_NVAR(_1); - ZVAL_STRING(_1, "app.after.handle", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _8, "applyhook", NULL, _1, _14); - zephir_check_temp_parameter(_1); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_NVAR(_18); + zephir_create_array(_18, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_18, response); + ZEPHIR_INIT_NVAR(_2); + ZVAL_STRING(_2, "app.after.handle", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _11, "applyhook", NULL, 0, _2, _18); + zephir_check_temp_parameter(_2); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(response, "send", NULL); + ZEPHIR_RETURN_CALL_METHOD(response, "send", NULL, 0); zephir_check_call_status(); RETURN_MM(); diff --git a/ext/ice/mvc/app.zep.h b/ext/ice/mvc/app.zep.h index 049a4db5..4711bde8 100644 --- a/ext/ice/mvc/app.zep.h +++ b/ext/ice/mvc/app.zep.h @@ -7,6 +7,7 @@ PHP_METHOD(Ice_Mvc_App, getAutoRender); PHP_METHOD(Ice_Mvc_App, setAutoRender); PHP_METHOD(Ice_Mvc_App, getModules); PHP_METHOD(Ice_Mvc_App, setModules); +PHP_METHOD(Ice_Mvc_App, __construct); PHP_METHOD(Ice_Mvc_App, handle); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_app_setautorender, 0, 0, 1) @@ -17,6 +18,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_app_setmodules, 0, 0, 1) ZEND_ARG_INFO(0, modules) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_app___construct, 0, 0, 0) + ZEND_ARG_OBJ_INFO(0, di, Ice\\Di, 1) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_app_handle, 0, 0, 0) ZEND_ARG_INFO(0, method) ZEND_ARG_INFO(0, uri) @@ -27,6 +32,7 @@ ZEPHIR_INIT_FUNCS(ice_mvc_app_method_entry) { PHP_ME(Ice_Mvc_App, setAutoRender, arginfo_ice_mvc_app_setautorender, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_App, getModules, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_App, setModules, arginfo_ice_mvc_app_setmodules, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Mvc_App, __construct, arginfo_ice_mvc_app___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Mvc_App, handle, arginfo_ice_mvc_app_handle, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/controller.zep.c b/ext/ice/mvc/controller.zep.c index 3aa7652a..1bdd884a 100644 --- a/ext/ice/mvc/controller.zep.c +++ b/ext/ice/mvc/controller.zep.c @@ -41,14 +41,14 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Controller) { PHP_METHOD(Ice_Mvc_Controller, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_0 = NULL; + zephir_fcall_cache_entry *_0 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_CALL_PARENT(NULL, ice_mvc_controller_ce, this_ptr, "__construct", &_0); + ZEPHIR_CALL_PARENT(NULL, ice_mvc_controller_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); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); diff --git a/ext/ice/mvc/controller.zep.h b/ext/ice/mvc/controller.zep.h index ac41cd33..1f95cb6d 100644 --- a/ext/ice/mvc/controller.zep.h +++ b/ext/ice/mvc/controller.zep.h @@ -7,5 +7,5 @@ PHP_METHOD(Ice_Mvc_Controller, __construct); ZEPHIR_INIT_FUNCS(ice_mvc_controller_method_entry) { PHP_ME(Ice_Mvc_Controller, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL|ZEND_ACC_CTOR) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/dispatcher.zep.c b/ext/ice/mvc/dispatcher.zep.c index c093363e..4569fffe 100644 --- a/ext/ice/mvc/dispatcher.zep.c +++ b/ext/ice/mvc/dispatcher.zep.c @@ -33,9 +33,9 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Dispatcher) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Mvc, Dispatcher, ice, mvc_dispatcher, ice_dispatcher_ce, ice_mvc_dispatcher_method_entry, 0); - zend_declare_property_null(ice_mvc_dispatcher_ce, SL("_method"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_dispatcher_ce, SL("method"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_mvc_dispatcher_ce, SL("_handlerSuffix"), "Controller", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_mvc_dispatcher_ce, SL("handlerSuffix"), "Controller", ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -44,7 +44,7 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Dispatcher) { PHP_METHOD(Ice_Mvc_Dispatcher, getMethod) { - RETURN_MEMBER(this_ptr, "_method"); + RETURN_MEMBER(this_ptr, "method"); } @@ -56,7 +56,7 @@ PHP_METHOD(Ice_Mvc_Dispatcher, setMethod) { - zephir_update_property_this(this_ptr, SL("_method"), method TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("method"), method TSRMLS_CC); } @@ -68,25 +68,25 @@ PHP_METHOD(Ice_Mvc_Dispatcher, setMethod) { PHP_METHOD(Ice_Mvc_Dispatcher, getActiveMethod) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_6 = NULL; - zval *action, *_0, *_1, *_2, *_3, *_4, *_5; + zephir_fcall_cache_entry *_6 = NULL; + zval *action = NULL, *_0, *_1, *_2, *_3, *_4, *_5; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_method"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("method"), PH_NOISY_CC); zephir_fast_strtolower(_0, _1); ZEPHIR_INIT_VAR(_2); - _3 = zephir_fetch_nproperty_this(this_ptr, SL("_action"), PH_NOISY_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("action"), PH_NOISY_CC); zephir_ucfirst(_2, _3); - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_actionSuffix"), PH_NOISY_CC); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("actionSuffix"), PH_NOISY_CC); ZEPHIR_INIT_VAR(action); ZEPHIR_CONCAT_VVV(action, _0, _2, _4); - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_activeHandler"), PH_NOISY_CC); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("activeHandler"), PH_NOISY_CC); if ((zephir_method_exists(_5, action TSRMLS_CC) == SUCCESS)) { RETURN_CCTOR(action); } - ZEPHIR_RETURN_CALL_PARENT(ice_mvc_dispatcher_ce, this_ptr, "getactivemethod", &_6); + ZEPHIR_RETURN_CALL_PARENT(ice_mvc_dispatcher_ce, this_ptr, "getactivemethod", &_6, 122); zephir_check_call_status(); RETURN_MM(); diff --git a/ext/ice/mvc/dispatcher.zep.h b/ext/ice/mvc/dispatcher.zep.h index b5a86b0d..b1fdad6c 100644 --- a/ext/ice/mvc/dispatcher.zep.h +++ b/ext/ice/mvc/dispatcher.zep.h @@ -15,5 +15,5 @@ ZEPHIR_INIT_FUNCS(ice_mvc_dispatcher_method_entry) { PHP_ME(Ice_Mvc_Dispatcher, getMethod, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Dispatcher, setMethod, arginfo_ice_mvc_dispatcher_setmethod, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Dispatcher, getActiveMethod, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/model.zep.c b/ext/ice/mvc/model.zep.c index 97f22c58..73eab381 100644 --- a/ext/ice/mvc/model.zep.c +++ b/ext/ice/mvc/model.zep.c @@ -18,37 +18,49 @@ #include "kernel/array.h" #include "kernel/operators.h" #include "kernel/string.h" +#include "kernel/exception.h" #include "kernel/iterator.h" #include "kernel/hash.h" -#include "kernel/exception.h" #include "ext/spl/spl_exceptions.h" + +/** + * Model connects business objects and database tables to create a persistable domain model where logic and data are + * presented in one wrapping (ORM & ODM). + * + * @package Ice/Db + * @category Component + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + */ ZEPHIR_INIT_CLASS(Ice_Mvc_Model) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Mvc, Model, ice, mvc_model, ice_arr_ce, ice_mvc_model_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(ice_mvc_model_ce, SL("_di"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_db"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("db"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_from"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("from"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_primary"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("primary"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_filters"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("filters"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_fields"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("fields"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_validation"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("validation"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_relations"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("relations"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_labels"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("labels"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_rules"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("rules"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_model_ce, SL("_messages"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_model_ce, SL("messages"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_mvc_model_ce->create_object = zephir_init_properties_Ice_Mvc_Model; zend_declare_class_constant_long(ice_mvc_model_ce, SL("BELONGS_TO"), 1 TSRMLS_CC); zend_declare_class_constant_long(ice_mvc_model_ce, SL("HAS_ONE"), 2 TSRMLS_CC); @@ -63,14 +75,14 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Model) { PHP_METHOD(Ice_Mvc_Model, getDi) { - RETURN_MEMBER(this_ptr, "_di"); + RETURN_MEMBER(this_ptr, "di"); } PHP_METHOD(Ice_Mvc_Model, getDb) { - RETURN_MEMBER(this_ptr, "_db"); + RETURN_MEMBER(this_ptr, "db"); } @@ -82,7 +94,7 @@ PHP_METHOD(Ice_Mvc_Model, setFrom) { - zephir_update_property_this(this_ptr, SL("_from"), from TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("from"), from TSRMLS_CC); } @@ -94,14 +106,14 @@ PHP_METHOD(Ice_Mvc_Model, setPrimary) { - zephir_update_property_this(this_ptr, SL("_primary"), primary TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("primary"), primary TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Model, getPrimary) { - RETURN_MEMBER(this_ptr, "_primary"); + RETURN_MEMBER(this_ptr, "primary"); } @@ -113,14 +125,14 @@ PHP_METHOD(Ice_Mvc_Model, setFilters) { - zephir_update_property_this(this_ptr, SL("_filters"), filters TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("filters"), filters TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Model, getFilters) { - RETURN_MEMBER(this_ptr, "_filters"); + RETURN_MEMBER(this_ptr, "filters"); } @@ -132,14 +144,14 @@ PHP_METHOD(Ice_Mvc_Model, setFields) { - zephir_update_property_this(this_ptr, SL("_fields"), fields TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("fields"), fields TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Model, getFields) { - RETURN_MEMBER(this_ptr, "_fields"); + RETURN_MEMBER(this_ptr, "fields"); } @@ -151,21 +163,21 @@ PHP_METHOD(Ice_Mvc_Model, setValidation) { - zephir_update_property_this(this_ptr, SL("_validation"), validation TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("validation"), validation TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Model, getValidation) { - RETURN_MEMBER(this_ptr, "_validation"); + RETURN_MEMBER(this_ptr, "validation"); } PHP_METHOD(Ice_Mvc_Model, getRelations) { - RETURN_MEMBER(this_ptr, "_relations"); + RETURN_MEMBER(this_ptr, "relations"); } @@ -177,14 +189,26 @@ PHP_METHOD(Ice_Mvc_Model, setLabels) { - zephir_update_property_this(this_ptr, SL("_labels"), labels TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("labels"), labels TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Model, getMessages) { - RETURN_MEMBER(this_ptr, "_messages"); + RETURN_MEMBER(this_ptr, "messages"); + +} + +PHP_METHOD(Ice_Mvc_Model, setMessages) { + + zval *messages; + + zephir_fetch_params(0, 1, 0, &messages); + + + + zephir_update_property_this(this_ptr, SL("messages"), messages TSRMLS_CC); } @@ -197,9 +221,9 @@ PHP_METHOD(Ice_Mvc_Model, getMessages) { PHP_METHOD(Ice_Mvc_Model, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_6 = NULL, *_11 = NULL, *_12 = NULL; + zephir_fcall_cache_entry *_0 = NULL, *_7 = NULL; zval *data = NULL; - zval *filters = NULL, *data_param = NULL, *_0, *_1, *_2, *_3, *_4, *_5, *di = NULL, *_7 = NULL, *_8, *_9, *_10 = NULL, *_13, *_14, *_15, *_16, *_17, *_18 = NULL; + zval *filters = NULL, *data_param = NULL, *di = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_5, *_6 = NULL, *_8, *_9, *_10, *_11 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &filters, &data_param); @@ -215,92 +239,133 @@ PHP_METHOD(Ice_Mvc_Model, __construct) { } - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_messages"), _0 TSRMLS_CC); - ZEPHIR_INIT_VAR(_1); - array_init(_1); - zephir_update_property_this(this_ptr, SL("_rules"), _1 TSRMLS_CC); + ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_0, 8); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("di"), di TSRMLS_CC); ZEPHIR_INIT_VAR(_2); - array_init(_2); - zephir_update_property_this(this_ptr, SL("_labels"), _2 TSRMLS_CC); + ZVAL_STRING(_2, "db", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_3); - array_init(_3); - zephir_update_property_this(this_ptr, SL("_relations"), _3 TSRMLS_CC); + ZVAL_NULL(_3); ZEPHIR_INIT_VAR(_4); - array_init(_4); - zephir_update_property_this(this_ptr, SL("_fields"), _4 TSRMLS_CC); - ZEPHIR_INIT_VAR(_5); - array_init(_5); - zephir_update_property_this(this_ptr, SL("_filters"), _5 TSRMLS_CC); - ZEPHIR_CALL_CE_STATIC(&di, ice_di_ce, "fetch", &_6); + ZVAL_BOOL(_4, 1); + ZEPHIR_CALL_METHOD(&_1, di, "get", NULL, 0, _2, _3, _4); + zephir_check_temp_parameter(_2); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_di"), di TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_7, di, "getdb", NULL); + zephir_update_property_this(this_ptr, SL("db"), _1 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_2); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("fields"), PH_NOISY_CC); + ZEPHIR_CALL_FUNCTION(&_6, "array_fill_keys", NULL, 9, _5, ZEPHIR_GLOBAL(global_null)); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_db"), _7 TSRMLS_CC); - ZEPHIR_INIT_VAR(_8); - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_fields"), PH_NOISY_CC); - ZEPHIR_CALL_FUNCTION(&_10, "array_fill_keys", &_11, _9, ZEPHIR_GLOBAL(global_null)); + zephir_fast_array_merge(_2, &(_6), &(data) TSRMLS_CC); + ZEPHIR_CPY_WRT(data, _2); + ZEPHIR_CALL_PARENT(NULL, ice_mvc_model_ce, this_ptr, "__construct", &_7, 6, data); zephir_check_call_status(); - zephir_fast_array_merge(_8, &(_10), &(data) TSRMLS_CC); - ZEPHIR_CPY_WRT(data, _8); - ZEPHIR_CALL_PARENT(NULL, ice_mvc_model_ce, this_ptr, "__construct", &_12, data); - zephir_check_call_status(); - _13 = zephir_fetch_nproperty_this(this_ptr, SL("_from"), PH_NOISY_CC); - if (!(zephir_is_true(_13))) { - ZEPHIR_INIT_VAR(_14); - ZEPHIR_INIT_VAR(_15); - zephir_get_class_ns(_15, this_ptr, 0 TSRMLS_CC); - zephir_uncamelize(_14, _15); - zephir_update_property_this(this_ptr, SL("_from"), _14 TSRMLS_CC); + _8 = zephir_fetch_nproperty_this(this_ptr, SL("from"), PH_NOISY_CC); + if (!(zephir_is_true(_8))) { + ZEPHIR_INIT_NVAR(_3); + ZEPHIR_INIT_NVAR(_4); + zephir_get_class_ns(_4, this_ptr, 0 TSRMLS_CC); + zephir_uncamelize(_3, _4); + zephir_update_property_this(this_ptr, SL("from"), _3 TSRMLS_CC); } - _16 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); - if (!(zephir_is_true(_16))) { - _17 = zephir_fetch_nproperty_this(this_ptr, SL("_db"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_18, _17, "getid", NULL); + _9 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); + if (!(zephir_is_true(_9))) { + _10 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_11, _10, "getid", NULL, 0); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_primary"), _18 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("primary"), _11 TSRMLS_CC); } if ((zephir_method_exists_ex(this_ptr, SS("onconstruct") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); zephir_check_call_status(); } if (zephir_is_true(filters)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "loadone", NULL, filters); + ZEPHIR_CALL_METHOD(&_11, this_ptr, "loadone", NULL, 0, filters); zephir_check_call_status(); + if (!(zephir_is_true(_11))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Not Found", "ice/mvc/model.zep", 70); + return; + } } if ((zephir_method_exists_ex(this_ptr, SS("initialize") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } +/** + * Get the id. + * + * @return mixed + */ +PHP_METHOD(Ice_Mvc_Model, getId) { + + int ZEPHIR_LAST_CALL_STATUS; + zval *_0 = NULL; + + ZEPHIR_MM_GROW(); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getidkey", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, _0); + zephir_check_call_status(); + RETURN_MM(); + +} + +/** + * Get the id key depending on db driver. + * + * @return string + */ +PHP_METHOD(Ice_Mvc_Model, getIdKey) { + + int ZEPHIR_LAST_CALL_STATUS; + zval *_0; + + ZEPHIR_MM_GROW(); + + _0 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "getid", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + +} + /** * Load one result to the current object. * * @param mixed filters + * @param array options + * @return this|false */ PHP_METHOD(Ice_Mvc_Model, loadOne) { int ZEPHIR_LAST_CALL_STATUS; - zval *filters, *result = NULL, *_0, *_1, *_2 = NULL; + zval *options = NULL; + zval *filters, *options_param = NULL, *result = NULL, *_0, *_1, *_2 = NULL; ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &filters); + zephir_fetch_params(1, 1, 1, &filters, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(options); + array_init(options); + } else { + zephir_get_arrval(options, options_param); + } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_db"), PH_NOISY_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_from"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&result, _0, "findone", NULL, _1, filters); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("from"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&result, _0, "findone", NULL, 0, _1, filters, options); zephir_check_call_status(); if (zephir_is_true(result)) { - ZEPHIR_CALL_METHOD(&_2, result, "all", NULL); + ZEPHIR_CALL_METHOD(&_2, result, "all", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", NULL, _2); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", NULL, 0, _2); zephir_check_call_status(); RETURN_THIS(); } else { @@ -313,14 +378,15 @@ PHP_METHOD(Ice_Mvc_Model, loadOne) { * Load results to the current object. * * @param mixed filters - * @return Arr + * @param array options + * @return object Arr */ PHP_METHOD(Ice_Mvc_Model, load) { zend_object_iterator *_3; int ZEPHIR_LAST_CALL_STATUS; zval *options = NULL, *_6 = NULL; - zval *filters, *options_param = NULL, *result = NULL, *instances, *data = NULL, *_0, *_1, *_2 = NULL, *_4 = NULL, *_5 = NULL; + zval *filters, *options_param = NULL, *result = NULL, *instances = NULL, *data = NULL, *_0, *_1, *_2 = NULL, *_4 = NULL, *_5 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &filters, &options_param); @@ -333,37 +399,38 @@ PHP_METHOD(Ice_Mvc_Model, load) { } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_db"), PH_NOISY_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_from"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&result, _0, "find", NULL, _1, filters, options); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("from"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&result, _0, "find", NULL, 0, _1, filters, options); zephir_check_call_status(); ZEPHIR_INIT_VAR(instances); array_init(instances); - ZEPHIR_CALL_METHOD(&_2, result, "count", NULL); + ZEPHIR_CALL_METHOD(&_2, result, "count", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_2)) { _3 = zephir_get_iterator(result TSRMLS_CC); _3->funcs->rewind(_3 TSRMLS_CC); for (;_3->funcs->valid(_3 TSRMLS_CC) == SUCCESS && !EG(exception); _3->funcs->move_forward(_3 TSRMLS_CC)) { - { zval **tmp; - _3->funcs->get_current_data(_3, &tmp TSRMLS_CC); - data = *tmp; + { + zval **ZEPHIR_TMP_ITERATOR_PTR; + _3->funcs->get_current_data(_3, &ZEPHIR_TMP_ITERATOR_PTR TSRMLS_CC); + ZEPHIR_CPY_WRT(data, (*ZEPHIR_TMP_ITERATOR_PTR)); } ZEPHIR_INIT_NVAR(_4); ZEPHIR_INIT_NVAR(_5); zephir_get_called_class(_5 TSRMLS_CC); ZEPHIR_INIT_NVAR(_6); - array_init_size(_6, 3); + zephir_create_array(_6, 2, 0 TSRMLS_CC); zephir_array_fast_append(_6, ZEPHIR_GLOBAL(global_null)); zephir_array_fast_append(_6, data); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(_4, _5, _6 TSRMLS_CC); zephir_check_call_status(); - zephir_array_append(&instances, _4, PH_SEPARATE, "ice/mvc/model.zep", 111); + zephir_array_append(&instances, _4, PH_SEPARATE, "ice/mvc/model.zep", 136); } _3->funcs->dtor(_3 TSRMLS_CC); } object_init_ex(return_value, ice_arr_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, instances); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 6, instances); zephir_check_call_status(); RETURN_MM(); @@ -382,37 +449,37 @@ PHP_METHOD(Ice_Mvc_Model, load) { * * * @param array filters - * @return Model|false + * @param array options + * @return this|false */ PHP_METHOD(Ice_Mvc_Model, findOne) { - zval *_0; int ZEPHIR_LAST_CALL_STATUS; - zval *filters = NULL, *result, *model, *_1 = NULL; + zval *options = NULL; + zval *filters = NULL, *options_param = NULL, *result = NULL, *model = NULL, *instance = NULL; ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &filters); + zephir_fetch_params(1, 0, 2, &filters, &options_param); if (!filters) { filters = ZEPHIR_GLOBAL(global_null); } + if (!options_param) { + ZEPHIR_INIT_VAR(options); + array_init(options); + } else { + zephir_get_arrval(options, options_param); + } ZEPHIR_INIT_VAR(model); zephir_get_called_class(model TSRMLS_CC); - ZEPHIR_INIT_VAR(result); - ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 2); - zephir_array_fast_append(_0, filters); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(result, model, _0 TSRMLS_CC); + ZEPHIR_INIT_VAR(instance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, model TSRMLS_CC); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, result, "count", NULL); + ZEPHIR_CALL_METHOD(&result, instance, "loadone", NULL, 0, filters, options); zephir_check_call_status(); - if (!(zephir_is_true(_1))) { - RETURN_MM_BOOL(0); - } else { - RETURN_CCTOR(result); - } + RETURN_CCTOR(result); } @@ -425,13 +492,14 @@ PHP_METHOD(Ice_Mvc_Model, findOne) { * * * @param array filters - * @return Arr + * @param array options + * @return object Arr */ PHP_METHOD(Ice_Mvc_Model, find) { int ZEPHIR_LAST_CALL_STATUS; zval *options = NULL; - zval *filters = NULL, *options_param = NULL, *result = NULL, *model, *instance; + zval *filters = NULL, *options_param = NULL, *result = NULL, *model = NULL, *instance = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &filters, &options_param); @@ -452,7 +520,7 @@ PHP_METHOD(Ice_Mvc_Model, find) { ZEPHIR_INIT_VAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, model TSRMLS_CC); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, instance, "load", NULL, filters, options); + ZEPHIR_CALL_METHOD(&result, instance, "load", NULL, 0, filters, options); zephir_check_call_status(); RETURN_CCTOR(result); @@ -461,17 +529,19 @@ PHP_METHOD(Ice_Mvc_Model, find) { /** * 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 */ PHP_METHOD(Ice_Mvc_Model, fields) { - zephir_nts_static zephir_fcall_cache_entry *_4 = NULL, *_8 = NULL, *_9 = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_8 = NULL, *_9 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *fields = NULL, *_0, *_1 = NULL, _2 = zval_used_for_init, *_3 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_10, *_11 = NULL, *_12, *_13; + zend_bool primary, _14; + zval *fields = NULL, *primary_param = NULL, *_0, *_1 = NULL, _2 = zval_used_for_init, *_3 = NULL, *_5 = NULL, *_6 = NULL, *_7 = NULL, *_10, *_11 = NULL, *_12, *_13; ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &fields); + zephir_fetch_params(1, 0, 2, &fields, &primary_param); if (!fields) { ZEPHIR_INIT_VAR(fields); @@ -479,78 +549,87 @@ PHP_METHOD(Ice_Mvc_Model, fields) { } else { ZEPHIR_SEPARATE_PARAM(fields); } + if (!primary_param) { + primary = 1; + } else { + primary = zephir_get_boolval(primary_param); + } - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_fields"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("fields"), PH_NOISY_CC); if (!(zephir_fast_count_int(_0 TSRMLS_CC))) { if (!(zephir_fast_count_int(fields TSRMLS_CC))) { - ZEPHIR_CALL_METHOD(&fields, this_ptr, "all", NULL); + ZEPHIR_CALL_METHOD(&fields, this_ptr, "all", NULL, 0); zephir_check_call_status(); } else { ZEPHIR_INIT_VAR(_1); zephir_array_keys(_1, fields TSRMLS_CC); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "is_string", 0); - ZEPHIR_CALL_FUNCTION(&_3, "array_filter", &_4, _1, &_2); + ZEPHIR_CALL_FUNCTION(&_3, "array_filter", &_4, 10, _1, &_2); zephir_check_call_status(); if (zephir_fast_count_int(_3 TSRMLS_CC)) { ZEPHIR_INIT_VAR(_5); - ZEPHIR_CALL_METHOD(&_6, this_ptr, "all", NULL); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "all", NULL, 0); zephir_check_call_status(); zephir_fast_array_merge(_5, &(_6), &(fields) TSRMLS_CC); ZEPHIR_CPY_WRT(fields, _5); } else { - ZEPHIR_CALL_METHOD(&_6, this_ptr, "all", NULL); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "all", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_7, "array_flip", &_8, fields); + ZEPHIR_CALL_FUNCTION(&_7, "array_flip", &_8, 11, fields); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&fields, "array_intersect_key", &_9, _6, _7); + ZEPHIR_CALL_FUNCTION(&fields, "array_intersect_key", &_9, 12, _6, _7); zephir_check_call_status(); } } } else { if (!(zephir_fast_count_int(fields TSRMLS_CC))) { - ZEPHIR_CALL_METHOD(&_3, this_ptr, "all", NULL); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "all", NULL, 0); zephir_check_call_status(); - _10 = zephir_fetch_nproperty_this(this_ptr, SL("_fields"), PH_NOISY_CC); - ZEPHIR_CALL_FUNCTION(&_6, "array_flip", &_8, _10); + _10 = zephir_fetch_nproperty_this(this_ptr, SL("fields"), PH_NOISY_CC); + ZEPHIR_CALL_FUNCTION(&_6, "array_flip", &_8, 11, _10); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&fields, "array_intersect_key", &_9, _3, _6); + ZEPHIR_CALL_FUNCTION(&fields, "array_intersect_key", &_9, 12, _3, _6); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(_1); zephir_array_keys(_1, fields TSRMLS_CC); ZEPHIR_SINIT_NVAR(_2); ZVAL_STRING(&_2, "is_string", 0); - ZEPHIR_CALL_FUNCTION(&_3, "array_filter", &_4, _1, &_2); + ZEPHIR_CALL_FUNCTION(&_3, "array_filter", &_4, 10, _1, &_2); zephir_check_call_status(); if (zephir_fast_count_int(_3 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_5); - ZEPHIR_CALL_METHOD(&_7, this_ptr, "all", NULL); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "all", NULL, 0); zephir_check_call_status(); zephir_fast_array_merge(_5, &(_7), &(fields) TSRMLS_CC); - _10 = zephir_fetch_nproperty_this(this_ptr, SL("_fields"), PH_NOISY_CC); - ZEPHIR_CALL_FUNCTION(&_11, "array_flip", &_8, _10); + _10 = zephir_fetch_nproperty_this(this_ptr, SL("fields"), PH_NOISY_CC); + ZEPHIR_CALL_FUNCTION(&_11, "array_flip", &_8, 11, _10); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&fields, "array_intersect_key", &_9, _5, _11); + ZEPHIR_CALL_FUNCTION(&fields, "array_intersect_key", &_9, 12, _5, _11); zephir_check_call_status(); } else { - ZEPHIR_CALL_METHOD(&_6, this_ptr, "all", NULL); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "all", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_7, "array_flip", &_8, fields); + ZEPHIR_CALL_FUNCTION(&_7, "array_flip", &_8, 11, fields); zephir_check_call_status(); - _12 = zephir_fetch_nproperty_this(this_ptr, SL("_fields"), PH_NOISY_CC); - ZEPHIR_CALL_FUNCTION(&_11, "array_flip", &_8, _12); + _12 = zephir_fetch_nproperty_this(this_ptr, SL("fields"), PH_NOISY_CC); + ZEPHIR_CALL_FUNCTION(&_11, "array_flip", &_8, 11, _12); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&fields, "array_intersect_key", &_9, _6, _7, _11); + ZEPHIR_CALL_FUNCTION(&fields, "array_intersect_key", &_9, 12, _6, _7, _11); zephir_check_call_status(); } } } ZEPHIR_OBS_VAR(_13); - zephir_read_property_this(&_13, this_ptr, SL("_primary"), PH_NOISY_CC); - if (Z_TYPE_P(_13) == IS_STRING) { - _10 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); + zephir_read_property_this(&_13, this_ptr, SL("primary"), PH_NOISY_CC); + _14 = Z_TYPE_P(_13) == IS_STRING; + if (_14) { + _14 = !primary; + } + if (_14) { + _10 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); zephir_array_unset(&fields, _10, PH_SEPARATE); } RETVAL_ZVAL(fields, 1, 0); @@ -574,10 +653,10 @@ PHP_METHOD(Ice_Mvc_Model, fields) { */ PHP_METHOD(Ice_Mvc_Model, create) { - zend_bool _6, _18, _19; - zval *_2, *_21; + zend_bool _8; + zval *_5, *_25, *_26, *_27; int ZEPHIR_LAST_CALL_STATUS; - zval *fields = NULL, *extra = NULL, *status = NULL, *valid = NULL, *extraValid = NULL, *messages = NULL, *extraMessages = NULL, *_0 = NULL, *_1, *_3 = NULL, *_4, *_5, *_7, *_8, *_9, *_10, *_11, *_12, *_13, *_14, *_15 = NULL, *_16, *_17 = NULL, *_20 = NULL, *_22 = NULL; + zval *fields = NULL, *extra = NULL, *status = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4, *_6, *_7, *_9, *_10, *_11, *_12, *_13, *_14, *_15, *_16, *_17, *_18, *_19 = NULL, *_20 = NULL, *_21, *_22, *_23 = NULL, *_24 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &fields, &extra); @@ -585,128 +664,137 @@ PHP_METHOD(Ice_Mvc_Model, create) { if (!fields) { ZEPHIR_INIT_VAR(fields); array_init(fields); - } else { - ZEPHIR_SEPARATE_PARAM(fields); } if (!extra) { extra = ZEPHIR_GLOBAL(global_null); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "fields", NULL, fields); + ZEPHIR_INIT_VAR(_1); + ZVAL_BOOL(_1, 0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "fields", NULL, 0, fields, _1); zephir_check_call_status(); - ZEPHIR_CPY_WRT(fields, _0); - ZEPHIR_INIT_VAR(extraValid); - ZVAL_BOOL(extraValid, 0); - ZEPHIR_INIT_VAR(extraMessages); - array_init(extraMessages); - ZEPHIR_INIT_VAR(valid); - ZVAL_BOOL(valid, 0); - ZEPHIR_INIT_VAR(messages); - array_init(messages); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", NULL, fields); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", NULL, 0, _0); zephir_check_call_status(); if (zephir_is_true(extra)) { - ZEPHIR_CALL_METHOD(&extraValid, extra, "validate", NULL); + ZEPHIR_CALL_METHOD(NULL, extra, "validate", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, extra, "getmessages", NULL); + ZEPHIR_CALL_METHOD(&_2, extra, "getmessages", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&extraMessages, _0, "all", NULL); + ZEPHIR_CALL_METHOD(&_3, _2, "all", NULL, 0); zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("messages"), _3 TSRMLS_CC); } - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 2); - zephir_array_fast_append(_2, this_ptr); - ZEPHIR_INIT_VAR(_3); - ZVAL_STRING(_3, "model.before.validate", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _1, "applyhook", NULL, _3, _2); - zephir_check_temp_parameter(_3); + _4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_5); + zephir_create_array(_5, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_5, this_ptr); + ZEPHIR_INIT_NVAR(_1); + ZVAL_STRING(_1, "model.before.validate", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _4, "applyhook", NULL, 0, _1, _5); + zephir_check_temp_parameter(_1); zephir_check_call_status(); - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_rules"), PH_NOISY_CC); - if (zephir_fast_count_int(_4 TSRMLS_CC)) { - ZEPHIR_OBS_VAR(_5); - zephir_read_property_this(&_5, this_ptr, SL("_validation"), PH_NOISY_CC); - _6 = Z_TYPE_P(_5) == IS_OBJECT; - if (_6) { - ZEPHIR_OBS_VAR(_7); - zephir_read_property_this(&_7, this_ptr, SL("_validation"), PH_NOISY_CC); - _6 = zephir_instance_of_ev(_7, ice_validation_ce TSRMLS_CC); + _6 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); + if (zephir_fast_count_int(_6 TSRMLS_CC)) { + ZEPHIR_OBS_VAR(_7); + zephir_read_property_this(&_7, this_ptr, SL("validation"), PH_NOISY_CC); + _8 = Z_TYPE_P(_7) == IS_OBJECT; + if (_8) { + ZEPHIR_OBS_VAR(_9); + zephir_read_property_this(&_9, this_ptr, SL("validation"), PH_NOISY_CC); + _8 = zephir_instance_of_ev(_9, ice_validation_ce TSRMLS_CC); } - if (!(_6)) { - ZEPHIR_INIT_NVAR(_3); - object_init_ex(_3, ice_validation_ce); - ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL); + if (!(_8)) { + ZEPHIR_INIT_NVAR(_1); + object_init_ex(_1, ice_validation_ce); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 13); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_validation"), _3 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("validation"), _1 TSRMLS_CC); } - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_validation"), PH_NOISY_CC); - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_rules"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _8, "rules", NULL, _9); + _10 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _10, "rules", NULL, 0, _11); zephir_check_call_status(); - _10 = zephir_fetch_nproperty_this(this_ptr, SL("_validation"), PH_NOISY_CC); - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _10, "setfilters", NULL, _11); + _12 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + _13 = zephir_fetch_nproperty_this(this_ptr, SL("filters"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _12, "setfilters", NULL, 0, _13); zephir_check_call_status(); - _12 = zephir_fetch_nproperty_this(this_ptr, SL("_validation"), PH_NOISY_CC); - _13 = zephir_fetch_nproperty_this(this_ptr, SL("_labels"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _12, "setlabels", NULL, _13); + _14 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + _15 = zephir_fetch_nproperty_this(this_ptr, SL("labels"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _14, "setlabels", NULL, 0, _15); zephir_check_call_status(); - _14 = zephir_fetch_nproperty_this(this_ptr, SL("_validation"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_15, this_ptr, "getdata", NULL); + _16 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getdata", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&valid, _14, "validate", NULL, _15); + ZEPHIR_CALL_METHOD(NULL, _16, "validate", NULL, 0, _2); zephir_check_call_status(); - _16 = zephir_fetch_nproperty_this(this_ptr, SL("_validation"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_17, _16, "getmessages", NULL); + _17 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_3, _17, "getvalues", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&messages, _17, "all", NULL); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", NULL, 0, _3); zephir_check_call_status(); - } - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_rules"), PH_NOISY_CC); - _6 = (zephir_fast_count_int(_8 TSRMLS_CC)) ? 1 : 0; - if (_6) { - _6 = !zephir_is_true(valid); - } - _18 = _6; - if (!(_18)) { - _19 = zephir_is_true(extra); - if (_19) { - _19 = !zephir_is_true(extraValid); + _18 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_19, _18, "valid", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(_19))) { + ZEPHIR_INIT_VAR(_20); + _21 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC); + _22 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_23, _22, "getmessages", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_24, _23, "all", NULL, 0); + zephir_check_call_status(); + zephir_fast_array_merge(_20, &(_21), &(_24) TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("messages"), _20 TSRMLS_CC); } - _18 = _19; } - if (_18) { - ZEPHIR_INIT_VAR(_20); - zephir_fast_array_merge(_20, &(extraMessages), &(messages) TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_messages"), _20 TSRMLS_CC); + _10 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_25); + zephir_create_array(_25, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_25, this_ptr); + ZEPHIR_INIT_NVAR(_20); + ZVAL_STRING(_20, "model.after.validate", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _10, "applyhook", NULL, 0, _20, _25); + zephir_check_temp_parameter(_20); + zephir_check_call_status(); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC); + if (zephir_fast_count_int(_11 TSRMLS_CC)) { RETURN_MM_BOOL(0); } - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_21); - array_init_size(_21, 2); - zephir_array_fast_append(_21, this_ptr); + _10 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_26); + zephir_create_array(_26, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_26, this_ptr); ZEPHIR_INIT_NVAR(_20); - ZVAL_STRING(_20, "model.after.validate", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _8, "applyhook", NULL, _20, _21); + ZVAL_STRING(_20, "model.before.create", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _10, "applyhook", NULL, 0, _20, _26); zephir_check_temp_parameter(_20); zephir_check_call_status(); - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_db"), PH_NOISY_CC); - _10 = zephir_fetch_nproperty_this(this_ptr, SL("_from"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_15, this_ptr, "getdata", NULL); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + _12 = zephir_fetch_nproperty_this(this_ptr, SL("from"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getdata", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, _9, "insert", NULL, _10, _15); + ZEPHIR_CALL_METHOD(&status, _11, "insert", NULL, 0, _12, _2); zephir_check_call_status(); if (zephir_is_true(status)) { - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_db"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_17, _11, "getid", NULL); + _13 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_3, _13, "getid", NULL, 0); zephir_check_call_status(); - _12 = zephir_fetch_nproperty_this(this_ptr, SL("_db"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_22, _12, "getlastinsertid", NULL); + _14 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_19, _14, "getlastinsertid", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, _17, _22); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, _3, _19); zephir_check_call_status(); } + _10 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_27); + zephir_create_array(_27, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_27, this_ptr); + ZEPHIR_INIT_NVAR(_20); + ZVAL_STRING(_20, "model.after.create", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _10, "applyhook", NULL, 0, _20, _27); + zephir_check_temp_parameter(_20); + zephir_check_call_status(); RETURN_CCTOR(status); } @@ -726,13 +814,13 @@ PHP_METHOD(Ice_Mvc_Model, create) { */ PHP_METHOD(Ice_Mvc_Model, update) { - zephir_fcall_cache_entry *_13 = NULL; - HashTable *_10; - HashPosition _9; - zend_bool _4; - zval *_2, *_6; + zend_bool _13; + zval *_11, *_23, *_25, *_26; + zephir_fcall_cache_entry *_6 = NULL, *_8 = NULL; + HashTable *_3; + HashPosition _2; int ZEPHIR_LAST_CALL_STATUS; - zval *fields = NULL, *extra = NULL, *status = NULL, *primary = NULL, *key = NULL, *extraValid = NULL, *extraMessages = NULL, *_0 = NULL, *_1, *_3 = NULL, *_5, *_7, *_8, **_11, *_12 = NULL, *_14, *_15; + zval *fields = NULL, *extra = NULL, *data = NULL, *status = NULL, *primary = NULL, *key = NULL, *_0, *_1, **_4, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_10 = NULL, *_12 = NULL, *_14, *_15, *_16, *_17, *_18 = NULL, *_19, *_20, *_21 = NULL, *_22 = NULL, *_24 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, &fields, &extra); @@ -740,89 +828,143 @@ PHP_METHOD(Ice_Mvc_Model, update) { if (!fields) { ZEPHIR_INIT_VAR(fields); array_init(fields); - } else { - ZEPHIR_SEPARATE_PARAM(fields); } if (!extra) { extra = ZEPHIR_GLOBAL(global_null); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "fields", NULL, fields); + ZEPHIR_CALL_METHOD(&data, this_ptr, "getdata", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(fields, _0); - ZEPHIR_INIT_VAR(extraValid); - ZVAL_BOOL(extraValid, 0); - ZEPHIR_INIT_VAR(extraMessages); - array_init(extraMessages); ZEPHIR_INIT_VAR(primary); array_init(primary); + ZEPHIR_OBS_VAR(_0); + zephir_read_property_this(&_0, this_ptr, SL("primary"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_ARRAY) { + _1 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); + zephir_is_iterable(_1, &_3, &_2, 0, 0, "ice/mvc/model.zep", 335); + for ( + ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS + ; zephir_hash_move_forward_ex(_3, &_2) + ) { + ZEPHIR_GET_HVALUE(key, _4); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", &_6, 0, key); + zephir_check_call_status(); + zephir_array_update_zval(&primary, key, &_5, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_INIT_NVAR(primary); + zephir_create_array(primary, 1, 0 TSRMLS_CC); + ZEPHIR_OBS_VAR(_7); + zephir_read_property_this(&_7, this_ptr, SL("primary"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", &_6, 0, _1); + zephir_check_call_status(); + zephir_array_update_zval(&primary, _7, &_5, PH_COPY); + } + ZEPHIR_CALL_METHOD(&_5, this_ptr, "fields", &_8, 0, fields); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", NULL, 0, _5); + zephir_check_call_status(); if (zephir_is_true(extra)) { - ZEPHIR_CALL_METHOD(&extraValid, extra, "validate", NULL); + ZEPHIR_CALL_METHOD(NULL, extra, "validate", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, extra, "getmessages", NULL); + ZEPHIR_CALL_METHOD(&_9, extra, "getmessages", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&extraMessages, _0, "all", NULL); + ZEPHIR_CALL_METHOD(&_10, _9, "all", NULL, 0); zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("messages"), _10 TSRMLS_CC); } - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_2); - array_init_size(_2, 2); - zephir_array_fast_append(_2, this_ptr); - ZEPHIR_INIT_VAR(_3); - ZVAL_STRING(_3, "model.before.validate", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _1, "applyhook", NULL, _3, _2); - zephir_check_temp_parameter(_3); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_11); + zephir_create_array(_11, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_11, this_ptr); + ZEPHIR_INIT_VAR(_12); + ZVAL_STRING(_12, "model.before.validate", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _1, "applyhook", NULL, 0, _12, _11); + zephir_check_temp_parameter(_12); zephir_check_call_status(); - _4 = zephir_is_true(extra); - if (_4) { - _4 = !zephir_is_true(extraValid); - } - if (_4) { - zephir_update_property_this(this_ptr, SL("_messages"), extraMessages TSRMLS_CC); - RETURN_MM_BOOL(0); + ZEPHIR_OBS_NVAR(_7); + zephir_read_property_this(&_7, this_ptr, SL("validation"), PH_NOISY_CC); + _13 = Z_TYPE_P(_7) == IS_OBJECT; + if (_13) { + ZEPHIR_OBS_VAR(_14); + zephir_read_property_this(&_14, this_ptr, SL("validation"), PH_NOISY_CC); + _13 = zephir_instance_of_ev(_14, ice_validation_ce TSRMLS_CC); } - _5 = zephir_fetch_nproperty_this(this_ptr, SL("_di"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(_6); - array_init_size(_6, 2); - zephir_array_fast_append(_6, this_ptr); - ZEPHIR_INIT_NVAR(_3); - ZVAL_STRING(_3, "model.after.validate", ZEPHIR_TEMP_PARAM_COPY); - ZEPHIR_CALL_METHOD(NULL, _5, "applyhook", NULL, _3, _6); - zephir_check_temp_parameter(_3); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(_7); - zephir_read_property_this(&_7, this_ptr, SL("_primary"), PH_NOISY_CC); - if (Z_TYPE_P(_7) == IS_ARRAY) { - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); - zephir_is_iterable(_8, &_10, &_9, 0, 0, "ice/mvc/model.zep", 324); - for ( - ; zephir_hash_get_current_data_ex(_10, (void**) &_11, &_9) == SUCCESS - ; zephir_hash_move_forward_ex(_10, &_9) - ) { - ZEPHIR_GET_HVALUE(key, _11); - ZEPHIR_CALL_METHOD(&_12, this_ptr, "get", &_13, key); + if (_13) { + _15 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "getdata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, _15, "validate", NULL, 0, _9); + zephir_check_call_status(); + _16 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_10, _16, "getvalues", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", NULL, 0, _10); + zephir_check_call_status(); + _17 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_18, _17, "valid", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(_18))) { + ZEPHIR_INIT_NVAR(_12); + _19 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC); + _20 = zephir_fetch_nproperty_this(this_ptr, SL("validation"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_21, _20, "getmessages", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_22, _21, "all", NULL, 0); zephir_check_call_status(); - zephir_array_update_zval(&primary, key, &_12, PH_COPY | PH_SEPARATE); + zephir_fast_array_merge(_12, &(_19), &(_22) TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("messages"), _12 TSRMLS_CC); } - } else { - ZEPHIR_INIT_NVAR(primary); - array_init_size(primary, 2); - ZEPHIR_OBS_VAR(_14); - zephir_read_property_this(&_14, this_ptr, SL("_primary"), PH_NOISY_CC); - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_12, this_ptr, "get", &_13, _8); + } + _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_23); + zephir_create_array(_23, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_23, this_ptr); + ZEPHIR_INIT_VAR(_24); + ZVAL_STRING(_24, "model.after.validate", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _1, "applyhook", NULL, 0, _24, _23); + zephir_check_temp_parameter(_24); + zephir_check_call_status(); + _15 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC); + if (zephir_fast_count_int(_15 TSRMLS_CC)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", NULL, 0, data); zephir_check_call_status(); - zephir_array_update_zval(&primary, _14, &_12, PH_COPY); + RETURN_MM_BOOL(0); } - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_db"), PH_NOISY_CC); - _15 = zephir_fetch_nproperty_this(this_ptr, SL("_from"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&status, _8, "update", NULL, _15, primary, fields); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_25); + zephir_create_array(_25, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_25, this_ptr); + ZEPHIR_INIT_NVAR(_24); + ZVAL_STRING(_24, "model.before.update", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _1, "applyhook", NULL, 0, _24, _25); + zephir_check_temp_parameter(_24); zephir_check_call_status(); - if (zephir_is_true(status)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "replace", NULL, fields); + _15 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + _16 = zephir_fetch_nproperty_this(this_ptr, SL("from"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "getdata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(_24); + ZVAL_BOOL(_24, 0); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "fields", &_8, 0, _9, _24); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&status, _15, "update", NULL, 0, _16, primary, _5); + zephir_check_call_status(); + if (!(zephir_is_true(status))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", NULL, 0, data); zephir_check_call_status(); } + _1 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(_26); + zephir_create_array(_26, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_26, this_ptr); + ZEPHIR_INIT_NVAR(_24); + ZVAL_STRING(_24, "model.after.update", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CALL_METHOD(NULL, _1, "applyhook", NULL, 0, _24, _26); + zephir_check_temp_parameter(_24); + zephir_check_call_status(); RETURN_CCTOR(status); } @@ -864,14 +1006,14 @@ PHP_METHOD(Ice_Mvc_Model, save) { } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "exists", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_0)) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "update", NULL, fields, extra); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "update", NULL, 0, fields, extra); zephir_check_call_status(); RETURN_MM(); } else { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "create", NULL, fields, extra); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "create", NULL, 0, fields, extra); zephir_check_call_status(); RETURN_MM(); } @@ -916,33 +1058,33 @@ PHP_METHOD(Ice_Mvc_Model, remove) { ZEPHIR_INIT_NVAR(filters); array_init(filters); ZEPHIR_OBS_VAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_primary"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("primary"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_ARRAY) { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); - zephir_is_iterable(_1, &_3, &_2, 0, 0, "ice/mvc/model.zep", 392); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); + zephir_is_iterable(_1, &_3, &_2, 0, 0, "ice/mvc/model.zep", 437); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(key, _4); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", &_6, key); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", &_6, 0, key); zephir_check_call_status(); zephir_array_update_zval(&filters, key, &_5, PH_COPY | PH_SEPARATE); } } else { ZEPHIR_INIT_NVAR(filters); - array_init_size(filters, 2); + zephir_create_array(filters, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_7); - zephir_read_property_this(&_7, this_ptr, SL("_primary"), PH_NOISY_CC); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", &_6, _1); + zephir_read_property_this(&_7, this_ptr, SL("primary"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "get", &_6, 0, _1); zephir_check_call_status(); zephir_array_update_zval(&filters, _7, &_5, PH_COPY); } } - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_db"), PH_NOISY_CC); - _8 = zephir_fetch_nproperty_this(this_ptr, SL("_from"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&status, _1, "remove", NULL, _8, filters); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + _8 = zephir_fetch_nproperty_this(this_ptr, SL("from"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&status, _1, "remove", NULL, 0, _8, filters); zephir_check_call_status(); RETURN_CCTOR(status); @@ -978,25 +1120,25 @@ PHP_METHOD(Ice_Mvc_Model, exists) { ZEPHIR_INIT_NVAR(filters); array_init(filters); ZEPHIR_OBS_VAR(_0); - zephir_read_property_this(&_0, this_ptr, SL("_primary"), PH_NOISY_CC); + zephir_read_property_this(&_0, this_ptr, SL("primary"), PH_NOISY_CC); if (Z_TYPE_P(_0) == IS_ARRAY) { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); - zephir_is_iterable(_1, &_3, &_2, 0, 0, "ice/mvc/model.zep", 423); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); + zephir_is_iterable(_1, &_3, &_2, 0, 0, "ice/mvc/model.zep", 468); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HVALUE(key, _4); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", &_6, key); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", &_6, 0, key); zephir_check_call_status(); _7 = zephir_is_true(_5); if (_7) { - ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", &_9, key); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", &_9, 0, key); zephir_check_call_status(); _7 = zephir_is_true(_8); } if (_7) { - ZEPHIR_CALL_METHOD(&_10, this_ptr, "get", &_9, key); + ZEPHIR_CALL_METHOD(&_10, this_ptr, "get", &_9, 0, key); zephir_check_call_status(); zephir_array_update_zval(&filters, key, &_10, PH_COPY | PH_SEPARATE); } else { @@ -1004,23 +1146,23 @@ PHP_METHOD(Ice_Mvc_Model, exists) { } } } else { - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", &_6, _1); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "has", &_6, 0, _1); zephir_check_call_status(); _7 = zephir_is_true(_5); if (_7) { - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", &_9, _11); + _11 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "get", &_9, 0, _11); zephir_check_call_status(); _7 = zephir_is_true(_8); } if (_7) { ZEPHIR_INIT_NVAR(filters); - array_init_size(filters, 2); + zephir_create_array(filters, 1, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_12); - zephir_read_property_this(&_12, this_ptr, SL("_primary"), PH_NOISY_CC); - _13 = zephir_fetch_nproperty_this(this_ptr, SL("_primary"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&_10, this_ptr, "get", &_9, _13); + zephir_read_property_this(&_12, this_ptr, SL("primary"), PH_NOISY_CC); + _13 = zephir_fetch_nproperty_this(this_ptr, SL("primary"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&_10, this_ptr, "get", &_9, 0, _13); zephir_check_call_status(); zephir_array_update_zval(&filters, _12, &_10, PH_COPY); } else { @@ -1028,7 +1170,7 @@ PHP_METHOD(Ice_Mvc_Model, exists) { } } } - ZEPHIR_RETURN_CALL_SELF("findone", NULL, filters); + ZEPHIR_RETURN_CALL_SELF("findone", NULL, 0, filters); zephir_check_call_status(); RETURN_MM(); @@ -1046,8 +1188,8 @@ PHP_METHOD(Ice_Mvc_Model, getError) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_db"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "geterror", NULL); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("db"), PH_NOISY_CC); + ZEPHIR_RETURN_CALL_METHOD(_0, "geterror", NULL, 0); zephir_check_call_status(); RETURN_MM(); @@ -1101,13 +1243,13 @@ PHP_METHOD(Ice_Mvc_Model, belongsTo) { ZEPHIR_CPY_WRT(alias, referenceModel); } ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 7); + zephir_create_array(_0, 5, 0 TSRMLS_CC); add_assoc_long_ex(_0, SS("type"), 1); zephir_array_update_string(&_0, SL("field"), &field, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("referenceModel"), &referenceModel, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("referencedField"), &referencedField, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("options"), &options, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("_relations"), alias, _0 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("relations"), alias, _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -1155,13 +1297,13 @@ PHP_METHOD(Ice_Mvc_Model, hasOne) { ZEPHIR_CPY_WRT(alias, referenceModel); } ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 7); + zephir_create_array(_0, 5, 0 TSRMLS_CC); add_assoc_long_ex(_0, SS("type"), 2); zephir_array_update_string(&_0, SL("field"), &field, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("referenceModel"), &referenceModel, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("referencedField"), &referencedField, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("options"), &options, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("_relations"), alias, _0 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("relations"), alias, _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -1216,13 +1358,13 @@ PHP_METHOD(Ice_Mvc_Model, hasMany) { ZEPHIR_CPY_WRT(alias, referenceModel); } ZEPHIR_INIT_VAR(_0); - array_init_size(_0, 7); + zephir_create_array(_0, 5, 0 TSRMLS_CC); add_assoc_long_ex(_0, SS("type"), 3); zephir_array_update_string(&_0, SL("field"), &field, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("referenceModel"), &referenceModel, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("referencedField"), &referencedField, PH_COPY | PH_SEPARATE); zephir_array_update_string(&_0, SL("options"), &options, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("_relations"), alias, _0 TSRMLS_CC); + zephir_update_property_array(this_ptr, SL("relations"), alias, _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -1232,18 +1374,18 @@ PHP_METHOD(Ice_Mvc_Model, hasMany) { * * @param string alias * @param array filters + * @param array options */ PHP_METHOD(Ice_Mvc_Model, getRelated) { - zend_class_entry *_10; + zend_class_entry *_9; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_4 = NULL; - zval *filters = NULL, *_7 = NULL, *_9; - zval *alias_param = NULL, *filters_param = NULL, *relation, *field, *referenceModel, *referencedField, *from, *result = NULL, *_0, *_1 = NULL, _2, *_3 = NULL, *_5, *_6, *_8 = NULL; + zval *filters = NULL, *options = NULL, *_6 = NULL, *_8; + zval *alias_param = NULL, *filters_param = NULL, *options_param = NULL, *relation = NULL, *field = NULL, *referenceModel = NULL, *referencedField = NULL, *from = NULL, *result = NULL, *_0, *_1 = NULL, _2, *_3 = NULL, *_4, *_5, *_7 = NULL; zval *alias = NULL; ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &alias_param, &filters_param); + zephir_fetch_params(1, 1, 2, &alias_param, &filters_param, &options_param); zephir_get_strval(alias, alias_param); if (!filters_param) { @@ -1252,20 +1394,26 @@ PHP_METHOD(Ice_Mvc_Model, getRelated) { } else { zephir_get_arrval(filters, filters_param); } + if (!options_param) { + ZEPHIR_INIT_VAR(options); + array_init(options); + } else { + zephir_get_arrval(options, options_param); + } ZEPHIR_OBS_VAR(relation); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_relations"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("relations"), PH_NOISY_CC); if (!(zephir_array_isset_fetch(&relation, _0, alias, 0 TSRMLS_CC))) { ZEPHIR_INIT_VAR(_1); object_init_ex(_1, ice_exception_ce); ZEPHIR_SINIT_VAR(_2); ZVAL_STRING(&_2, "Alias '%s' not found", 0); - ZEPHIR_CALL_FUNCTION(&_3, "sprintf", &_4, &_2, alias); + ZEPHIR_CALL_FUNCTION(&_3, "sprintf", NULL, 1, &_2, alias); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, _3); + ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 2, _3); zephir_check_call_status(); - zephir_throw_exception_debug(_1, "ice/mvc/model.zep", 573 TSRMLS_CC); + zephir_throw_exception_debug(_1, "ice/mvc/model.zep", 619 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } @@ -1275,45 +1423,45 @@ PHP_METHOD(Ice_Mvc_Model, getRelated) { zephir_array_isset_string_fetch(&referenceModel, relation, SS("referenceModel"), 0 TSRMLS_CC); ZEPHIR_OBS_VAR(referencedField); zephir_array_isset_string_fetch(&referencedField, relation, SS("referencedField"), 0 TSRMLS_CC); - ZEPHIR_INIT_VAR(from); ZEPHIR_INIT_NVAR(_1); zephir_get_class_ns(_1, referenceModel, 0 TSRMLS_CC); + ZEPHIR_INIT_VAR(from); zephir_uncamelize(from, _1); - zephir_array_fetch_string(&_5, relation, SL("type"), PH_NOISY | PH_READONLY, "ice/mvc/model.zep", 582 TSRMLS_CC); + zephir_array_fetch_string(&_4, relation, SL("type"), PH_NOISY | PH_READONLY, "ice/mvc/model.zep", 628 TSRMLS_CC); do { - if (ZEPHIR_IS_LONG(_5, 1) || ZEPHIR_IS_LONG(_5, 2)) { + if (ZEPHIR_IS_LONG(_4, 1) || ZEPHIR_IS_LONG(_4, 2)) { + ZEPHIR_INIT_VAR(_5); ZEPHIR_INIT_VAR(_6); - ZEPHIR_INIT_VAR(_7); - array_init_size(_7, 2); - ZEPHIR_OBS_VAR(_8); - zephir_read_property_zval(&_8, this_ptr, field, PH_NOISY_CC); - zephir_array_update_zval(&_7, referencedField, &_8, PH_COPY); - zephir_fast_array_merge(_6, &(filters), &(_7) TSRMLS_CC); - ZEPHIR_CPY_WRT(filters, _6); + zephir_create_array(_6, 1, 0 TSRMLS_CC); + ZEPHIR_OBS_VAR(_7); + zephir_read_property_zval(&_7, this_ptr, field, PH_NOISY_CC); + zephir_array_update_zval(&_6, referencedField, &_7, PH_COPY); + zephir_fast_array_merge(_5, &(filters), &(_6) TSRMLS_CC); + ZEPHIR_CPY_WRT(filters, _5); + ZEPHIR_INIT_VAR(_8); + zephir_create_array(_8, 1, 0 TSRMLS_CC); + zephir_array_fast_append(_8, filters); ZEPHIR_INIT_VAR(result); - ZEPHIR_INIT_VAR(_9); - array_init_size(_9, 2); - zephir_array_fast_append(_9, filters); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(result, referenceModel, _9 TSRMLS_CC); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(result, referenceModel, _8 TSRMLS_CC); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, result, "count", NULL); + ZEPHIR_CALL_METHOD(&_3, result, "count", NULL, 0); zephir_check_call_status(); if (!(zephir_is_true(_3))) { RETURN_MM_BOOL(0); } RETURN_CCTOR(result); } - if (ZEPHIR_IS_LONG(_5, 3)) { + if (ZEPHIR_IS_LONG(_4, 3)) { ZEPHIR_INIT_NVAR(_1); - ZEPHIR_INIT_NVAR(_7); - array_init_size(_7, 2); - ZEPHIR_OBS_NVAR(_8); - zephir_read_property_zval(&_8, this_ptr, field, PH_NOISY_CC); - zephir_array_update_zval(&_7, referencedField, &_8, PH_COPY); - zephir_fast_array_merge(_1, &(filters), &(_7) TSRMLS_CC); + ZEPHIR_INIT_NVAR(_6); + zephir_create_array(_6, 1, 0 TSRMLS_CC); + ZEPHIR_OBS_NVAR(_7); + zephir_read_property_zval(&_7, this_ptr, field, PH_NOISY_CC); + zephir_array_update_zval(&_6, referencedField, &_7, PH_COPY); + zephir_fast_array_merge(_1, &(filters), &(_6) TSRMLS_CC); ZEPHIR_CPY_WRT(filters, _1); - _10 = zend_fetch_class(Z_STRVAL_P(referenceModel), Z_STRLEN_P(referenceModel), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); - ZEPHIR_CALL_CE_STATIC(&result, _10, "find", NULL, filters); + _9 = zephir_fetch_class(referenceModel TSRMLS_CC); + ZEPHIR_CALL_CE_STATIC(&result, _9, "find", NULL, 0, filters, options); zephir_check_call_status(); RETURN_CCTOR(result); } @@ -1323,6 +1471,71 @@ PHP_METHOD(Ice_Mvc_Model, getRelated) { } +/** + * 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 + */ +PHP_METHOD(Ice_Mvc_Model, getRules) { + + HashTable *_3; + HashPosition _2; + zend_bool _0; + zval *fields = NULL, *rules = NULL, *field = NULL, *_1, **_4, *_5, *_6, *_7; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 0, 1, &fields); + + if (!fields) { + fields = ZEPHIR_GLOBAL(global_null); + } + + + if (zephir_is_true(fields)) { + _0 = Z_TYPE_P(fields) == IS_STRING; + if (_0) { + _1 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); + _0 = zephir_array_isset(_1, fields); + } + if (Z_TYPE_P(fields) == IS_ARRAY) { + ZEPHIR_INIT_VAR(rules); + array_init(rules); + zephir_is_iterable(fields, &_3, &_2, 0, 0, "ice/mvc/model.zep", 679); + for ( + ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS + ; zephir_hash_move_forward_ex(_3, &_2) + ) { + ZEPHIR_GET_HVALUE(field, _4); + _5 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); + if (zephir_array_isset(_5, field)) { + _6 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); + zephir_array_fetch(&_7, _6, field, PH_NOISY | PH_READONLY, "ice/mvc/model.zep", 675 TSRMLS_CC); + zephir_array_update_zval(&rules, field, &_7, PH_COPY | PH_SEPARATE); + } + } + RETURN_CCTOR(rules); + } else if (_0) { + _5 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); + zephir_array_fetch(&_7, _5, fields, PH_NOISY | PH_READONLY, "ice/mvc/model.zep", 681 TSRMLS_CC); + RETURN_CTOR(_7); + } + } + RETURN_MM_MEMBER(this_ptr, "rules"); + +} + /** * Set rules for validation. * @@ -1343,7 +1556,6 @@ PHP_METHOD(Ice_Mvc_Model, setRules) { array_init(rules); } else { rules = rules_param; - } if (!merge_param) { merge = 1; @@ -1354,11 +1566,11 @@ PHP_METHOD(Ice_Mvc_Model, setRules) { if (merge) { ZEPHIR_INIT_VAR(_0); - _1 = zephir_fetch_nproperty_this(this_ptr, SL("_rules"), PH_NOISY_CC); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); zephir_fast_array_merge(_0, &(_1), &(rules) TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_rules"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("rules"), _0 TSRMLS_CC); } else { - zephir_update_property_this(this_ptr, SL("_rules"), rules TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("rules"), rules TSRMLS_CC); } ZEPHIR_MM_RESTORE(); @@ -1371,12 +1583,17 @@ PHP_METHOD(Ice_Mvc_Model, setRules) { */ PHP_METHOD(Ice_Mvc_Model, serialize) { - zval *_0; + int ZEPHIR_LAST_CALL_STATUS; + zval *_0, *_1 = NULL; + ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY_CC); - zephir_json_encode(return_value, &(return_value), _0, 0 TSRMLS_CC); - return; + _0 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC); + ZEPHIR_CALL_FUNCTION(&_1, "serialize", NULL, 14, _0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 15, _1); + zephir_check_call_status(); + RETURN_MM(); } @@ -1386,7 +1603,7 @@ PHP_METHOD(Ice_Mvc_Model, serialize) { PHP_METHOD(Ice_Mvc_Model, unserialize) { int ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, *_0; + zval *data_param = NULL, *_0 = NULL, *_1 = NULL; zval *data = NULL; ZEPHIR_MM_GROW(); @@ -1396,7 +1613,6 @@ PHP_METHOD(Ice_Mvc_Model, unserialize) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'data' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } - if (likely(Z_TYPE_P(data_param) == IS_STRING)) { zephir_get_strval(data, data_param); } else { @@ -1405,11 +1621,13 @@ PHP_METHOD(Ice_Mvc_Model, unserialize) { } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "__construct", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_0); - zephir_json_decode(_0, &(_0), data, zephir_get_intval(ZEPHIR_GLOBAL(global_true)) TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_data"), _0 TSRMLS_CC); + ZEPHIR_CALL_FUNCTION(&_0, "base64_decode", NULL, 16, data); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_1, "unserialize", NULL, 17, _0); + zephir_check_call_status(); + zephir_update_property_this(this_ptr, SL("data"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -1419,9 +1637,8 @@ PHP_METHOD(Ice_Mvc_Model, unserialize) { */ PHP_METHOD(Ice_Mvc_Model, __call) { - zephir_nts_static zephir_fcall_cache_entry *_4 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *method_param = NULL, *arguments = NULL, *filters, *_0 = NULL, _1 = zval_used_for_init, *_2, *_3 = NULL; + zval *method_param = NULL, *arguments = NULL, *filters = NULL, *options = NULL, *_0 = NULL, _1 = zval_used_for_init, *_2, *_3 = NULL; zval *method = NULL; ZEPHIR_MM_GROW(); @@ -1436,13 +1653,15 @@ PHP_METHOD(Ice_Mvc_Model, __call) { if (zephir_start_with_str(method, SL("get"))) { ZEPHIR_OBS_VAR(filters); zephir_array_isset_long_fetch(&filters, arguments, 0, 0 TSRMLS_CC); + ZEPHIR_OBS_VAR(options); + zephir_array_isset_long_fetch(&options, arguments, 1, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); ZEPHIR_SINIT_VAR(_1); ZVAL_LONG(&_1, 3); ZEPHIR_INIT_VAR(_2); zephir_substr(_2, method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); zephir_ucfirst(_0, _2); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelated", NULL, _0, filters); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelated", NULL, 0, _0, filters, options); zephir_check_call_status(); RETURN_MM(); } @@ -1450,13 +1669,70 @@ PHP_METHOD(Ice_Mvc_Model, __call) { object_init_ex(_0, ice_exception_ce); ZEPHIR_SINIT_NVAR(_1); ZVAL_STRING(&_1, "The method '%s' doesn't exist", 0); - ZEPHIR_CALL_FUNCTION(&_3, "sprintf", &_4, &_1, method); + ZEPHIR_CALL_FUNCTION(&_3, "sprintf", NULL, 1, &_1, method); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _3); + ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 2, _3); zephir_check_call_status(); - zephir_throw_exception_debug(_0, "ice/mvc/model.zep", 649 TSRMLS_CC); + zephir_throw_exception_debug(_0, "ice/mvc/model.zep", 736 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } +static zend_object_value zephir_init_properties_Ice_Mvc_Model(zend_class_entry *class_type TSRMLS_DC) { + + zval *_0, *_1 = NULL, *_2, *_3, *_4, *_5, *_6, *_7; + + ZEPHIR_MM_GROW(); + + { + zval *this_ptr = NULL; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("messages"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("messages"), _1 TSRMLS_CC); + } + _2 = zephir_fetch_nproperty_this(this_ptr, SL("rules"), PH_NOISY_CC); + if (Z_TYPE_P(_2) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("rules"), _1 TSRMLS_CC); + } + _3 = zephir_fetch_nproperty_this(this_ptr, SL("labels"), PH_NOISY_CC); + if (Z_TYPE_P(_3) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("labels"), _1 TSRMLS_CC); + } + _4 = zephir_fetch_nproperty_this(this_ptr, SL("relations"), PH_NOISY_CC); + if (Z_TYPE_P(_4) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("relations"), _1 TSRMLS_CC); + } + _5 = zephir_fetch_nproperty_this(this_ptr, SL("fields"), PH_NOISY_CC); + if (Z_TYPE_P(_5) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("fields"), _1 TSRMLS_CC); + } + _6 = zephir_fetch_nproperty_this(this_ptr, SL("data"), PH_NOISY_CC); + if (Z_TYPE_P(_6) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("data"), _1 TSRMLS_CC); + } + _7 = zephir_fetch_nproperty_this(this_ptr, SL("filters"), PH_NOISY_CC); + if (Z_TYPE_P(_7) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("filters"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } + +} + diff --git a/ext/ice/mvc/model.zep.h b/ext/ice/mvc/model.zep.h index c2fbb4bc..f174aa0d 100644 --- a/ext/ice/mvc/model.zep.h +++ b/ext/ice/mvc/model.zep.h @@ -17,7 +17,10 @@ PHP_METHOD(Ice_Mvc_Model, getValidation); PHP_METHOD(Ice_Mvc_Model, getRelations); PHP_METHOD(Ice_Mvc_Model, setLabels); PHP_METHOD(Ice_Mvc_Model, getMessages); +PHP_METHOD(Ice_Mvc_Model, setMessages); PHP_METHOD(Ice_Mvc_Model, __construct); +PHP_METHOD(Ice_Mvc_Model, getId); +PHP_METHOD(Ice_Mvc_Model, getIdKey); PHP_METHOD(Ice_Mvc_Model, loadOne); PHP_METHOD(Ice_Mvc_Model, load); PHP_METHOD(Ice_Mvc_Model, findOne); @@ -33,10 +36,12 @@ PHP_METHOD(Ice_Mvc_Model, belongsTo); PHP_METHOD(Ice_Mvc_Model, hasOne); PHP_METHOD(Ice_Mvc_Model, hasMany); PHP_METHOD(Ice_Mvc_Model, getRelated); +PHP_METHOD(Ice_Mvc_Model, getRules); PHP_METHOD(Ice_Mvc_Model, setRules); PHP_METHOD(Ice_Mvc_Model, serialize); PHP_METHOD(Ice_Mvc_Model, unserialize); PHP_METHOD(Ice_Mvc_Model, __call); +static zend_object_value zephir_init_properties_Ice_Mvc_Model(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_setfrom, 0, 0, 1) ZEND_ARG_INFO(0, from) @@ -62,6 +67,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_setlabels, 0, 0, 1) ZEND_ARG_INFO(0, labels) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_setmessages, 0, 0, 1) + ZEND_ARG_INFO(0, messages) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model___construct, 0, 0, 0) ZEND_ARG_INFO(0, filters) ZEND_ARG_ARRAY_INFO(0, data, 1) @@ -69,6 +78,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_loadone, 0, 0, 1) ZEND_ARG_INFO(0, filters) + ZEND_ARG_ARRAY_INFO(0, options, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_load, 0, 0, 1) @@ -78,6 +88,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_findone, 0, 0, 0) ZEND_ARG_INFO(0, filters) + ZEND_ARG_ARRAY_INFO(0, options, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_find, 0, 0, 0) @@ -87,6 +98,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_fields, 0, 0, 0) ZEND_ARG_INFO(0, fields) + ZEND_ARG_INFO(0, primary) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_create, 0, 0, 0) @@ -136,6 +148,11 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_getrelated, 0, 0, 1) ZEND_ARG_INFO(0, alias) ZEND_ARG_ARRAY_INFO(0, filters, 1) + ZEND_ARG_ARRAY_INFO(0, options, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_getrules, 0, 0, 0) + ZEND_ARG_INFO(0, fields) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_model_setrules, 0, 0, 0) @@ -167,7 +184,10 @@ ZEPHIR_INIT_FUNCS(ice_mvc_model_method_entry) { PHP_ME(Ice_Mvc_Model, getRelations, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, setLabels, arginfo_ice_mvc_model_setlabels, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, getMessages, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Mvc_Model, setMessages, arginfo_ice_mvc_model_setmessages, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, __construct, arginfo_ice_mvc_model___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_ME(Ice_Mvc_Model, getId, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Mvc_Model, getIdKey, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, loadOne, arginfo_ice_mvc_model_loadone, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, load, arginfo_ice_mvc_model_load, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, findOne, arginfo_ice_mvc_model_findone, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) @@ -183,9 +203,10 @@ ZEPHIR_INIT_FUNCS(ice_mvc_model_method_entry) { PHP_ME(Ice_Mvc_Model, hasOne, arginfo_ice_mvc_model_hasone, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, hasMany, arginfo_ice_mvc_model_hasmany, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, getRelated, arginfo_ice_mvc_model_getrelated, ZEND_ACC_PUBLIC) + PHP_ME(Ice_Mvc_Model, getRules, arginfo_ice_mvc_model_getrules, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, setRules, arginfo_ice_mvc_model_setrules, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, serialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, unserialize, arginfo_ice_mvc_model_unserialize, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Model, __call, arginfo_ice_mvc_model___call, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/moduleinterface.zep.h b/ext/ice/mvc/moduleinterface.zep.h index de17e2f5..f8e359be 100644 --- a/ext/ice/mvc/moduleinterface.zep.h +++ b/ext/ice/mvc/moduleinterface.zep.h @@ -10,5 +10,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_mvc_moduleinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Mvc_ModuleInterface, registerAutoloaders, NULL) PHP_ABSTRACT_ME(Ice_Mvc_ModuleInterface, registerServices, arginfo_ice_mvc_moduleinterface_registerservices) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route.zep.c b/ext/ice/mvc/route.zep.c index a2ed0dfd..fb417ee7 100644 --- a/ext/ice/mvc/route.zep.c +++ b/ext/ice/mvc/route.zep.c @@ -16,7 +16,7 @@ #include "kernel/operators.h" #include "kernel/memory.h" #include "kernel/concat.h" -#include "kernel/fcall.h" +#include "kernel/string.h" /** @@ -27,7 +27,7 @@ * @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 */ ZEPHIR_INIT_CLASS(Ice_Mvc_Route) { @@ -83,9 +83,7 @@ PHP_METHOD(Ice_Mvc_Route, __construct) { */ PHP_METHOD(Ice_Mvc_Route, matches) { - int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL; - zval *str_param = NULL, *regex = NULL, *_0, *_1, *_2 = NULL; + zval *str_param = NULL, *regex = NULL, *_0, *_1, *_2, *_3; zval *str = NULL; ZEPHIR_MM_GROW(); @@ -98,9 +96,10 @@ PHP_METHOD(Ice_Mvc_Route, matches) { ZEPHIR_INIT_VAR(_1); ZEPHIR_CONCAT_SVS(_1, "~^", _0, "$~"); ZEPHIR_CPY_WRT(regex, _1); - ZEPHIR_CALL_FUNCTION(&_2, "preg_match", &_3, regex, str); - zephir_check_call_status(); - RETURN_MM_BOOL(zephir_get_boolval(_2)); + ZEPHIR_INIT_VAR(_2); + ZEPHIR_INIT_VAR(_3); + zephir_preg_match(_3, regex, str, _2, 0, 0 , 0 TSRMLS_CC); + RETURN_MM_BOOL(zephir_get_boolval(_3)); } diff --git a/ext/ice/mvc/route.zep.h b/ext/ice/mvc/route.zep.h index c3d2d29b..86201869 100644 --- a/ext/ice/mvc/route.zep.h +++ b/ext/ice/mvc/route.zep.h @@ -20,5 +20,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_mvc_route_method_entry) { PHP_ME(Ice_Mvc_Route, __construct, arginfo_ice_mvc_route___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Mvc_Route, matches, arginfo_ice_mvc_route_matches, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route/collector.zep.c b/ext/ice/mvc/route/collector.zep.c index 1389058f..43f2b12f 100644 --- a/ext/ice/mvc/route/collector.zep.c +++ b/ext/ice/mvc/route/collector.zep.c @@ -86,7 +86,7 @@ PHP_METHOD(Ice_Mvc_Route_Collector, __construct) { ZEPHIR_INIT_NVAR(routeParser); object_init_ex(routeParser, ice_mvc_route_parser_std_ce); if (zephir_has_constructor(routeParser TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, routeParser, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, routeParser, "__construct", NULL, 0); zephir_check_call_status(); } } @@ -94,7 +94,7 @@ PHP_METHOD(Ice_Mvc_Route_Collector, __construct) { ZEPHIR_INIT_NVAR(dataGenerator); object_init_ex(dataGenerator, ice_mvc_route_datagenerator_groupcount_ce); if (zephir_has_constructor(dataGenerator TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, dataGenerator, "__construct", NULL); + ZEPHIR_CALL_METHOD(NULL, dataGenerator, "__construct", NULL, 0); zephir_check_call_status(); } } @@ -115,11 +115,11 @@ PHP_METHOD(Ice_Mvc_Route_Collector, __construct) { */ PHP_METHOD(Ice_Mvc_Route_Collector, addRoute) { - HashTable *_2; - HashPosition _1; + HashTable *_2, *_5; + HashPosition _1, _4; int ZEPHIR_LAST_CALL_STATUS; zval *route = NULL; - zval *httpMethod = NULL, *route_param = NULL, *handler = NULL, *routeData = NULL, *method = NULL, *_0, **_3, *_4; + zval *httpMethod = NULL, *route_param = NULL, *handler = NULL, *routeDatas = NULL, *routeData = NULL, *method = NULL, *_0, **_3, **_6, *_7; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &httpMethod, &route_param, &handler); @@ -132,23 +132,30 @@ PHP_METHOD(Ice_Mvc_Route_Collector, addRoute) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("routeParser"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(&routeData, _0, "parse", NULL, route); + ZEPHIR_CALL_METHOD(&routeDatas, _0, "parse", NULL, 0, route); zephir_check_call_status(); if (Z_TYPE_P(httpMethod) == IS_STRING) { ZEPHIR_CPY_WRT(method, httpMethod); ZEPHIR_INIT_NVAR(httpMethod); - array_init_size(httpMethod, 2); + zephir_create_array(httpMethod, 1, 0 TSRMLS_CC); zephir_array_fast_append(httpMethod, method); } - zephir_is_iterable(httpMethod, &_2, &_1, 0, 0, "ice/mvc/route/collector.zep", 58); + zephir_is_iterable(httpMethod, &_2, &_1, 0, 0, "ice/mvc/route/collector.zep", 60); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(method, _3); - _4 = zephir_fetch_nproperty_this(this_ptr, SL("dataGenerator"), PH_NOISY_CC); - ZEPHIR_CALL_METHOD(NULL, _4, "addroute", NULL, method, routeData, handler); - zephir_check_call_status(); + zephir_is_iterable(routeDatas, &_5, &_4, 0, 0, "ice/mvc/route/collector.zep", 59); + for ( + ; zephir_hash_get_current_data_ex(_5, (void**) &_6, &_4) == SUCCESS + ; zephir_hash_move_forward_ex(_5, &_4) + ) { + ZEPHIR_GET_HVALUE(routeData, _6); + _7 = zephir_fetch_nproperty_this(this_ptr, SL("dataGenerator"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(NULL, _7, "addroute", NULL, 0, method, routeData, handler); + zephir_check_call_status(); + } } ZEPHIR_MM_RESTORE(); @@ -167,7 +174,7 @@ PHP_METHOD(Ice_Mvc_Route_Collector, getData) { ZEPHIR_MM_GROW(); _0 = zephir_fetch_nproperty_this(this_ptr, SL("dataGenerator"), PH_NOISY_CC); - ZEPHIR_RETURN_CALL_METHOD(_0, "getdata", NULL); + ZEPHIR_RETURN_CALL_METHOD(_0, "getdata", NULL, 0); zephir_check_call_status(); RETURN_MM(); diff --git a/ext/ice/mvc/route/collector.zep.h b/ext/ice/mvc/route/collector.zep.h index e8566ff3..4c75a0bb 100644 --- a/ext/ice/mvc/route/collector.zep.h +++ b/ext/ice/mvc/route/collector.zep.h @@ -34,5 +34,5 @@ ZEPHIR_INIT_FUNCS(ice_mvc_route_collector_method_entry) { PHP_ME(Ice_Mvc_Route_Collector, __construct, arginfo_ice_mvc_route_collector___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Mvc_Route_Collector, addRoute, arginfo_ice_mvc_route_collector_addroute, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Route_Collector, getData, NULL, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route/datagenerator/datageneratorinterface.zep.h b/ext/ice/mvc/route/datagenerator/datageneratorinterface.zep.h index 61c0f119..96b0481e 100644 --- a/ext/ice/mvc/route/datagenerator/datageneratorinterface.zep.h +++ b/ext/ice/mvc/route/datagenerator/datageneratorinterface.zep.h @@ -12,5 +12,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_mvc_route_datagenerator_datageneratorinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Mvc_Route_DataGenerator_DataGeneratorInterface, addRoute, arginfo_ice_mvc_route_datagenerator_datageneratorinterface_addroute) PHP_ABSTRACT_ME(Ice_Mvc_Route_DataGenerator_DataGeneratorInterface, getData, NULL) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route/datagenerator/groupcount.zep.c b/ext/ice/mvc/route/datagenerator/groupcount.zep.c index 5654a44d..99ea4805 100644 --- a/ext/ice/mvc/route/datagenerator/groupcount.zep.c +++ b/ext/ice/mvc/route/datagenerator/groupcount.zep.c @@ -40,11 +40,11 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_GroupCount, getApproxChunkSize) { PHP_METHOD(Ice_Mvc_Route_DataGenerator_GroupCount, processChunk) { zval *_11 = NULL; - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; + zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; HashTable *_1; HashPosition _0; - int repeat, i, ZEPHIR_LAST_CALL_STATUS; - zval *regexToRoutesMap, *routeMap, *regex = NULL, *route = NULL, *regexes, *numGroups = NULL, *numVariables = NULL, **_2, *_3 = NULL, *_4 = NULL, *_6 = NULL, _7 = zval_used_for_init, _8 = zval_used_for_init, *_10 = NULL, *_12 = NULL, *_13; + int repeat = 0, i = 0, ZEPHIR_LAST_CALL_STATUS; + zval *regexToRoutesMap, *routeMap = NULL, *regex = NULL, *route = NULL, *regexes = NULL, *numGroups = NULL, *numVariables = NULL, **_2, *_3 = NULL, *_4 = NULL, *_6 = NULL, _7 = zval_used_for_init, _8 = zval_used_for_init, *_10 = NULL, *_12 = NULL, *_13; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, ®exToRoutesMap); @@ -68,31 +68,31 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_GroupCount, processChunk) { zephir_read_property(&_3, route, SL("variables"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(numVariables); ZVAL_LONG(numVariables, zephir_fast_count_int(_3 TSRMLS_CC)); - ZEPHIR_CALL_FUNCTION(&_4, "max", &_5, numGroups, numVariables); + ZEPHIR_CALL_FUNCTION(&_4, "max", &_5, 32, numGroups, numVariables); zephir_check_call_status(); ZEPHIR_CPY_WRT(numGroups, _4); ZEPHIR_INIT_LNVAR(_6); - sub_function(_6, numGroups, numVariables TSRMLS_CC); + zephir_sub_function(_6, numGroups, numVariables); repeat = zephir_get_numberval(_6); ZEPHIR_SINIT_NVAR(_7); ZVAL_STRING(&_7, "()", 0); ZEPHIR_SINIT_NVAR(_8); ZVAL_LONG(&_8, repeat); - ZEPHIR_CALL_FUNCTION(&_4, "str_repeat", &_9, &_7, &_8); + ZEPHIR_CALL_FUNCTION(&_4, "str_repeat", &_9, 68, &_7, &_8); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_10); ZEPHIR_CONCAT_VV(_10, regex, _4); zephir_array_append(®exes, _10, PH_SEPARATE, "ice/mvc/route/datagenerator/groupcount.zep", 27); i = (zephir_get_numberval(numGroups) + 1); ZEPHIR_INIT_NVAR(_11); - array_init_size(_11, 3); + zephir_create_array(_11, 2, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_12); zephir_read_property(&_12, route, SL("handler"), PH_NOISY_CC); zephir_array_fast_append(_11, _12); ZEPHIR_OBS_NVAR(_12); zephir_read_property(&_12, route, SL("variables"), PH_NOISY_CC); zephir_array_fast_append(_11, _12); - zephir_array_update_long(&routeMap, i, &_11, PH_COPY | PH_SEPARATE, "ice/mvc/route/datagenerator/groupcount.zep", 29); + zephir_array_update_long(&routeMap, i, &_11, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); ZEPHIR_SEPARATE(numGroups); zephir_increment(numGroups); } @@ -100,8 +100,8 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_GroupCount, processChunk) { zephir_fast_join_str(_13, SL("|"), regexes TSRMLS_CC); ZEPHIR_INIT_VAR(regex); ZEPHIR_CONCAT_SVS(regex, "~^(?|", _13, ")$~"); - array_init_size(return_value, 3); - ZEPHIR_CALL_FUNCTION(&_4, "utf8_encode", NULL, regex); + zephir_create_array(return_value, 2, 0 TSRMLS_CC); + ZEPHIR_CALL_FUNCTION(&_4, "utf8_encode", NULL, 115, regex); zephir_check_call_status(); zephir_array_update_string(&return_value, SL("regex"), &_4, PH_COPY | PH_SEPARATE); zephir_array_update_string(&return_value, SL("routeMap"), &routeMap, PH_COPY | PH_SEPARATE); diff --git a/ext/ice/mvc/route/datagenerator/groupcount.zep.h b/ext/ice/mvc/route/datagenerator/groupcount.zep.h index 03ba8f01..79229060 100644 --- a/ext/ice/mvc/route/datagenerator/groupcount.zep.h +++ b/ext/ice/mvc/route/datagenerator/groupcount.zep.h @@ -13,5 +13,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_mvc_route_datagenerator_groupcount_method_entry) { PHP_ME(Ice_Mvc_Route_DataGenerator_GroupCount, getApproxChunkSize, NULL, ZEND_ACC_PROTECTED) PHP_ME(Ice_Mvc_Route_DataGenerator_GroupCount, processChunk, arginfo_ice_mvc_route_datagenerator_groupcount_processchunk, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route/datagenerator/regex.zep.c b/ext/ice/mvc/route/datagenerator/regex.zep.c index c953f201..a53bc142 100644 --- a/ext/ice/mvc/route/datagenerator/regex.zep.c +++ b/ext/ice/mvc/route/datagenerator/regex.zep.c @@ -18,16 +18,20 @@ #include "kernel/object.h" #include "kernel/array.h" #include "kernel/hash.h" +#include "kernel/math.h" #include "kernel/exception.h" #include "kernel/concat.h" + ZEPHIR_INIT_CLASS(Ice_Mvc_Route_DataGenerator_Regex) { ZEPHIR_REGISTER_CLASS(Ice\\Mvc\\Route\\DataGenerator, Regex, ice, mvc_route_datagenerator_regex, ice_mvc_route_datagenerator_regex_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(ice_mvc_route_datagenerator_regex_ce, SL("_staticRoutes"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_route_datagenerator_regex_ce, SL("staticRoutes"), ZEND_ACC_PROTECTED TSRMLS_CC); + + zend_declare_property_null(ice_mvc_route_datagenerator_regex_ce, SL("methodToRegexToRoutesMap"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_route_datagenerator_regex_ce, SL("_methodToRegexToRoutesMap"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_mvc_route_datagenerator_regex_ce->create_object = zephir_init_properties_Ice_Mvc_Route_DataGenerator_Regex; zend_class_implements(ice_mvc_route_datagenerator_regex_ce TSRMLS_CC, 1, ice_mvc_route_datagenerator_datageneratorinterface_ce); return SUCCESS; @@ -52,13 +56,13 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, addRoute) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "isstaticroute", NULL, routeData); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "isstaticroute", NULL, 0, routeData); zephir_check_call_status(); if (zephir_is_true(_0)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addstaticroute", NULL, httpMethod, routeData, handler); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addstaticroute", NULL, 0, httpMethod, routeData, handler); zephir_check_call_status(); } else { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addvariableroute", NULL, httpMethod, routeData, handler); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addvariableroute", NULL, 0, httpMethod, routeData, handler); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); @@ -72,22 +76,22 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, getData) { ZEPHIR_MM_GROW(); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_methodToRegexToRoutesMap"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("methodToRegexToRoutesMap"), PH_NOISY_CC); if (ZEPHIR_IS_EMPTY(_0)) { - array_init_size(return_value, 3); + zephir_create_array(return_value, 2, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_staticRoutes"), PH_NOISY_CC); + zephir_read_property_this(&_1, this_ptr, SL("staticRoutes"), PH_NOISY_CC); zephir_array_fast_append(return_value, _1); ZEPHIR_INIT_VAR(_2); array_init(_2); zephir_array_fast_append(return_value, _2); RETURN_MM(); } - array_init_size(return_value, 3); + zephir_create_array(return_value, 2, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_1); - zephir_read_property_this(&_1, this_ptr, SL("_staticRoutes"), PH_NOISY_CC); + zephir_read_property_this(&_1, this_ptr, SL("staticRoutes"), PH_NOISY_CC); zephir_array_fast_append(return_value, _1); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "generatevariableroutedata", NULL); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "generatevariableroutedata", NULL, 0); zephir_check_call_status(); zephir_array_fast_append(return_value, _3); RETURN_MM(); @@ -97,18 +101,17 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, getData) { PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, generateVariableRouteData) { zval *_7 = NULL; - zephir_nts_static zephir_fcall_cache_entry *_6 = NULL, *_9 = NULL; - zephir_fcall_cache_entry *_5 = NULL; + zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL, *_9 = NULL; int ZEPHIR_LAST_CALL_STATUS; HashTable *_2; HashPosition _1; - zval *chunkSize = NULL, *chunks = NULL, *data, *method = NULL, *regexToRoutesMap = NULL, *_0, **_3, *_4 = NULL, *_8 = NULL; + zval *chunkSize = NULL, *chunks = NULL, *data = NULL, *method = NULL, *regexToRoutesMap = NULL, *_0, **_3, *_4 = NULL, *_8 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(data); array_init(data); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_methodToRegexToRoutesMap"), PH_NOISY_CC); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("methodToRegexToRoutesMap"), PH_NOISY_CC); zephir_is_iterable(_0, &_2, &_1, 0, 0, "ice/mvc/route/datagenerator/regex.zep", 47); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS @@ -118,17 +121,17 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, generateVariableRouteData) { ZEPHIR_GET_HVALUE(regexToRoutesMap, _3); ZEPHIR_INIT_NVAR(_4); ZVAL_LONG(_4, zephir_fast_count_int(regexToRoutesMap TSRMLS_CC)); - ZEPHIR_CALL_METHOD(&chunkSize, this_ptr, "computechunksize", &_5, _4); + ZEPHIR_CALL_METHOD(&chunkSize, this_ptr, "computechunksize", &_5, 0, _4); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&chunks, "array_chunk", &_6, regexToRoutesMap, chunkSize, ZEPHIR_GLOBAL(global_true)); + ZEPHIR_CALL_FUNCTION(&chunks, "array_chunk", &_6, 30, regexToRoutesMap, chunkSize, ZEPHIR_GLOBAL(global_true)); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_7); - array_init_size(_7, 3); + zephir_create_array(_7, 2, 0 TSRMLS_CC); zephir_array_fast_append(_7, this_ptr); ZEPHIR_INIT_NVAR(_4); ZVAL_STRING(_4, "processChunk", 1); zephir_array_fast_append(_7, _4); - ZEPHIR_CALL_FUNCTION(&_8, "array_map", &_9, _7, chunks); + ZEPHIR_CALL_FUNCTION(&_8, "array_map", &_9, 31, _7, chunks); zephir_check_call_status(); zephir_array_update_zval(&data, method, &_8, PH_COPY | PH_SEPARATE); } @@ -138,17 +141,16 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, generateVariableRouteData) { PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, computeChunkSize) { - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL; int ZEPHIR_LAST_CALL_STATUS; - double round, ceil; - zval *count, *numParts = NULL, *_0 = NULL, *_1, *_2, _3, *_4, *_6, _7; + double round = 0, ceil = 0; + zval *count, *numParts = NULL, *_0 = NULL, *_1, *_2, _3, *_4, *_5, _6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &count); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getapproxchunksize", NULL); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getapproxchunksize", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(_1); div_function(_1, count, _0 TSRMLS_CC); @@ -159,15 +161,14 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, computeChunkSize) { zephir_round(_2, &_3, NULL, NULL TSRMLS_CC); ZEPHIR_INIT_VAR(_4); ZVAL_LONG(_4, 1); - ZEPHIR_CALL_FUNCTION(&numParts, "max", &_5, _4, _2); + ZEPHIR_CALL_FUNCTION(&numParts, "max", NULL, 32, _4, _2); zephir_check_call_status(); - ZEPHIR_INIT_VAR(_6); - div_function(_6, count, numParts TSRMLS_CC); - ceil = zephir_get_numberval(_6); - ZEPHIR_SINIT_VAR(_7); - ZVAL_DOUBLE(&_7, ceil); - zephir_ceil(return_value, &_7 TSRMLS_CC); - RETURN_MM(); + ZEPHIR_INIT_VAR(_5); + div_function(_5, count, numParts TSRMLS_CC); + ceil = zephir_get_numberval(_5); + ZEPHIR_SINIT_VAR(_6); + ZVAL_DOUBLE(&_6, ceil); + RETURN_MM_DOUBLE(zephir_ceil(&_6 TSRMLS_CC)); } @@ -193,11 +194,10 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, addStaticRoute) { HashTable *_13; HashPosition _12; - zephir_fcall_cache_entry *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_7 = NULL; + zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL; zend_bool _1; - zval *httpMethod, *routeData, *handler, *routeStr, *route = NULL, *_0, *_2, *_3, *_4 = NULL, _5 = zval_used_for_init, *_6 = NULL, *_9, *_10, *_11, **_14, *_15 = NULL, *_16 = NULL; + zval *httpMethod, *routeData, *handler, *routeStr = NULL, *route = NULL, *_0, *_2, *_3, *_4 = NULL, _5 = zval_used_for_init, *_6 = NULL, *_9, *_10, *_11, **_14, *_15 = NULL, *_16 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &httpMethod, &routeData, &handler); @@ -206,29 +206,29 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, addStaticRoute) { ZEPHIR_OBS_VAR(routeStr); zephir_array_fetch_long(&routeStr, routeData, 0, PH_NOISY, "ice/mvc/route/datagenerator/regex.zep", 71 TSRMLS_CC); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_staticRoutes"), PH_NOISY_CC); - _1 = zephir_array_isset(_0, routeStr); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("staticRoutes"), PH_NOISY_CC); + _1 = zephir_array_isset(_0, httpMethod); if (_1) { - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_staticRoutes"), PH_NOISY_CC); - zephir_array_fetch(&_3, _2, routeStr, PH_READONLY, "ice/mvc/route/datagenerator/regex.zep", 73 TSRMLS_CC); - _1 = zephir_array_isset(_3, httpMethod); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("staticRoutes"), PH_NOISY_CC); + zephir_array_fetch(&_3, _2, httpMethod, PH_READONLY, "ice/mvc/route/datagenerator/regex.zep", 73 TSRMLS_CC); + _1 = zephir_array_isset(_3, routeStr); } if (_1) { ZEPHIR_INIT_VAR(_4); object_init_ex(_4, ice_exception_ce); ZEPHIR_SINIT_VAR(_5); ZVAL_STRING(&_5, "Cannot register two routes matching '%s' for method '%s'", 0); - ZEPHIR_CALL_FUNCTION(&_6, "sprintf", &_7, &_5, routeStr, httpMethod); + ZEPHIR_CALL_FUNCTION(&_6, "sprintf", &_7, 1, &_5, routeStr, httpMethod); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_8, _6); + ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_8, 2, _6); zephir_check_call_status(); zephir_throw_exception_debug(_4, "ice/mvc/route/datagenerator/regex.zep", 76 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } - _9 = zephir_fetch_nproperty_this(this_ptr, SL("_methodToRegexToRoutesMap"), PH_NOISY_CC); + _9 = zephir_fetch_nproperty_this(this_ptr, SL("methodToRegexToRoutesMap"), PH_NOISY_CC); if (zephir_array_isset(_9, httpMethod)) { - _10 = zephir_fetch_nproperty_this(this_ptr, SL("_methodToRegexToRoutesMap"), PH_NOISY_CC); + _10 = zephir_fetch_nproperty_this(this_ptr, SL("methodToRegexToRoutesMap"), PH_NOISY_CC); zephir_array_fetch(&_11, _10, httpMethod, PH_NOISY | PH_READONLY, "ice/mvc/route/datagenerator/regex.zep", 80 TSRMLS_CC); zephir_is_iterable(_11, &_13, &_12, 0, 0, "ice/mvc/route/datagenerator/regex.zep", 88); for ( @@ -236,7 +236,7 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, addStaticRoute) { ; zephir_hash_move_forward_ex(_13, &_12) ) { ZEPHIR_GET_HVALUE(route, _14); - ZEPHIR_CALL_METHOD(&_6, route, "matches", NULL, routeStr); + ZEPHIR_CALL_METHOD(&_6, route, "matches", NULL, 0, routeStr); zephir_check_call_status(); if (zephir_is_true(_6)) { ZEPHIR_INIT_NVAR(_4); @@ -245,9 +245,9 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, addStaticRoute) { zephir_read_property(&_15, route, SL("regex"), PH_NOISY_CC); ZEPHIR_SINIT_NVAR(_5); ZVAL_STRING(&_5, "Static route '%s' is shadowed by previously defined variable route '%s' for method '%s'", 0); - ZEPHIR_CALL_FUNCTION(&_16, "sprintf", &_7, &_5, routeStr, _15, httpMethod); + ZEPHIR_CALL_FUNCTION(&_16, "sprintf", &_7, 1, &_5, routeStr, _15, httpMethod); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_8, _16); + ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_8, 2, _16); zephir_check_call_status(); zephir_throw_exception_debug(_4, "ice/mvc/route/datagenerator/regex.zep", 85 TSRMLS_CC); ZEPHIR_MM_RESTORE(); @@ -255,68 +255,67 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, addStaticRoute) { } } } - zephir_update_property_array_multi(this_ptr, SL("_staticRoutes"), &handler TSRMLS_CC, SL("zz"), 2, routeStr, httpMethod); + zephir_update_property_array_multi(this_ptr, SL("staticRoutes"), &handler TSRMLS_CC, SL("zz"), 2, httpMethod, routeStr); ZEPHIR_MM_RESTORE(); } PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, addVariableRoute) { - zephir_nts_static zephir_fcall_cache_entry *_9 = NULL; - zend_bool _3; + zend_bool _4; + zephir_fcall_cache_entry *_1 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *httpMethod, *routeData, *handler, *regex, *variables, *_0 = NULL, *_1 = NULL, *_2, *_4, *_5, *_6 = NULL, _7, *_8 = NULL; + zval *httpMethod, *routeData, *handler, *regex = NULL, *variables = NULL, *_0 = NULL, *_2 = NULL, *_3, *_5, *_6, *_7 = NULL, _8, *_9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &httpMethod, &routeData, &handler); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "buildregexforroute", NULL, routeData); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "buildregexforroute", &_1, 0, routeData); zephir_check_call_status(); ZEPHIR_OBS_VAR(regex); zephir_array_fetch_long(®ex, _0, 0, PH_NOISY, "ice/mvc/route/datagenerator/regex.zep", 97 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "buildregexforroute", NULL, routeData); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "buildregexforroute", &_1, 0, routeData); zephir_check_call_status(); ZEPHIR_OBS_VAR(variables); - zephir_array_fetch_long(&variables, _1, 1, PH_NOISY, "ice/mvc/route/datagenerator/regex.zep", 98 TSRMLS_CC); - _2 = zephir_fetch_nproperty_this(this_ptr, SL("_methodToRegexToRoutesMap"), PH_NOISY_CC); - _3 = zephir_array_isset(_2, httpMethod); - if (_3) { - _4 = zephir_fetch_nproperty_this(this_ptr, SL("_methodToRegexToRoutesMap"), PH_NOISY_CC); - zephir_array_fetch(&_5, _4, httpMethod, PH_READONLY, "ice/mvc/route/datagenerator/regex.zep", 100 TSRMLS_CC); - _3 = zephir_array_isset(_5, regex); + zephir_array_fetch_long(&variables, _2, 1, PH_NOISY, "ice/mvc/route/datagenerator/regex.zep", 98 TSRMLS_CC); + _3 = zephir_fetch_nproperty_this(this_ptr, SL("methodToRegexToRoutesMap"), PH_NOISY_CC); + _4 = zephir_array_isset(_3, httpMethod); + if (_4) { + _5 = zephir_fetch_nproperty_this(this_ptr, SL("methodToRegexToRoutesMap"), PH_NOISY_CC); + zephir_array_fetch(&_6, _5, httpMethod, PH_READONLY, "ice/mvc/route/datagenerator/regex.zep", 100 TSRMLS_CC); + _4 = zephir_array_isset(_6, regex); } - if (_3) { - ZEPHIR_INIT_VAR(_6); - object_init_ex(_6, ice_exception_ce); - ZEPHIR_SINIT_VAR(_7); - ZVAL_STRING(&_7, "Cannot register two routes matching '%s' for method '%s'", 0); - ZEPHIR_CALL_FUNCTION(&_8, "sprintf", &_9, &_7, regex, httpMethod); + if (_4) { + ZEPHIR_INIT_VAR(_7); + object_init_ex(_7, ice_exception_ce); + ZEPHIR_SINIT_VAR(_8); + ZVAL_STRING(&_8, "Cannot register two routes matching '%s' for method '%s'", 0); + ZEPHIR_CALL_FUNCTION(&_9, "sprintf", NULL, 1, &_8, regex, httpMethod); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, _8); + ZEPHIR_CALL_METHOD(NULL, _7, "__construct", NULL, 2, _9); zephir_check_call_status(); - zephir_throw_exception_debug(_6, "ice/mvc/route/datagenerator/regex.zep", 104 TSRMLS_CC); + zephir_throw_exception_debug(_7, "ice/mvc/route/datagenerator/regex.zep", 104 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } - ZEPHIR_INIT_NVAR(_6); - object_init_ex(_6, ice_mvc_route_ce); - ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, httpMethod, handler, regex, variables); + ZEPHIR_INIT_NVAR(_7); + object_init_ex(_7, ice_mvc_route_ce); + ZEPHIR_CALL_METHOD(NULL, _7, "__construct", NULL, 33, httpMethod, handler, regex, variables); zephir_check_call_status(); - zephir_update_property_array_multi(this_ptr, SL("_methodToRegexToRoutesMap"), &_6 TSRMLS_CC, SL("zz"), 2, httpMethod, regex); + zephir_update_property_array_multi(this_ptr, SL("methodToRegexToRoutesMap"), &_7 TSRMLS_CC, SL("zz"), 2, httpMethod, regex); ZEPHIR_MM_RESTORE(); } PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, buildRegexForRoute) { - zephir_fcall_cache_entry *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; + zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_8 = NULL; HashTable *_1; HashPosition _0; - zval *routeData, *regex, *variables, *part = NULL, *varName = NULL, *regexPart = NULL, **_2, _3 = zval_used_for_init, *_4 = NULL, *_6 = NULL, *_9 = NULL; + zval *routeData, *regex = NULL, *variables = NULL, *part = NULL, *varName = NULL, *regexPart = NULL, **_2, _3 = zval_used_for_init, *_4 = NULL, *_6 = NULL, *_9 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &routeData); @@ -336,7 +335,7 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, buildRegexForRoute) { if (Z_TYPE_P(part) == IS_STRING) { ZEPHIR_SINIT_NVAR(_3); ZVAL_STRING(&_3, "~", 0); - ZEPHIR_CALL_FUNCTION(&_4, "preg_quote", &_5, part, &_3); + ZEPHIR_CALL_FUNCTION(&_4, "preg_quote", &_5, 34, part, &_3); zephir_check_call_status(); zephir_concat_self(®ex, _4 TSRMLS_CC); continue; @@ -350,9 +349,9 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, buildRegexForRoute) { object_init_ex(_6, ice_exception_ce); ZEPHIR_SINIT_NVAR(_3); ZVAL_STRING(&_3, "Cannot use the same placeholder '%s' twice", 0); - ZEPHIR_CALL_FUNCTION(&_4, "sprintf", &_7, &_3, varName); + ZEPHIR_CALL_FUNCTION(&_4, "sprintf", &_7, 1, &_3, varName); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_8, _4); + ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_8, 2, _4); zephir_check_call_status(); zephir_throw_exception_debug(_6, "ice/mvc/route/datagenerator/regex.zep", 131 TSRMLS_CC); ZEPHIR_MM_RESTORE(); @@ -363,26 +362,37 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, buildRegexForRoute) { ZEPHIR_CONCAT_SVS(_9, "(", regexPart, ")"); zephir_concat_self(®ex, _9 TSRMLS_CC); } - array_init_size(return_value, 3); + zephir_create_array(return_value, 2, 0 TSRMLS_CC); zephir_array_fast_append(return_value, regex); zephir_array_fast_append(return_value, variables); RETURN_MM(); } -PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, __construct) { +static zend_object_value zephir_init_properties_Ice_Mvc_Route_DataGenerator_Regex(zend_class_entry *class_type TSRMLS_DC) { - zval *_0, *_1; + zval *_0, *_1 = NULL, *_2; - ZEPHIR_MM_GROW(); - - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_methodToRegexToRoutesMap"), _0 TSRMLS_CC); - ZEPHIR_INIT_VAR(_1); - array_init(_1); - zephir_update_property_this(this_ptr, SL("_staticRoutes"), _1 TSRMLS_CC); - ZEPHIR_MM_RESTORE(); + ZEPHIR_MM_GROW(); + + { + zval *this_ptr = NULL; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("methodToRegexToRoutesMap"), PH_NOISY_CC); + if (Z_TYPE_P(_0) == IS_NULL) { + ZEPHIR_INIT_VAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("methodToRegexToRoutesMap"), _1 TSRMLS_CC); + } + _2 = zephir_fetch_nproperty_this(this_ptr, SL("staticRoutes"), PH_NOISY_CC); + if (Z_TYPE_P(_2) == IS_NULL) { + ZEPHIR_INIT_NVAR(_1); + array_init(_1); + zephir_update_property_this(this_ptr, SL("staticRoutes"), _1 TSRMLS_CC); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJVAL_P(this_ptr); + } } diff --git a/ext/ice/mvc/route/datagenerator/regex.zep.h b/ext/ice/mvc/route/datagenerator/regex.zep.h index dbf6f74c..f97545af 100644 --- a/ext/ice/mvc/route/datagenerator/regex.zep.h +++ b/ext/ice/mvc/route/datagenerator/regex.zep.h @@ -13,7 +13,7 @@ PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, isStaticRoute); PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, addStaticRoute); PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, addVariableRoute); PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, buildRegexForRoute); -PHP_METHOD(Ice_Mvc_Route_DataGenerator_Regex, __construct); +static zend_object_value zephir_init_properties_Ice_Mvc_Route_DataGenerator_Regex(zend_class_entry *class_type TSRMLS_DC); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_route_datagenerator_regex_processchunk, 0, 0, 1) ZEND_ARG_INFO(0, regexToRoutesMap) @@ -60,6 +60,5 @@ ZEPHIR_INIT_FUNCS(ice_mvc_route_datagenerator_regex_method_entry) { PHP_ME(Ice_Mvc_Route_DataGenerator_Regex, addStaticRoute, arginfo_ice_mvc_route_datagenerator_regex_addstaticroute, ZEND_ACC_PROTECTED) PHP_ME(Ice_Mvc_Route_DataGenerator_Regex, addVariableRoute, arginfo_ice_mvc_route_datagenerator_regex_addvariableroute, ZEND_ACC_PROTECTED) PHP_ME(Ice_Mvc_Route_DataGenerator_Regex, buildRegexForRoute, arginfo_ice_mvc_route_datagenerator_regex_buildregexforroute, ZEND_ACC_PROTECTED) - PHP_ME(Ice_Mvc_Route_DataGenerator_Regex, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route/dispatcher/dispatcherinterface.zep.h b/ext/ice/mvc/route/dispatcher/dispatcherinterface.zep.h index f7557bfe..567b4067 100644 --- a/ext/ice/mvc/route/dispatcher/dispatcherinterface.zep.h +++ b/ext/ice/mvc/route/dispatcher/dispatcherinterface.zep.h @@ -10,5 +10,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_mvc_route_dispatcher_dispatcherinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Mvc_Route_Dispatcher_DispatcherInterface, dispatch, arginfo_ice_mvc_route_dispatcher_dispatcherinterface_dispatch) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route/dispatcher/groupcount.zep.c b/ext/ice/mvc/route/dispatcher/groupcount.zep.c index 6da39c26..6e4b9d58 100644 --- a/ext/ice/mvc/route/dispatcher/groupcount.zep.c +++ b/ext/ice/mvc/route/dispatcher/groupcount.zep.c @@ -17,16 +17,16 @@ #include "kernel/array.h" #include "kernel/operators.h" #include "kernel/hash.h" -#include "kernel/fcall.h" +#include "kernel/string.h" ZEPHIR_INIT_CLASS(Ice_Mvc_Route_Dispatcher_GroupCount) { ZEPHIR_REGISTER_CLASS_EX(Ice\\Mvc\\Route\\Dispatcher, GroupCount, ice, mvc_route_dispatcher_groupcount, ice_mvc_route_dispatcher_regex_ce, ice_mvc_route_dispatcher_groupcount_method_entry, 0); - zend_declare_property_null(ice_mvc_route_dispatcher_groupcount_ce, SL("_staticRouteMap"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_route_dispatcher_groupcount_ce, SL("staticRouteMap"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_route_dispatcher_groupcount_ce, SL("_variableRouteData"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_route_dispatcher_groupcount_ce, SL("variableRouteData"), ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; @@ -40,7 +40,7 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_GroupCount, setStaticRouteMap) { - zephir_update_property_this(this_ptr, SL("_staticRouteMap"), staticRouteMap TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("staticRouteMap"), staticRouteMap TSRMLS_CC); } @@ -52,7 +52,7 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_GroupCount, setVariableRouteData) { - zephir_update_property_this(this_ptr, SL("_variableRouteData"), variableRouteData TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("variableRouteData"), variableRouteData TSRMLS_CC); } @@ -74,9 +74,9 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_GroupCount, __construct) { if (zephir_fast_count_int(data TSRMLS_CC)) { zephir_array_fetch_long(&_0, data, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 16 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_staticRouteMap"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("staticRouteMap"), _0 TSRMLS_CC); zephir_array_fetch_long(&_1, data, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 17 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_variableRouteData"), _1 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("variableRouteData"), _1 TSRMLS_CC); } ZEPHIR_MM_RESTORE(); @@ -84,11 +84,10 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_GroupCount, __construct) { PHP_METHOD(Ice_Mvc_Route_Dispatcher_GroupCount, dispatchVariableRoute) { - zephir_nts_static zephir_fcall_cache_entry *_5 = NULL; - HashTable *_1, *_11; - HashPosition _0, _10; - int i, j, ZEPHIR_LAST_CALL_STATUS; - zval *routeData, *uri, *data = NULL, *matches, *handler, *varName = NULL, *varNames, *vars = NULL, **_2, *_3, *_4 = NULL, *_6, *_7, *_8, *_9, **_12, *_13, *_14 = NULL; + HashTable *_1, *_10; + HashPosition _0, _9; + int i = 0, j = 0; + zval *routeData, *uri, *data = NULL, *matches = NULL, *handler = NULL, *varName = NULL, *varNames = NULL, *vars = NULL, **_2, *_3 = NULL, *_4, *_5, *_6, *_7, *_8, **_11, *_12, *_13 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &routeData, &uri); @@ -103,46 +102,44 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_GroupCount, dispatchVariableRoute) { ; zephir_hash_move_forward_ex(_1, &_0) ) { ZEPHIR_GET_HVALUE(data, _2); - zephir_array_fetch_string(&_3, data, SL("regex"), PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 29 TSRMLS_CC); - Z_SET_ISREF_P(matches); - ZEPHIR_CALL_FUNCTION(&_4, "preg_match", &_5, _3, uri, matches); - Z_UNSET_ISREF_P(matches); - zephir_check_call_status(); - if (!(zephir_is_true(_4))) { + ZEPHIR_INIT_NVAR(_3); + zephir_array_fetch_string(&_4, data, SL("regex"), PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 29 TSRMLS_CC); + zephir_preg_match(_3, _4, uri, matches, 0, 0 , 0 TSRMLS_CC); + if (!(zephir_is_true(_3))) { continue; } j = zephir_fast_count_int(matches TSRMLS_CC); - zephir_array_fetch_string(&_6, data, SL("routeMap"), PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 34 TSRMLS_CC); - zephir_array_fetch_long(&_7, _6, j, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 34 TSRMLS_CC); - zephir_array_fetch_long(&handler, _7, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 34 TSRMLS_CC); - zephir_array_fetch_string(&_8, data, SL("routeMap"), PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 35 TSRMLS_CC); - zephir_array_fetch_long(&_9, _8, j, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 35 TSRMLS_CC); - zephir_array_fetch_long(&varNames, _9, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 35 TSRMLS_CC); + zephir_array_fetch_string(&_5, data, SL("routeMap"), PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 34 TSRMLS_CC); + zephir_array_fetch_long(&_6, _5, j, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 34 TSRMLS_CC); + zephir_array_fetch_long(&handler, _6, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 34 TSRMLS_CC); + zephir_array_fetch_string(&_7, data, SL("routeMap"), PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 35 TSRMLS_CC); + zephir_array_fetch_long(&_8, _7, j, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 35 TSRMLS_CC); + zephir_array_fetch_long(&varNames, _8, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 35 TSRMLS_CC); ZEPHIR_INIT_NVAR(vars); array_init(vars); i = 0; - zephir_is_iterable(varNames, &_11, &_10, 0, 0, "ice/mvc/route/dispatcher/groupcount.zep", 45); + zephir_is_iterable(varNames, &_10, &_9, 0, 0, "ice/mvc/route/dispatcher/groupcount.zep", 45); 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(_10, (void**) &_11, &_9) == SUCCESS + ; zephir_hash_move_forward_ex(_10, &_9) ) { - ZEPHIR_GET_HVALUE(varName, _12); + ZEPHIR_GET_HVALUE(varName, _11); i++; - zephir_array_fetch_long(&_13, matches, i, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 42 TSRMLS_CC); - zephir_array_update_zval(&vars, varName, &_13, PH_COPY | PH_SEPARATE); + zephir_array_fetch_long(&_12, matches, i, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/groupcount.zep", 42 TSRMLS_CC); + zephir_array_update_zval(&vars, varName, &_12, PH_COPY | PH_SEPARATE); } - array_init_size(return_value, 4); - ZEPHIR_INIT_NVAR(_14); - ZVAL_LONG(_14, 1); - zephir_array_fast_append(return_value, _14); + zephir_create_array(return_value, 3, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_13); + ZVAL_LONG(_13, 1); + zephir_array_fast_append(return_value, _13); zephir_array_fast_append(return_value, handler); zephir_array_fast_append(return_value, vars); RETURN_MM(); } - array_init_size(return_value, 2); - ZEPHIR_INIT_NVAR(_14); - ZVAL_LONG(_14, 0); - zephir_array_fast_append(return_value, _14); + zephir_create_array(return_value, 1, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_3); + ZVAL_LONG(_3, 0); + zephir_array_fast_append(return_value, _3); RETURN_MM(); } diff --git a/ext/ice/mvc/route/dispatcher/groupcount.zep.h b/ext/ice/mvc/route/dispatcher/groupcount.zep.h index a5c2f4de..e6da4fe5 100644 --- a/ext/ice/mvc/route/dispatcher/groupcount.zep.h +++ b/ext/ice/mvc/route/dispatcher/groupcount.zep.h @@ -30,5 +30,5 @@ ZEPHIR_INIT_FUNCS(ice_mvc_route_dispatcher_groupcount_method_entry) { PHP_ME(Ice_Mvc_Route_Dispatcher_GroupCount, setVariableRouteData, arginfo_ice_mvc_route_dispatcher_groupcount_setvariableroutedata, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Route_Dispatcher_GroupCount, __construct, arginfo_ice_mvc_route_dispatcher_groupcount___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Ice_Mvc_Route_Dispatcher_GroupCount, dispatchVariableRoute, arginfo_ice_mvc_route_dispatcher_groupcount_dispatchvariableroute, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route/dispatcher/regex.zep.c b/ext/ice/mvc/route/dispatcher/regex.zep.c index c547392b..53d7fd09 100644 --- a/ext/ice/mvc/route/dispatcher/regex.zep.c +++ b/ext/ice/mvc/route/dispatcher/regex.zep.c @@ -17,8 +17,8 @@ #include "kernel/array.h" #include "ext/spl/spl_exceptions.h" #include "kernel/exception.h" -#include "kernel/fcall.h" #include "kernel/operators.h" +#include "kernel/fcall.h" #include "kernel/hash.h" @@ -26,9 +26,9 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Route_Dispatcher_Regex) { ZEPHIR_REGISTER_CLASS(Ice\\Mvc\\Route\\Dispatcher, Regex, ice, mvc_route_dispatcher_regex, ice_mvc_route_dispatcher_regex_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(ice_mvc_route_dispatcher_regex_ce, SL("_staticRouteMap"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_route_dispatcher_regex_ce, SL("staticRouteMap"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_route_dispatcher_regex_ce, SL("_variableRouteData"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_route_dispatcher_regex_ce, SL("variableRouteData"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(ice_mvc_route_dispatcher_regex_ce TSRMLS_CC, 1, ice_mvc_route_dispatcher_dispatcherinterface_ce); return SUCCESS; @@ -43,7 +43,7 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, setStaticRouteMap) { - zephir_update_property_this(this_ptr, SL("_staticRouteMap"), staticRouteMap TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("staticRouteMap"), staticRouteMap TSRMLS_CC); } @@ -55,7 +55,7 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, setVariableRouteData) { - zephir_update_property_this(this_ptr, SL("_variableRouteData"), variableRouteData TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("variableRouteData"), variableRouteData TSRMLS_CC); } @@ -72,14 +72,13 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, setData) { array_init(data); } else { data = data_param; - } zephir_array_fetch_long(&_0, data, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 15 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_staticRouteMap"), _0 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("staticRouteMap"), _0 TSRMLS_CC); zephir_array_fetch_long(&_1, data, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 16 TSRMLS_CC); - zephir_update_property_this(this_ptr, SL("_variableRouteData"), _1 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("variableRouteData"), _1 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -90,132 +89,130 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, dispatchVariableRoute) { PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, dispatch) { - zephir_fcall_cache_entry *_7 = NULL; - HashTable *_5; - HashPosition _4; - zend_bool _1; + HashTable *_14, *_18; + HashPosition _13, _17; + zephir_fcall_cache_entry *_11 = NULL; int ZEPHIR_LAST_CALL_STATUS; - zval *httpMethod, *uri, *varRouteData, *result = NULL, *allowedMethods, *method = NULL, *routeData = NULL, *_0, *_2, *_3, **_6, *_8 = NULL; + zend_bool _1, _4, _10, _16; + zval *httpMethod, *uri, *handler = NULL, *varRouteData = NULL, *result = NULL, *allowedMethods = NULL, *uriMap = NULL, *method = NULL, *routeData = NULL, *_0, *_2, *_3, *_5, *_6, *_7, *_8, *_9 = NULL, *_12, **_15, **_19; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &httpMethod, &uri); - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_staticRouteMap"), PH_NOISY_CC); - if (zephir_array_isset(_0, uri)) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dispatchstaticroute", NULL, httpMethod, uri); - zephir_check_call_status(); + _0 = zephir_fetch_nproperty_this(this_ptr, SL("staticRouteMap"), PH_NOISY_CC); + _1 = zephir_array_isset(_0, httpMethod); + if (_1) { + _2 = zephir_fetch_nproperty_this(this_ptr, SL("staticRouteMap"), PH_NOISY_CC); + zephir_array_fetch(&_3, _2, httpMethod, PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 25 TSRMLS_CC); + _1 = zephir_array_isset(_3, uri); + } + _4 = ZEPHIR_IS_STRING_IDENTICAL(httpMethod, "HEAD"); + if (_4) { + _5 = zephir_fetch_nproperty_this(this_ptr, SL("staticRouteMap"), PH_NOISY_CC); + zephir_array_fetch_string(&_6, _5, SL("GET"), PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 28 TSRMLS_CC); + _4 = zephir_array_isset(_6, uri); + } + if (_1) { + _7 = zephir_fetch_nproperty_this(this_ptr, SL("staticRouteMap"), PH_NOISY_CC); + zephir_array_fetch(&_8, _7, httpMethod, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 26 TSRMLS_CC); + ZEPHIR_OBS_VAR(handler); + zephir_array_fetch(&handler, _8, uri, PH_NOISY, "ice/mvc/route/dispatcher/regex.zep", 26 TSRMLS_CC); + zephir_create_array(return_value, 3, 0 TSRMLS_CC); + ZEPHIR_INIT_VAR(_9); + ZVAL_LONG(_9, 1); + zephir_array_fast_append(return_value, _9); + zephir_array_fast_append(return_value, handler); + ZEPHIR_INIT_NVAR(_9); + array_init(_9); + zephir_array_fast_append(return_value, _9); + RETURN_MM(); + } else if (_4) { + _7 = zephir_fetch_nproperty_this(this_ptr, SL("staticRouteMap"), PH_NOISY_CC); + zephir_array_fetch_string(&_8, _7, SL("GET"), PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 29 TSRMLS_CC); + ZEPHIR_OBS_NVAR(handler); + zephir_array_fetch(&handler, _8, uri, PH_NOISY, "ice/mvc/route/dispatcher/regex.zep", 29 TSRMLS_CC); + zephir_create_array(return_value, 3, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_9); + ZVAL_LONG(_9, 1); + zephir_array_fast_append(return_value, _9); + zephir_array_fast_append(return_value, handler); + ZEPHIR_INIT_NVAR(_9); + array_init(_9); + zephir_array_fast_append(return_value, _9); RETURN_MM(); } ZEPHIR_OBS_VAR(varRouteData); - zephir_read_property_this(&varRouteData, this_ptr, SL("_variableRouteData"), PH_NOISY_CC); - _1 = ZEPHIR_IS_STRING_IDENTICAL(httpMethod, "HEAD"); - if (_1) { - _1 = zephir_array_isset_string(varRouteData, SS("GET")); + zephir_read_property_this(&varRouteData, this_ptr, SL("variableRouteData"), PH_NOISY_CC); + _10 = ZEPHIR_IS_STRING_IDENTICAL(httpMethod, "HEAD"); + if (_10) { + _10 = zephir_array_isset_string(varRouteData, SS("GET")); } if (zephir_array_isset(varRouteData, httpMethod)) { - zephir_array_fetch(&_2, varRouteData, httpMethod, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 32 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&result, this_ptr, "dispatchvariableroute", NULL, _2, uri); + zephir_array_fetch(&_8, varRouteData, httpMethod, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 36 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&result, this_ptr, "dispatchvariableroute", &_11, 0, _8, uri); zephir_check_call_status(); - zephir_array_fetch_long(&_3, result, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 34 TSRMLS_CC); - if (ZEPHIR_IS_LONG_IDENTICAL(_3, 1)) { + zephir_array_fetch_long(&_12, result, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 38 TSRMLS_CC); + if (ZEPHIR_IS_LONG_IDENTICAL(_12, 1)) { RETURN_CCTOR(result); } - } else if (_1) { - zephir_array_fetch_string(&_2, varRouteData, SL("GET"), PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 38 TSRMLS_CC); - ZEPHIR_CALL_METHOD(&result, this_ptr, "dispatchvariableroute", NULL, _2, uri); + } else if (_10) { + zephir_array_fetch_string(&_8, varRouteData, SL("GET"), PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 42 TSRMLS_CC); + ZEPHIR_CALL_METHOD(&result, this_ptr, "dispatchvariableroute", &_11, 0, _8, uri); zephir_check_call_status(); - zephir_array_fetch_long(&_3, result, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 40 TSRMLS_CC); - if (ZEPHIR_IS_LONG_IDENTICAL(_3, 1)) { + zephir_array_fetch_long(&_12, result, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 44 TSRMLS_CC); + if (ZEPHIR_IS_LONG_IDENTICAL(_12, 1)) { RETURN_CCTOR(result); } } ZEPHIR_INIT_VAR(allowedMethods); array_init(allowedMethods); - zephir_is_iterable(varRouteData, &_5, &_4, 0, 0, "ice/mvc/route/dispatcher/regex.zep", 61); + _7 = zephir_fetch_nproperty_this(this_ptr, SL("staticRouteMap"), PH_NOISY_CC); + zephir_is_iterable(_7, &_14, &_13, 0, 0, "ice/mvc/route/dispatcher/regex.zep", 58); + for ( + ; zephir_hash_get_current_data_ex(_14, (void**) &_15, &_13) == SUCCESS + ; zephir_hash_move_forward_ex(_14, &_13) + ) { + ZEPHIR_GET_HMKEY(method, _14, _13); + ZEPHIR_GET_HVALUE(uriMap, _15); + _16 = !ZEPHIR_IS_IDENTICAL(method, httpMethod); + if (_16) { + _16 = zephir_array_isset(uriMap, uri); + } + if (_16) { + zephir_array_append(&allowedMethods, method, PH_SEPARATE, "ice/mvc/route/dispatcher/regex.zep", 54); + } + } + zephir_is_iterable(varRouteData, &_18, &_17, 0, 0, "ice/mvc/route/dispatcher/regex.zep", 70); 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(_18, (void**) &_19, &_17) == SUCCESS + ; zephir_hash_move_forward_ex(_18, &_17) ) { - ZEPHIR_GET_HMKEY(method, _5, _4); - ZEPHIR_GET_HVALUE(routeData, _6); + ZEPHIR_GET_HMKEY(method, _18, _17); + ZEPHIR_GET_HVALUE(routeData, _19); if (ZEPHIR_IS_IDENTICAL(method, httpMethod)) { continue; } - ZEPHIR_CALL_METHOD(&result, this_ptr, "dispatchvariableroute", &_7, routeData, uri); + ZEPHIR_CALL_METHOD(&result, this_ptr, "dispatchvariableroute", &_11, 0, routeData, uri); zephir_check_call_status(); - zephir_array_fetch_long(&_2, result, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 56 TSRMLS_CC); - if (ZEPHIR_IS_LONG_IDENTICAL(_2, 1)) { - zephir_array_append(&allowedMethods, method, PH_SEPARATE, "ice/mvc/route/dispatcher/regex.zep", 57); + zephir_array_fetch_long(&_8, result, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/dispatcher/regex.zep", 65 TSRMLS_CC); + if (ZEPHIR_IS_LONG_IDENTICAL(_8, 1)) { + zephir_array_append(&allowedMethods, method, PH_SEPARATE, "ice/mvc/route/dispatcher/regex.zep", 66); } } if (zephir_is_true(allowedMethods)) { - array_init_size(return_value, 3); - ZEPHIR_INIT_VAR(_8); - ZVAL_LONG(_8, 2); - zephir_array_fast_append(return_value, _8); + zephir_create_array(return_value, 2, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_9); + ZVAL_LONG(_9, 2); + zephir_array_fast_append(return_value, _9); zephir_array_fast_append(return_value, allowedMethods); RETURN_MM(); } else { - array_init_size(return_value, 2); - ZEPHIR_INIT_NVAR(_8); - ZVAL_LONG(_8, 0); - zephir_array_fast_append(return_value, _8); - RETURN_MM(); - } - -} - -PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, dispatchStaticRoute) { - - zend_bool _1; - zval *httpMethod, *uri, *routes, *_0, *_2 = NULL, *_3 = NULL; - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &httpMethod, &uri); - - - - _0 = zephir_fetch_nproperty_this(this_ptr, SL("_staticRouteMap"), PH_NOISY_CC); - ZEPHIR_OBS_VAR(routes); - zephir_array_fetch(&routes, _0, uri, PH_NOISY, "ice/mvc/route/dispatcher/regex.zep", 72 TSRMLS_CC); - _1 = ZEPHIR_IS_STRING_IDENTICAL(httpMethod, "HEAD"); - if (_1) { - _1 = zephir_array_isset_string(routes, SS("GET")); - } - if (zephir_array_isset(routes, httpMethod)) { - array_init_size(return_value, 4); - ZEPHIR_INIT_VAR(_2); - ZVAL_LONG(_2, 1); - zephir_array_fast_append(return_value, _2); - ZEPHIR_OBS_VAR(_3); - zephir_array_fetch(&_3, routes, httpMethod, PH_NOISY, "ice/mvc/route/dispatcher/regex.zep", 75 TSRMLS_CC); - zephir_array_fast_append(return_value, _3); - ZEPHIR_INIT_NVAR(_2); - array_init(_2); - zephir_array_fast_append(return_value, _2); - RETURN_MM(); - } else if (_1) { - array_init_size(return_value, 4); - ZEPHIR_INIT_NVAR(_2); - ZVAL_LONG(_2, 1); - zephir_array_fast_append(return_value, _2); - ZEPHIR_OBS_NVAR(_3); - zephir_array_fetch_string(&_3, routes, SL("GET"), PH_NOISY, "ice/mvc/route/dispatcher/regex.zep", 77 TSRMLS_CC); - zephir_array_fast_append(return_value, _3); - ZEPHIR_INIT_NVAR(_2); - array_init(_2); - zephir_array_fast_append(return_value, _2); - RETURN_MM(); - } else { - array_init_size(return_value, 3); - ZEPHIR_INIT_NVAR(_2); - ZVAL_LONG(_2, 2); - zephir_array_fast_append(return_value, _2); - ZEPHIR_INIT_NVAR(_2); - zephir_array_keys(_2, routes TSRMLS_CC); - zephir_array_fast_append(return_value, _2); + zephir_create_array(return_value, 1, 0 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_9); + ZVAL_LONG(_9, 0); + zephir_array_fast_append(return_value, _9); RETURN_MM(); } diff --git a/ext/ice/mvc/route/dispatcher/regex.zep.h b/ext/ice/mvc/route/dispatcher/regex.zep.h index 0aecb4f9..b42a4a43 100644 --- a/ext/ice/mvc/route/dispatcher/regex.zep.h +++ b/ext/ice/mvc/route/dispatcher/regex.zep.h @@ -8,7 +8,6 @@ PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, setVariableRouteData); PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, setData); PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, dispatchVariableRoute); PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, dispatch); -PHP_METHOD(Ice_Mvc_Route_Dispatcher_Regex, dispatchStaticRoute); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_route_dispatcher_regex_setstaticroutemap, 0, 0, 1) ZEND_ARG_INFO(0, staticRouteMap) @@ -32,17 +31,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_route_dispatcher_regex_dispatch, 0, 0, 2) ZEND_ARG_INFO(0, uri) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_route_dispatcher_regex_dispatchstaticroute, 0, 0, 2) - ZEND_ARG_INFO(0, httpMethod) - ZEND_ARG_INFO(0, uri) -ZEND_END_ARG_INFO() - ZEPHIR_INIT_FUNCS(ice_mvc_route_dispatcher_regex_method_entry) { PHP_ME(Ice_Mvc_Route_Dispatcher_Regex, setStaticRouteMap, arginfo_ice_mvc_route_dispatcher_regex_setstaticroutemap, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Route_Dispatcher_Regex, setVariableRouteData, arginfo_ice_mvc_route_dispatcher_regex_setvariableroutedata, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Route_Dispatcher_Regex, setData, arginfo_ice_mvc_route_dispatcher_regex_setdata, ZEND_ACC_PUBLIC) PHP_ME(Ice_Mvc_Route_Dispatcher_Regex, dispatchVariableRoute, arginfo_ice_mvc_route_dispatcher_regex_dispatchvariableroute, ZEND_ACC_PROTECTED|ZEND_ACC_ABSTRACT) PHP_ME(Ice_Mvc_Route_Dispatcher_Regex, dispatch, arginfo_ice_mvc_route_dispatcher_regex_dispatch, ZEND_ACC_PUBLIC) - PHP_ME(Ice_Mvc_Route_Dispatcher_Regex, dispatchStaticRoute, arginfo_ice_mvc_route_dispatcher_regex_dispatchstaticroute, ZEND_ACC_PROTECTED) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route/parser/parserinterface.zep.c b/ext/ice/mvc/route/parser/parserinterface.zep.c index 03a957ea..b6554518 100644 --- a/ext/ice/mvc/route/parser/parserinterface.zep.c +++ b/ext/ice/mvc/route/parser/parserinterface.zep.c @@ -21,18 +21,32 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Route_Parser_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 */ ZEPHIR_DOC_METHOD(Ice_Mvc_Route_Parser_ParserInterface, parse); diff --git a/ext/ice/mvc/route/parser/parserinterface.zep.h b/ext/ice/mvc/route/parser/parserinterface.zep.h index 145227f8..df040c21 100644 --- a/ext/ice/mvc/route/parser/parserinterface.zep.h +++ b/ext/ice/mvc/route/parser/parserinterface.zep.h @@ -9,5 +9,5 @@ ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(ice_mvc_route_parser_parserinterface_method_entry) { PHP_ABSTRACT_ME(Ice_Mvc_Route_Parser_ParserInterface, parse, arginfo_ice_mvc_route_parser_parserinterface_parse) - PHP_FE_END + PHP_FE_END }; diff --git a/ext/ice/mvc/route/parser/std.zep.c b/ext/ice/mvc/route/parser/std.zep.c index e0463119..27b5e002 100644 --- a/ext/ice/mvc/route/parser/std.zep.c +++ b/ext/ice/mvc/route/parser/std.zep.c @@ -12,24 +12,26 @@ #include #include "kernel/main.h" +#include "kernel/string.h" #include "kernel/memory.h" +#include "kernel/concat.h" #include "kernel/fcall.h" #include "kernel/operators.h" -#include "kernel/array.h" +#include "kernel/exception.h" #include "kernel/hash.h" -#include "kernel/string.h" +#include "kernel/array.h" /** - * Parses routes of the following form: + * Parses route strings of the following form: * - * "/user/{name}/{id:[0-9]+}" + * "/user/{name}[/{id:[0-9]+}]" */ ZEPHIR_INIT_CLASS(Ice_Mvc_Route_Parser_Std) { ZEPHIR_REGISTER_CLASS(Ice\\Mvc\\Route\\Parser, Std, ice, mvc_route_parser_std, ice_mvc_route_parser_std_method_entry, 0); - zend_declare_class_constant_string(ice_mvc_route_parser_std_ce, SL("VARIABLE_REGEX"), "~\\{ \\s* ([a-zA-Z][a-zA-Z0-9_]*) \\s* (?: : \\s* ([^{}]*(?:\\{(?-1)\\}[^{}]*)*) )? \\}~x" TSRMLS_CC); + zend_declare_class_constant_string(ice_mvc_route_parser_std_ce, SL("VARIABLE_REGEX"), "\\{ \\s* ([a-zA-Z][a-zA-Z0-9_]*) \\s* (?: : \\s* ([^{}]*(?:\\{(?-1)\\}[^{}]*)*) )? \\}" TSRMLS_CC); zend_declare_class_constant_string(ice_mvc_route_parser_std_ce, SL("DEFAULT_DISPATCH_REGEX"), "[^/]+" TSRMLS_CC); @@ -40,12 +42,81 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Route_Parser_Std) { PHP_METHOD(Ice_Mvc_Route_Parser_Std, parse) { - zval *_13 = NULL; - HashTable *_5; - HashPosition _4; - zephir_nts_static zephir_fcall_cache_entry *_3 = NULL; - int offset = 0, ZEPHIR_LAST_CALL_STATUS; - zval *route, *matches, *routeData, *value = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, **_6, *_7, *_8, *_9, *_10, _11 = zval_used_for_init, _12 = zval_used_for_init, *_14 = NULL, *_15 = NULL, *_16, *_17, *_18, *_19, *_20; + zephir_fcall_cache_entry *_10 = NULL; + zend_bool _8; + HashTable *_6; + HashPosition _5; + int ZEPHIR_LAST_CALL_STATUS; + zval *_1, *_4; + zval *route, *routeWithoutClosingOptionals = NULL, *numOptionals = NULL, *segments = NULL, *currentRoute = NULL, *routeDatas = NULL, *n = NULL, *segment = NULL, _0, *_2, *_3, **_7, *_9 = NULL; + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &route); + + + + ZEPHIR_SINIT_VAR(_0); + ZVAL_LONG(&_0, ']'); + ZEPHIR_INIT_VAR(routeWithoutClosingOptionals); + zephir_fast_trim(routeWithoutClosingOptionals, route, &_0, ZEPHIR_TRIM_RIGHT TSRMLS_CC); + ZEPHIR_INIT_VAR(numOptionals); + ZVAL_LONG(numOptionals, (zephir_fast_strlen_ev(route) - zephir_fast_strlen_ev(routeWithoutClosingOptionals))); + ZEPHIR_INIT_VAR(_1); + ZEPHIR_CONCAT_SSS(_1, "~", "\\{ \\s* ([a-zA-Z][a-zA-Z0-9_]*) \\s* (?: : \\s* ([^{}]*(?:\\{(?-1)\\}[^{}]*)*) )? \\}", "(*SKIP)(*F) | \\[~x"); + ZEPHIR_CALL_FUNCTION(&segments, "preg_split", NULL, 123, _1, routeWithoutClosingOptionals); + zephir_check_call_status(); + if (!ZEPHIR_IS_LONG_IDENTICAL(numOptionals, (zephir_fast_count_int(segments TSRMLS_CC) - 1))) { + ZEPHIR_INIT_VAR(_2); + ZEPHIR_INIT_VAR(_3); + ZEPHIR_INIT_VAR(_4); + ZEPHIR_CONCAT_SSS(_4, "~", "\\{ \\s* ([a-zA-Z][a-zA-Z0-9_]*) \\s* (?: : \\s* ([^{}]*(?:\\{(?-1)\\}[^{}]*)*) )? \\}", "(*SKIP)(*F) | \\]~x"); + zephir_preg_match(_3, _4, routeWithoutClosingOptionals, _2, 0, 0 , 0 TSRMLS_CC); + if (zephir_is_true(_3)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Optional segments can only occur at the end of a route", "ice/mvc/route/parser/std.zep", 30); + return; + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Number of opening '[' and closing ']' does not match", "ice/mvc/route/parser/std.zep", 33); + return; + } + ZEPHIR_INIT_VAR(currentRoute); + ZVAL_STRING(currentRoute, "", 1); + ZEPHIR_INIT_VAR(routeDatas); + array_init(routeDatas); + zephir_is_iterable(segments, &_6, &_5, 0, 0, "ice/mvc/route/parser/std.zep", 48); + for ( + ; zephir_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS + ; zephir_hash_move_forward_ex(_6, &_5) + ) { + ZEPHIR_GET_HMKEY(n, _6, _5); + ZEPHIR_GET_HVALUE(segment, _7); + _8 = ZEPHIR_IS_STRING_IDENTICAL(segment, ""); + if (_8) { + _8 = !ZEPHIR_IS_LONG_IDENTICAL(n, 0); + } + if (_8) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Empty optional part", "ice/mvc/route/parser/std.zep", 41); + return; + } + zephir_concat_self(¤tRoute, segment TSRMLS_CC); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "parseplaceholders", &_10, 124, currentRoute); + zephir_check_call_status(); + zephir_array_append(&routeDatas, _9, PH_SEPARATE, "ice/mvc/route/parser/std.zep", 45); + } + RETURN_CCTOR(routeDatas); + +} + +/** + * Parses a route string that does not contain optional segments. + */ +PHP_METHOD(Ice_Mvc_Route_Parser_Std, parsePlaceholders) { + + zval *_11 = NULL; + HashTable *_4; + HashPosition _3; + int ZEPHIR_LAST_CALL_STATUS; + zval *_0; + zval *route, *matches = NULL, *routeData = NULL, *value = NULL, *offset = NULL, *_1 = NULL, *_2 = NULL, **_5, *_6, *_7, *_8, *_9, _10 = zval_used_for_init, *_12 = NULL, *_13 = NULL, *_14, *_15, *_16, *_17, *_18, *_19; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &route); @@ -55,70 +126,68 @@ PHP_METHOD(Ice_Mvc_Route_Parser_Std, parse) { ZEPHIR_INIT_VAR(matches); array_init(matches); ZEPHIR_INIT_VAR(_0); - ZVAL_STRING(_0, "~\\{ \\s* ([a-zA-Z][a-zA-Z0-9_]*) \\s* (?: : \\s* ([^{}]*(?:\\{(?-1)\\}[^{}]*)*) )? \\}~x", ZEPHIR_TEMP_PARAM_COPY); + ZEPHIR_CONCAT_SSS(_0, "~", "\\{ \\s* ([a-zA-Z][a-zA-Z0-9_]*) \\s* (?: : \\s* ([^{}]*(?:\\{(?-1)\\}[^{}]*)*) )? \\}", "~x"); ZEPHIR_INIT_VAR(_1); ZVAL_LONG(_1, (256 | 2)); - Z_SET_ISREF_P(matches); - ZEPHIR_CALL_FUNCTION(&_2, "preg_match_all", &_3, _0, route, matches, _1); - zephir_check_temp_parameter(_0); - Z_UNSET_ISREF_P(matches); + ZEPHIR_MAKE_REF(matches); + ZEPHIR_CALL_FUNCTION(&_2, "preg_match_all", NULL, 125, _0, route, matches, _1); + ZEPHIR_UNREF(matches); zephir_check_call_status(); if (!(zephir_is_true(_2))) { - array_init_size(return_value, 2); + zephir_create_array(return_value, 1, 0 TSRMLS_CC); zephir_array_fast_append(return_value, route); RETURN_MM(); } + ZEPHIR_INIT_VAR(offset); + ZVAL_LONG(offset, 0); ZEPHIR_INIT_VAR(routeData); array_init(routeData); - zephir_is_iterable(matches, &_5, &_4, 0, 0, "ice/mvc/route/parser/std.zep", 41); + zephir_is_iterable(matches, &_4, &_3, 0, 0, "ice/mvc/route/parser/std.zep", 79); 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(_4, (void**) &_5, &_3) == SUCCESS + ; zephir_hash_move_forward_ex(_4, &_3) ) { - ZEPHIR_GET_HVALUE(value, _6); - zephir_array_fetch_long(&_7, value, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 29 TSRMLS_CC); - zephir_array_fetch_long(&_8, _7, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 29 TSRMLS_CC); - if (ZEPHIR_GT_LONG(_8, offset)) { - zephir_array_fetch_long(&_9, value, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 30 TSRMLS_CC); - zephir_array_fetch_long(&_10, _9, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 30 TSRMLS_CC); - ZEPHIR_SINIT_NVAR(_11); - ZVAL_LONG(&_11, offset); - ZEPHIR_SINIT_NVAR(_12); - ZVAL_LONG(&_12, (zephir_get_numberval(_10) - offset)); - ZEPHIR_INIT_NVAR(_0); - zephir_substr(_0, route, zephir_get_intval(&_11), zephir_get_intval(&_12), 0); - zephir_array_append(&routeData, _0, PH_SEPARATE, "ice/mvc/route/parser/std.zep", 30); + ZEPHIR_GET_HVALUE(value, _5); + zephir_array_fetch_long(&_6, value, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 68 TSRMLS_CC); + zephir_array_fetch_long(&_7, _6, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 68 TSRMLS_CC); + if (ZEPHIR_GT(_7, offset)) { + zephir_array_fetch_long(&_8, value, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 69 TSRMLS_CC); + zephir_array_fetch_long(&_9, _8, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 69 TSRMLS_CC); + ZEPHIR_SINIT_NVAR(_10); + zephir_sub_function(&_10, _9, offset); + ZEPHIR_INIT_NVAR(_1); + zephir_substr(_1, route, zephir_get_intval(offset), zephir_get_intval(&_10), 0); + zephir_array_append(&routeData, _1, PH_SEPARATE, "ice/mvc/route/parser/std.zep", 69); } - ZEPHIR_INIT_NVAR(_13); - array_init_size(_13, 3); - zephir_array_fetch_long(&_9, value, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 34 TSRMLS_CC); - ZEPHIR_OBS_NVAR(_14); - zephir_array_fetch_long(&_14, _9, 0, PH_NOISY, "ice/mvc/route/parser/std.zep", 34 TSRMLS_CC); - zephir_array_fast_append(_13, _14); - ZEPHIR_INIT_LNVAR(_15); + ZEPHIR_INIT_NVAR(_11); + zephir_create_array(_11, 2, 0 TSRMLS_CC); + zephir_array_fetch_long(&_8, value, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 73 TSRMLS_CC); + ZEPHIR_OBS_NVAR(_12); + zephir_array_fetch_long(&_12, _8, 0, PH_NOISY, "ice/mvc/route/parser/std.zep", 73 TSRMLS_CC); + zephir_array_fast_append(_11, _12); + ZEPHIR_INIT_LNVAR(_13); if (zephir_array_isset_long(value, 2)) { - ZEPHIR_INIT_NVAR(_15); - zephir_array_fetch_long(&_10, value, 2, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 35 TSRMLS_CC); - zephir_array_fetch_long(&_16, _10, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 35 TSRMLS_CC); - zephir_fast_trim(_15, _16, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); + zephir_array_fetch_long(&_9, value, 2, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 74 TSRMLS_CC); + zephir_array_fetch_long(&_14, _9, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 74 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_13); + zephir_fast_trim(_13, _14, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC); } else { - ZEPHIR_INIT_NVAR(_15); - ZVAL_STRING(_15, "[^/]+", 1); + ZEPHIR_INIT_NVAR(_13); + ZVAL_STRING(_13, "[^/]+", 1); } - zephir_array_fast_append(_13, _15); - zephir_array_append(&routeData, _13, PH_SEPARATE, "ice/mvc/route/parser/std.zep", 36); - zephir_array_fetch_long(&_17, value, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 38 TSRMLS_CC); - zephir_array_fetch_long(&_18, _17, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 38 TSRMLS_CC); - zephir_array_fetch_long(&_19, value, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 38 TSRMLS_CC); - zephir_array_fetch_long(&_20, _19, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 38 TSRMLS_CC); - offset = (zephir_get_numberval(_18) + zephir_fast_strlen_ev(_20)); + zephir_array_fast_append(_11, _13); + zephir_array_append(&routeData, _11, PH_SEPARATE, "ice/mvc/route/parser/std.zep", 75); + zephir_array_fetch_long(&_15, value, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 76 TSRMLS_CC); + zephir_array_fetch_long(&_16, _15, 1, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 76 TSRMLS_CC); + zephir_array_fetch_long(&_17, value, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 76 TSRMLS_CC); + zephir_array_fetch_long(&_18, _17, 0, PH_NOISY | PH_READONLY, "ice/mvc/route/parser/std.zep", 76 TSRMLS_CC); + ZEPHIR_INIT_NVAR(offset); + ZVAL_LONG(offset, (zephir_get_numberval(_16) + zephir_fast_strlen_ev(_18))); } - if (offset != zephir_fast_strlen_ev(route)) { - ZEPHIR_SINIT_NVAR(_11); - ZVAL_LONG(&_11, offset); - ZEPHIR_INIT_NVAR(_1); - zephir_substr(_1, route, zephir_get_intval(&_11), 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_array_append(&routeData, _1, PH_SEPARATE, "ice/mvc/route/parser/std.zep", 42); + if (!ZEPHIR_IS_LONG(offset, zephir_fast_strlen_ev(route))) { + ZEPHIR_INIT_VAR(_19); + zephir_substr(_19, route, zephir_get_intval(offset), 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_array_append(&routeData, _19, PH_SEPARATE, "ice/mvc/route/parser/std.zep", 80); } RETURN_CCTOR(routeData); diff --git a/ext/ice/mvc/route/parser/std.zep.h b/ext/ice/mvc/route/parser/std.zep.h index 0f49b1b0..180f38fb 100644 --- a/ext/ice/mvc/route/parser/std.zep.h +++ b/ext/ice/mvc/route/parser/std.zep.h @@ -4,12 +4,18 @@ extern zend_class_entry *ice_mvc_route_parser_std_ce; ZEPHIR_INIT_CLASS(Ice_Mvc_Route_Parser_Std); PHP_METHOD(Ice_Mvc_Route_Parser_Std, parse); +PHP_METHOD(Ice_Mvc_Route_Parser_Std, parsePlaceholders); ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_route_parser_std_parse, 0, 0, 1) ZEND_ARG_INFO(0, route) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_ice_mvc_route_parser_std_parseplaceholders, 0, 0, 1) + ZEND_ARG_INFO(0, route) +ZEND_END_ARG_INFO() + ZEPHIR_INIT_FUNCS(ice_mvc_route_parser_std_method_entry) { PHP_ME(Ice_Mvc_Route_Parser_Std, parse, arginfo_ice_mvc_route_parser_std_parse, ZEND_ACC_PUBLIC) - PHP_FE_END + PHP_ME(Ice_Mvc_Route_Parser_Std, parsePlaceholders, arginfo_ice_mvc_route_parser_std_parseplaceholders, ZEND_ACC_PRIVATE) + PHP_FE_END }; diff --git a/ext/ice/mvc/router.zep.c b/ext/ice/mvc/router.zep.c index 8a5e6826..2bdef402 100644 --- a/ext/ice/mvc/router.zep.c +++ b/ext/ice/mvc/router.zep.c @@ -26,40 +26,53 @@ #include "kernel/variables.h" #include "kernel/string.h" + +/** + * Router is the standard framework router. Routing is the process of taking a URI endpoint and decomposing it into + * parameters to determine which module, controller, and action of that controller should receive the request. + * + * @package Ice/Router + * @category Component + * @author Ice Team + * @copyright (c) 2014-2015 Ice Team + * @license http://iceframework.org/license + * @uses FastRoute http:/github.com/nikic/FastRoute + */ ZEPHIR_INIT_CLASS(Ice_Mvc_Router) { ZEPHIR_REGISTER_CLASS(Ice\\Mvc, Router, ice, mvc_router, ice_mvc_router_method_entry, 0); - zend_declare_property_null(ice_mvc_router_ce, SL("_di"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("di"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_mvc_router_ce, SL("_defaultModule"), "default", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_mvc_router_ce, SL("defaultModule"), "default", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_mvc_router_ce, SL("_defaultHandler"), "index", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_mvc_router_ce, SL("defaultHandler"), "index", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(ice_mvc_router_ce, SL("_defaultAction"), "index", ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_string(ice_mvc_router_ce, SL("defaultAction"), "index", ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_router_ce, SL("_method"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("method"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_router_ce, SL("_module"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("module"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_router_ce, SL("_handler"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("handler"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_router_ce, SL("_action"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("action"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_router_ce, SL("_params"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("params"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_bool(ice_mvc_router_ce, SL("_ready"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(ice_mvc_router_ce, SL("ready"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_bool(ice_mvc_router_ce, SL("_silent"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(ice_mvc_router_ce, SL("silent"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_router_ce, SL("_options"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("options"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_router_ce, SL("_routes"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("routes"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_router_ce, SL("_collector"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("collector"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_null(ice_mvc_router_ce, SL("_dispatcher"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(ice_mvc_router_ce, SL("dispatcher"), ZEND_ACC_PROTECTED TSRMLS_CC); + ice_mvc_router_ce->create_object = zephir_init_properties_Ice_Mvc_Router; zend_declare_class_constant_long(ice_mvc_router_ce, SL("NOT_FOUND"), 0 TSRMLS_CC); zend_declare_class_constant_long(ice_mvc_router_ce, SL("FOUND"), 1 TSRMLS_CC); @@ -73,7 +86,7 @@ ZEPHIR_INIT_CLASS(Ice_Mvc_Router) { PHP_METHOD(Ice_Mvc_Router, getDefaultModule) { - RETURN_MEMBER(this_ptr, "_defaultModule"); + RETURN_MEMBER(this_ptr, "defaultModule"); } @@ -85,14 +98,14 @@ PHP_METHOD(Ice_Mvc_Router, setDefaultModule) { - zephir_update_property_this(this_ptr, SL("_defaultModule"), defaultModule TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultModule"), defaultModule TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Router, getDefaultHandler) { - RETURN_MEMBER(this_ptr, "_defaultHandler"); + RETURN_MEMBER(this_ptr, "defaultHandler"); } @@ -104,14 +117,14 @@ PHP_METHOD(Ice_Mvc_Router, setDefaultHandler) { - zephir_update_property_this(this_ptr, SL("_defaultHandler"), defaultHandler TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultHandler"), defaultHandler TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Router, getDefaultAction) { - RETURN_MEMBER(this_ptr, "_defaultAction"); + RETURN_MEMBER(this_ptr, "defaultAction"); } @@ -123,42 +136,42 @@ PHP_METHOD(Ice_Mvc_Router, setDefaultAction) { - zephir_update_property_this(this_ptr, SL("_defaultAction"), defaultAction TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultAction"), defaultAction TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Router, getMethod) { - RETURN_MEMBER(this_ptr, "_method"); + RETURN_MEMBER(this_ptr, "method"); } PHP_METHOD(Ice_Mvc_Router, getModule) { - RETURN_MEMBER(this_ptr, "_module"); + RETURN_MEMBER(this_ptr, "module"); } PHP_METHOD(Ice_Mvc_Router, getHandler) { - RETURN_MEMBER(this_ptr, "_handler"); + RETURN_MEMBER(this_ptr, "handler"); } PHP_METHOD(Ice_Mvc_Router, getAction) { - RETURN_MEMBER(this_ptr, "_action"); + RETURN_MEMBER(this_ptr, "action"); } PHP_METHOD(Ice_Mvc_Router, getParams) { - RETURN_MEMBER(this_ptr, "_params"); + RETURN_MEMBER(this_ptr, "params"); } @@ -170,14 +183,14 @@ PHP_METHOD(Ice_Mvc_Router, setSilent) { - zephir_update_property_this(this_ptr, SL("_silent"), silent TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("silent"), silent TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Router, getOptions) { - RETURN_MEMBER(this_ptr, "_options"); + RETURN_MEMBER(this_ptr, "options"); } @@ -189,14 +202,14 @@ PHP_METHOD(Ice_Mvc_Router, setOptions) { - zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("options"), options TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Router, getRoutes) { - RETURN_MEMBER(this_ptr, "_routes"); + RETURN_MEMBER(this_ptr, "routes"); } @@ -208,14 +221,14 @@ PHP_METHOD(Ice_Mvc_Router, setRoutes) { - zephir_update_property_this(this_ptr, SL("_routes"), routes TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("routes"), routes TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Router, getCollector) { - RETURN_MEMBER(this_ptr, "_collector"); + RETURN_MEMBER(this_ptr, "collector"); } @@ -227,14 +240,14 @@ PHP_METHOD(Ice_Mvc_Router, setCollector) { - zephir_update_property_this(this_ptr, SL("_collector"), collector TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("collector"), collector TSRMLS_CC); } PHP_METHOD(Ice_Mvc_Router, getDispatcher) { - RETURN_MEMBER(this_ptr, "_dispatcher"); + RETURN_MEMBER(this_ptr, "dispatcher"); } @@ -246,7 +259,7 @@ PHP_METHOD(Ice_Mvc_Router, setDispatcher) { - zephir_update_property_this(this_ptr, SL("_dispatcher"), dispatcher TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("dispatcher"), dispatcher TSRMLS_CC); } @@ -256,17 +269,14 @@ PHP_METHOD(Ice_Mvc_Router, setDispatcher) { PHP_METHOD(Ice_Mvc_Router, __construct) { int ZEPHIR_LAST_CALL_STATUS; - zephir_nts_static zephir_fcall_cache_entry *_2 = NULL; - zval *_0, *_1 = NULL; + zephir_fcall_cache_entry *_1 = NULL; + zval *_0 = NULL; ZEPHIR_MM_GROW(); - ZEPHIR_INIT_VAR(_0); - array_init(_0); - zephir_update_property_this(this_ptr, SL("_params"), _0 TSRMLS_CC); - ZEPHIR_CALL_CE_STATIC(&_1, ice_di_ce, "fetch", &_2); + ZEPHIR_CALL_CE_STATIC(&_0, ice_di_ce, "fetch", &_1, 8); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_di"), _1 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("di"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); } @@ -278,7 +288,7 @@ PHP_METHOD(Ice_Mvc_Router, __construct) { */ PHP_METHOD(Ice_Mvc_Router, setDefaults) { - zval *defaults_param = NULL, *module, *handler, *action; + zval *defaults_param = NULL, *module = NULL, *handler = NULL, *action = NULL; zval *defaults = NULL; zephir_fetch_params(0, 1, 0, &defaults_param); @@ -286,176 +296,163 @@ PHP_METHOD(Ice_Mvc_Router, setDefaults) { defaults = defaults_param; - if (zephir_array_isset_string_fetch(&module, defaults, SS("module"), 1 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_defaultModule"), module TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultModule"), module TSRMLS_CC); } if (zephir_array_isset_string_fetch(&handler, defaults, SS("handler"), 1 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_defaultHandler"), handler TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultHandler"), handler TSRMLS_CC); } if (zephir_array_isset_string_fetch(&action, defaults, SS("action"), 1 TSRMLS_CC)) { - zephir_update_property_this(this_ptr, SL("_defaultAction"), action TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("defaultAction"), action TSRMLS_CC); } } /** * Prepare the FastRoute. - * - * @param object routeDefinitionCallback - * @param array options */ PHP_METHOD(Ice_Mvc_Router, fastRoute) { - HashTable *_13; - HashPosition _12; + HashTable *_14; + HashPosition _13; int ZEPHIR_LAST_CALL_STATUS; - zend_class_entry *_7, *_10, *_21; - zend_bool _2, _3, _18, _19; - zval *options = NULL, *_1; - zval *routeDefinitionCallback = NULL, *options_param = NULL, *dispatcher = NULL, *data = NULL, *collector, *parser, *generator, *route = NULL, *handler = NULL, *_0, *_4 = NULL, *_5, *_6 = NULL, *_8, *_9 = NULL, *_11, **_14, *_15, *_16, *_17, *_20 = NULL, *_22 = NULL, *_23; + zend_class_entry *_8, *_11, *_22; + zend_bool _3, _4, _19, _20; + zval *_0; + zval *options = NULL, *dispatcher = NULL, *data = NULL, *collector = NULL, *parser = NULL, *generator = NULL, *route = NULL, *handler = NULL, *_1, *_2, *_5 = NULL, *_6, *_7 = NULL, *_9, *_10 = NULL, *_12, **_15, *_16, *_17, *_18, *_21 = NULL, *_23 = NULL, *_24; ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 2, &routeDefinitionCallback, &options_param); - - if (!routeDefinitionCallback) { - routeDefinitionCallback = ZEPHIR_GLOBAL(global_null); - } - if (!options_param) { - ZEPHIR_INIT_VAR(options); - array_init(options); - } else { - zephir_get_arrval(options, options_param); - } - ZEPHIR_INIT_VAR(_0); - ZEPHIR_INIT_VAR(_1); - array_init_size(_1, 6); - add_assoc_stringl_ex(_1, SS("routeParser"), SL("Ice\\Mvc\\Route\\Parser\\Std"), 1); - add_assoc_stringl_ex(_1, SS("dataGenerator"), SL("Ice\\Mvc\\Route\\DataGenerator\\GroupCount"), 1); - add_assoc_stringl_ex(_1, SS("dispatcher"), SL("Ice\\Mvc\\Route\\Dispatcher\\GroupCount"), 1); - zephir_array_update_string(&_1, SL("cache"), &ZEPHIR_GLOBAL(global_false), PH_COPY | PH_SEPARATE); - zephir_fast_array_merge(_0, &(_1), &(options) TSRMLS_CC); - ZEPHIR_CPY_WRT(options, _0); - zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC); - ZEPHIR_OBS_VAR(collector); - zephir_read_property_this(&collector, this_ptr, SL("_collector"), PH_NOISY_CC); - _2 = Z_TYPE_P(collector) != IS_OBJECT; - if (!(_2)) { - _3 = Z_TYPE_P(collector) == IS_OBJECT; - if (_3) { - _3 = !((zephir_instance_of_ev(collector, ice_mvc_route_collector_ce TSRMLS_CC))); + zephir_create_array(_0, 4, 0 TSRMLS_CC); + add_assoc_stringl_ex(_0, SS("routeParser"), SL("Ice\\Mvc\\Route\\Parser\\Std"), 1); + add_assoc_stringl_ex(_0, SS("dataGenerator"), SL("Ice\\Mvc\\Route\\DataGenerator\\GroupCount"), 1); + add_assoc_stringl_ex(_0, SS("dispatcher"), SL("Ice\\Mvc\\Route\\Dispatcher\\GroupCount"), 1); + zephir_array_update_string(&_0, SL("cache"), &ZEPHIR_GLOBAL(global_false), PH_COPY | PH_SEPARATE); + _1 = zephir_fetch_nproperty_this(this_ptr, SL("options"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(options); + zephir_fast_array_merge(options, &(_0), &(_1) TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("options"), options TSRMLS_CC); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("collector"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(collector, _2); + _3 = Z_TYPE_P(collector) != IS_OBJECT; + if (!(_3)) { + _4 = Z_TYPE_P(collector) == IS_OBJECT; + if (_4) { + _4 = !((zephir_instance_of_ev(collector, ice_mvc_route_collector_ce TSRMLS_CC))); } - _2 = _3; + _3 = _4; } - if (_2) { + if (_3) { ZEPHIR_OBS_VAR(parser); zephir_array_isset_string_fetch(&parser, options, SS("routeParser"), 0 TSRMLS_CC); ZEPHIR_OBS_VAR(generator); zephir_array_isset_string_fetch(&generator, options, SS("dataGenerator"), 0 TSRMLS_CC); - ZEPHIR_INIT_VAR(_4); - object_init_ex(_4, ice_mvc_route_collector_ce); ZEPHIR_INIT_VAR(_5); - zephir_fetch_safe_class(_6, parser); - _7 = zend_fetch_class(Z_STRVAL_P(_6), Z_STRLEN_P(_6), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); - object_init_ex(_5, _7); - if (zephir_has_constructor(_5 TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, _5, "__construct", NULL); + object_init_ex(_5, ice_mvc_route_collector_ce); + ZEPHIR_INIT_VAR(_6); + zephir_fetch_safe_class(_7, parser); + _8 = zend_fetch_class(Z_STRVAL_P(_7), Z_STRLEN_P(_7), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); + object_init_ex(_6, _8); + if (zephir_has_constructor(_6 TSRMLS_CC)) { + ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, 0); zephir_check_call_status(); } - ZEPHIR_INIT_VAR(_8); - zephir_fetch_safe_class(_9, generator); - _10 = zend_fetch_class(Z_STRVAL_P(_9), Z_STRLEN_P(_9), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); - object_init_ex(_8, _10); - if (zephir_has_constructor(_8 TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, _8, "__construct", NULL); + ZEPHIR_INIT_VAR(_9); + zephir_fetch_safe_class(_10, generator); + _11 = zend_fetch_class(Z_STRVAL_P(_10), Z_STRLEN_P(_10), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); + object_init_ex(_9, _11); + if (zephir_has_constructor(_9 TSRMLS_CC)) { + ZEPHIR_CALL_METHOD(NULL, _9, "__construct", NULL, 0); zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, _5, _8); + ZEPHIR_CALL_METHOD(NULL, _5, "__construct", NULL, 126, _6, _9); zephir_check_call_status(); - zephir_update_property_this(this_ptr, SL("_collector"), _4 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("collector"), _5 TSRMLS_CC); } - if (zephir_is_callable(routeDefinitionCallback TSRMLS_CC) == 1) { - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_collector"), PH_NOISY_CC); - ZEPHIR_CALL_ZVAL_FUNCTION(NULL, routeDefinitionCallback, NULL, _11); - zephir_check_call_status(); - } - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); - if (!(zephir_is_true(_11))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "There are no routes.", "ice/mvc/router.zep", 108); + _2 = zephir_fetch_nproperty_this(this_ptr, SL("routes"), PH_NOISY_CC); + if (!(zephir_is_true(_2))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "There are no routes.", "ice/mvc/router.zep", 100); return; } else { - _11 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC); - zephir_is_iterable(_11, &_13, &_12, 0, 0, "ice/mvc/router.zep", 114); + _12 = zephir_fetch_nproperty_this(this_ptr, SL("routes"), PH_NOISY_CC); + zephir_is_iterable(_12, &_14, &_13, 0, 0, "ice/mvc/router.zep", 106); for ( - ; zephir_hash_get_current_data_ex(_13, (void**) &_14, &_12) == SUCCESS - ; zephir_hash_move_forward_ex(_13, &_12) + ; zephir_hash_get_current_data_ex(_14, (void**) &_15, &_13) == SUCCESS + ; zephir_hash_move_forward_ex(_14, &_13) ) { - ZEPHIR_GET_HVALUE(route, _14); + ZEPHIR_GET_HVALUE(route, _15); ZEPHIR_OBS_NVAR(handler); zephir_array_isset_long_fetch(&handler, route, 2, 0 TSRMLS_CC); - _15 = zephir_fetch_nproperty_this(this_ptr, SL("_collector"), PH_NOISY_CC); - zephir_array_fetch_long(&_16, route, 0, PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 112 TSRMLS_CC); - zephir_array_fetch_long(&_17, route, 1, PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 112 TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, _15, "addroute", NULL, _16, _17, handler); + _16 = zephir_fetch_nproperty_this(this_ptr, SL("collector"), PH_NOISY_CC); + zephir_array_fetch_long(&_17, route, 0, PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 104 TSRMLS_CC); + zephir_array_fetch_long(&_18, route, 1, PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 104 TSRMLS_CC); + ZEPHIR_CALL_METHOD(NULL, _16, "addroute", NULL, 0, _17, _18, handler); zephir_check_call_status(); } } - ZEPHIR_OBS_VAR(dispatcher); - zephir_read_property_this(&dispatcher, this_ptr, SL("_dispatcher"), PH_NOISY_CC); - _18 = Z_TYPE_P(dispatcher) != IS_OBJECT; - if (!(_18)) { - _19 = Z_TYPE_P(dispatcher) == IS_OBJECT; - if (_19) { - _19 = !((zephir_instance_of_ev(dispatcher, ice_mvc_route_dispatcher_dispatcherinterface_ce TSRMLS_CC))); + _12 = zephir_fetch_nproperty_this(this_ptr, SL("dispatcher"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(dispatcher, _12); + _19 = Z_TYPE_P(dispatcher) != IS_OBJECT; + if (!(_19)) { + _20 = Z_TYPE_P(dispatcher) == IS_OBJECT; + if (_20) { + _20 = !((zephir_instance_of_ev(dispatcher, ice_mvc_route_dispatcher_dispatcherinterface_ce TSRMLS_CC))); } - _18 = _19; + _19 = _20; } - if (_18) { + if (_19) { ZEPHIR_OBS_NVAR(dispatcher); - zephir_array_fetch_string(&dispatcher, options, SL("dispatcher"), PH_NOISY, "ice/mvc/router.zep", 118 TSRMLS_CC); - ZEPHIR_INIT_NVAR(_4); - zephir_fetch_safe_class(_20, dispatcher); - _21 = zend_fetch_class(Z_STRVAL_P(_20), Z_STRLEN_P(_20), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); - object_init_ex(_4, _21); - if (zephir_has_constructor(_4 TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL); + zephir_array_fetch_string(&dispatcher, options, SL("dispatcher"), PH_NOISY, "ice/mvc/router.zep", 111 TSRMLS_CC); + ZEPHIR_INIT_NVAR(_5); + zephir_fetch_safe_class(_21, dispatcher); + _22 = zend_fetch_class(Z_STRVAL_P(_21), Z_STRLEN_P(_21), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); + object_init_ex(_5, _22); + if (zephir_has_constructor(_5 TSRMLS_CC)) { + ZEPHIR_CALL_METHOD(NULL, _5, "__construct", NULL, 0); zephir_check_call_status(); } - zephir_update_property_this(this_ptr, SL("_dispatcher"), _4 TSRMLS_CC); + zephir_update_property_this(this_ptr, SL("dispatcher"), _5 TSRMLS_CC); } - zephir_array_fetch_string(&_16, options, SL("cache"), PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 122 TSRMLS_CC); - if (zephir_is_true(_16)) { + zephir_array_fetch_string(&_17, options, SL("cache"), PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 115 TSRMLS_CC); + if (zephir_is_true(_17)) { if (!(zephir_array_isset_string(options, SS("cacheFile")))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Must specify 'cacheFile' option", "ice/mvc/router.zep", 124); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(ice_exception_ce, "Must specify 'cacheFile' option", "ice/mvc/router.zep", 117); return; } - zephir_array_fetch_string(&_16, options, SL("cacheFile"), PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 127 TSRMLS_CC); - if ((zephir_file_exists(_16 TSRMLS_CC) == SUCCESS)) { - zephir_array_fetch_string(&_17, options, SL("cacheFile"), PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 128 TSRMLS_CC); - ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_22); - if (zephir_require_zval_ret(&_22, _17 TSRMLS_CC) == FAILURE) { + zephir_array_fetch_string(&_17, options, SL("cacheFile"), PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 120 TSRMLS_CC); + if ((zephir_file_exists(_17 TSRMLS_CC) == SUCCESS)) { + zephir_array_fetch_string(&_18, options, SL("cacheFile"), PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 121 TSRMLS_CC); + ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_23); + if (zephir_require_zval_ret(&_23, _18 TSRMLS_CC) == FAILURE) { RETURN_MM_NULL(); } - ZEPHIR_CPY_WRT(data, _22); + ZEPHIR_CPY_WRT(data, _23); } else { - zephir_array_fetch_string(&_16, options, SL("cacheFile"), PH_NOISY | PH_READONLY, "ice/mvc/router.zep", 130 TSRMLS_CC); - ZEPHIR_INIT_NVAR(_4); - zephir_var_export_ex(_4, &(data) TSRMLS_CC); - ZEPHIR_INIT_VAR(_23); - ZEPHIR_CONCAT_SVS(_23, " +#include "../../php_ext.h" +#include "../../ext.h" + +#include +#include +#include + +#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 
    + *  $this->tag->button(['some', 'content']);
    + *  
    + *  // Sleet 
    + *  {{ 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 
    + * $this->tag->form(['post/add']); + * + * // + * $this->tag->form(['http://example.com', 'local' => false]); + * + * // Sleet + * {{ form([false]) }} + * + * // + * {{ form(['post/add', 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal']) }} + *
    + * * @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 Logo
    + *  $this->tag->img(['img/logo.png', 'Logo']);
    + *  
    + *  // Sleet Logo
    + *  {{ 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 
    +     *  $this->tag->button(['some', 'content']);
    +     *  
    +     *  // Sleet 
    +     *  {{ 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 
    + * $this->tag->form(['post/add']); + * + * // + * $this->tag->form(['http://example.com', 'local' => false]); + * + * // Sleet + * {{ form([false]) }} + * + * // + * {{ form(['post/add', 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal']) }} + *
    + * * @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 Logo
    +     *  $this->tag->img(['img/logo.png', 'Logo']);
    +     *  
    +     *  // Sleet Logo
    +     *  {{ 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